Clover Coverage Report - AnCal Coverage Report
Coverage timestamp: gio dic 18 2014 12:18:42 EST
../../../../../img/srcFileCovDistChart9.png 40% of files have more coverage
50   210   22   2,94
10   152   0,44   8,5
17     1,29  
2    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  DataRowAppointment       Line # 12 50 22 89,6% 0.8961039
  DataRowAppointment.fid       Line # 15 0 0 - -1.0
 
No Tests
 
1    /**
2    * 12-12-2007
3    * @author Piotr
4    */
5    package pl.magot.vetch.ancal.database;
6   
7   
8    import java.util.*;
9    import pl.magot.vetch.ancal.RepeatData;
10   
11   
 
12    public class DataRowAppointment extends DataRow
13    {
14    //Table field indexes for field select speedup
 
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    //Table definition
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    //fields
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    //methods
 
53  37 toggle public DataRowAppointment(Database userdb)
54    {
55  37 super(userdb);
56  37 SetTableDefinition(TableDef);
57    }
58   
59    //setters
 
60  11 toggle public void SetSubject(String value)
61    {
62  11 sSubject = new String(value.trim());
63    }
 
64  11 toggle 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    }
 
70  12 toggle public void SetDuration(long value)
71    {
72  12 iDurationInMinutes = (int)value;
73    }
 
74  11 toggle public void SetAllDay(boolean value)
75    {
76  11 bAllDay = value;
77    }
 
78  11 toggle public void SetAlarm(boolean value)
79    {
80  11 bAlarm = value;
81    }
82   
83    //getters
 
84  11 toggle public String GetSubject()
85    {
86  11 return sSubject;
87    }
 
88  14 toggle public Calendar GetStartDate()
89    {
90  14 return calDateStart;
91    }
 
92  8 toggle public int GetDuration()
93    {
94  8 return iDurationInMinutes;
95    }
 
96  0 toggle public Calendar GetStopDate()
97    {
98  0 calDateStop.setTimeInMillis(calDateStart.getTimeInMillis());
99  0 calDateStop.add(Calendar.MINUTE, iDurationInMinutes);
100  0 return calDateStop;
101    }
 
102  11 toggle public boolean GetAllDay()
103    {
104  11 return bAllDay;
105    }
 
106  11 toggle public boolean GetAlarm()
107    {
108  11 return bAlarm;
109    }
 
110  52 toggle public RepeatData GetRepeat()
111    {
112  52 return Repeat;
113    }
114   
115    /*
116    public String toString()
117    {
118    String s = "";
119    s += sSubject + "\n";
120   
121    SimpleDateFormat dateFormatFull = new SimpleDateFormat("EEEE, dd-MM-yyyy, hh:mm");
122    dateFormatFull.format(calDateStart);
123   
124    s += DateFormat.format("EEEE, dd-MM-yyyy, hh:mm", calDateStart).toString() + "\n";
125   
126    s += String.format("allday: %b, alarm: %b", bAllDay, bAlarm) + "\n";
127    s += String.format("repeat: %d", GetRepeat().GetRepeatTypeAsInt()) + "\n";
128    s += String.format("every: %d, endon: %b", GetRepeat().GetEvery(), GetRepeat().UsingEndOnDate()) + "\n";
129   
130    s += DateFormat.format("EEEE, dd-MM-yyyy, ", GetRepeat().GetEndOnDate()) + "\n";
131   
132    return s;
133    }
134    */
135   
 
136  8 toggle @Override
137    public boolean Validate()
138    {
139  8 if (sSubject.length() > 0)
140    {
141  8 return true;
142    }
143  0 return false;
144    }
145   
 
146  8 toggle @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    //if repeat type != NONE
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   
 
174  3 toggle @Override
175    public void GetValuesFromDataRow()
176    {
177    //subject values is not required for compare
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    //if repeat type == NONE
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   
 
204  59 toggle @Override
205    public String GetTableName()
206    {
207  59 return Database.sTableNameAppointments;
208    }
209   
210    }