1 |
|
|
2 |
|
|
3 |
|
@author |
4 |
|
|
5 |
|
package pl.magot.vetch.ancal.database; |
6 |
|
|
7 |
|
|
8 |
|
import java.util.*; |
9 |
|
import pl.magot.vetch.ancal.RepeatData; |
10 |
|
|
11 |
|
|
|
|
| 89,6% |
Uncovered Elements: 8 (77) |
Complexity: 22 |
Complexity Density: 0,44 |
|
12 |
|
public class DataRowAppointment extends DataRow |
13 |
|
{ |
14 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 0 |
Complexity Density: - |
|
15 |
|
public static class fid |
16 |
|
{ |
17 |
|
public static final int ID = 0; |
18 |
|
public static final int Subject = 1; |
19 |
|
public static final int StartDate = 2; |
20 |
|
public static final int DurationInMinutes = 3; |
21 |
|
public static final int AllDay = 4; |
22 |
|
public static final int Alarm = 5; |
23 |
|
public static final int RepeatType = 6; |
24 |
|
public static final int RepeatEvery = 7; |
25 |
|
public static final int RepeatEndOnDate = 8; |
26 |
|
}; |
27 |
|
|
28 |
|
|
29 |
|
private final DataField[] TableDef = { |
30 |
|
new DataField(fid.ID, "_ID", DataField.Type.INT, true, true), |
31 |
|
new DataField(fid.Subject, "Subject", DataField.Type.TEXT, true, false), |
32 |
|
new DataField(fid.StartDate, "StartDate", DataField.Type.INT, true, false), |
33 |
|
new DataField(fid.DurationInMinutes, "DurationInMinutes", DataField.Type.INT, true, false), |
34 |
|
new DataField(fid.AllDay, "AllDay", DataField.Type.BOOL, true, false), |
35 |
|
new DataField(fid.Alarm, "Alarm", DataField.Type.BOOL, true, false), |
36 |
|
new DataField(fid.RepeatType, "RepeatType", DataField.Type.INT, true, false), |
37 |
|
new DataField(fid.RepeatEvery, "RepeatEvery", DataField.Type.INT, true, false), |
38 |
|
new DataField(fid.RepeatEndOnDate, "RepeatEndOnDate", DataField.Type.INT, true, false), |
39 |
|
}; |
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
private String sSubject = ""; |
44 |
|
private Calendar calDateStart = Calendar.getInstance(); |
45 |
|
private Calendar calDateStop = Calendar.getInstance(); |
46 |
|
private int iDurationInMinutes = 15; |
47 |
|
private boolean bAllDay = false; |
48 |
|
private boolean bAlarm = true; |
49 |
|
private RepeatData Repeat = new RepeatData(); |
50 |
|
|
51 |
|
|
52 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
53 |
37
|
public DataRowAppointment(Database userdb)... |
54 |
|
{ |
55 |
37
|
super(userdb); |
56 |
37
|
SetTableDefinition(TableDef); |
57 |
|
} |
58 |
|
|
59 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
60 |
11
|
public void SetSubject(String value)... |
61 |
|
{ |
62 |
11
|
sSubject = new String(value.trim()); |
63 |
|
} |
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
|
64 |
11
|
public void SetStartDate(Calendar calDate)... |
65 |
|
{ |
66 |
11
|
calDateStart.setTimeInMillis(calDate.getTimeInMillis()); |
67 |
11
|
calDateStart.set(Calendar.SECOND, 0); |
68 |
11
|
calDateStart.set(Calendar.MILLISECOND, 0); |
69 |
|
} |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
70 |
12
|
public void SetDuration(long value)... |
71 |
|
{ |
72 |
12
|
iDurationInMinutes = (int)value; |
73 |
|
} |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
74 |
11
|
public void SetAllDay(boolean value)... |
75 |
|
{ |
76 |
11
|
bAllDay = value; |
77 |
|
} |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
78 |
11
|
public void SetAlarm(boolean value)... |
79 |
|
{ |
80 |
11
|
bAlarm = value; |
81 |
|
} |
82 |
|
|
83 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
84 |
11
|
public String GetSubject()... |
85 |
|
{ |
86 |
11
|
return sSubject; |
87 |
|
} |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
88 |
14
|
public Calendar GetStartDate()... |
89 |
|
{ |
90 |
14
|
return calDateStart; |
91 |
|
} |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
92 |
8
|
public int GetDuration()... |
93 |
|
{ |
94 |
8
|
return iDurationInMinutes; |
95 |
|
} |
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
|
96 |
0
|
public Calendar GetStopDate()... |
97 |
|
{ |
98 |
0
|
calDateStop.setTimeInMillis(calDateStart.getTimeInMillis()); |
99 |
0
|
calDateStop.add(Calendar.MINUTE, iDurationInMinutes); |
100 |
0
|
return calDateStop; |
101 |
|
} |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
102 |
11
|
public boolean GetAllDay()... |
103 |
|
{ |
104 |
11
|
return bAllDay; |
105 |
|
} |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
106 |
11
|
public boolean GetAlarm()... |
107 |
|
{ |
108 |
11
|
return bAlarm; |
109 |
|
} |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
110 |
52
|
public RepeatData GetRepeat()... |
111 |
|
{ |
112 |
52
|
return Repeat; |
113 |
|
} |
114 |
|
|
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
|
119 |
|
|
120 |
|
|
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
|
133 |
|
|
134 |
|
|
135 |
|
|
|
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 2 |
Complexity Density: 0,67 |
|
136 |
8
|
@Override... |
137 |
|
public boolean Validate() |
138 |
|
{ |
139 |
8
|
if (sSubject.length() > 0) |
140 |
|
{ |
141 |
8
|
return true; |
142 |
|
} |
143 |
0
|
return false; |
144 |
|
} |
145 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (18) |
Complexity: 3 |
Complexity Density: 0,21 |
|
146 |
8
|
@Override... |
147 |
|
public void SetValuesForDataRow() |
148 |
|
{ |
149 |
8
|
ClearContentValues(); |
150 |
|
|
151 |
8
|
Value(fid.Subject).set(GetSubject()); |
152 |
8
|
Value(fid.StartDate).set(GetStartDate()); |
153 |
8
|
Value(fid.DurationInMinutes).set(GetDuration()); |
154 |
8
|
Value(fid.AllDay).set(GetAllDay()); |
155 |
8
|
Value(fid.Alarm).set(GetAlarm()); |
156 |
|
|
157 |
8
|
int iRepeatType = GetRepeat().GetRepeatTypeAsInt(); |
158 |
|
|
159 |
8
|
Value(fid.RepeatType).set(iRepeatType); |
160 |
8
|
Value(fid.RepeatEvery).setNull(); |
161 |
8
|
Value(fid.RepeatEndOnDate).setNull(); |
162 |
|
|
163 |
|
|
164 |
8
|
if (iRepeatType != 0) |
165 |
|
{ |
166 |
6
|
Value(fid.RepeatEvery).set(GetRepeat().GetEvery()); |
167 |
6
|
if (GetRepeat().UsingEndOnDate()) |
168 |
|
{ |
169 |
2
|
Value(fid.RepeatEndOnDate).set(GetRepeat().GetEndOnDate()); |
170 |
|
} |
171 |
|
} |
172 |
|
} |
173 |
|
|
|
|
| 88,9% |
Uncovered Elements: 2 (18) |
Complexity: 3 |
Complexity Density: 0,21 |
|
174 |
3
|
@Override... |
175 |
|
public void GetValuesFromDataRow() |
176 |
|
{ |
177 |
|
|
178 |
3
|
SetSubject(Value(fid.Subject).asString()); |
179 |
|
|
180 |
3
|
SetStartDate(Value(fid.StartDate).asCalendar()); |
181 |
3
|
SetDuration(Value(fid.DurationInMinutes).asLong()); |
182 |
|
|
183 |
3
|
SetAllDay(Value(fid.AllDay).asBoolean()); |
184 |
3
|
SetAlarm(Value(fid.Alarm).asBoolean()); |
185 |
|
|
186 |
3
|
long lRepeatType = Value(fid.RepeatType).asLong(); |
187 |
3
|
GetRepeat().SetRepeatTypeAsInt((int)lRepeatType); |
188 |
|
|
189 |
|
|
190 |
3
|
GetRepeat().SetEndOnDate(null); |
191 |
3
|
if (lRepeatType == 0) |
192 |
|
{ |
193 |
0
|
GetRepeat().SetEvery(1); |
194 |
|
} else { |
195 |
3
|
GetRepeat().SetEvery((int)Value(fid.RepeatEvery).asLong()); |
196 |
3
|
if (!Value(fid.RepeatEndOnDate).isNull()) |
197 |
|
{ |
198 |
1
|
Calendar calDate = Value(fid.RepeatEndOnDate).asCalendar(); |
199 |
1
|
GetRepeat().SetEndOnDate(calDate); |
200 |
|
} |
201 |
|
} |
202 |
|
} |
203 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
204 |
59
|
@Override... |
205 |
|
public String GetTableName() |
206 |
|
{ |
207 |
59
|
return Database.sTableNameAppointments; |
208 |
|
} |
209 |
|
|
210 |
|
} |