@@ -33,13 +33,13 @@ namespace Point85.ShiftSharp.Schedule
3333 public class Team : Named , IComparable < Team >
3434 {
3535 // owning work schedule
36- private WorkSchedule workSchedule ;
36+ public WorkSchedule WorkSchedule { get ; set ; }
3737
3838 // reference date for starting the rotations
39- private LocalDate rotationStart ;
39+ public LocalDate RotationStart { get ; set ; }
4040
4141 // shift rotation days
42- private Rotation rotation ;
42+ public Rotation Rotation { get ; set ; }
4343
4444 /**
4545 * Default constructor
@@ -50,68 +50,8 @@ public Team() : base()
5050
5151 internal Team ( string name , string description , Rotation rotation , LocalDate rotationStart ) : base ( name , description )
5252 {
53- this . rotation = rotation ;
54- this . SetRotationStart ( rotationStart ) ;
55- }
56-
57- /**
58- * Get rotation start
59- *
60- * @return Rotation start date
61- */
62- public LocalDate GetRotationStart ( )
63- {
64- return rotationStart ;
65- }
66-
67- /**
68- * Get rotation start
69- *
70- * @param rotationStart
71- * Starting date of rotation
72- */
73- public void SetRotationStart ( LocalDate rotationStart )
74- {
75- this . rotationStart = rotationStart ;
76- }
77-
78- /*
79- private long GetDayFrom()
80- {
81- LocalDate localDate;
82- int eraYear = localDate.YearOfEra;
83- //NodaTime.Calendars.Era era = rotationStart.Era;
84- //LocalDateTime now;
85- Instant unixStart = Instant.FromUnixTimeSeconds(0);
86- Instant.FromUtc(2017, 10, 23, 0, 0, 0);
87- Instant now = SystemClock.Instance.GetCurrentInstant();
88-
89- Instant unixEpoch = NodaConstants.UnixEpoch;
90- Duration duration = now.Minus(unixEpoch);
91-
92- return rotationStart.toEpochDay();
93- }
94- */
95-
96- /**
97- * Get the shift rotation for this team
98- *
99- * @return {@link Rotation}
100- */
101- public Rotation GetRotation ( )
102- {
103- return rotation ;
104- }
105-
106- /**
107- * Set the shift rotation for this team
108- *
109- * @param rotation
110- * {@link Rotation}
111- */
112- public void SetRotation ( Rotation rotation )
113- {
114- this . rotation = rotation ;
53+ this . Rotation = rotation ;
54+ this . RotationStart = rotationStart ;
11555 }
11656
11757 /**
@@ -123,7 +63,7 @@ public void SetRotation(Rotation rotation)
12363 */
12464 public Duration GetRotationDuration ( )
12565 {
126- return GetRotation ( ) . GetDuration ( ) ;
66+ return Rotation . GetDuration ( ) ;
12767 }
12868
12969 /**
@@ -136,7 +76,7 @@ public Duration GetRotationDuration()
13676 */
13777 public float GetPercentageWorked ( )
13878 {
139- double ratio = GetRotation ( ) . GetWorkingTime ( ) . TotalSeconds / GetRotationDuration ( ) . TotalSeconds ;
79+ double ratio = Rotation . GetWorkingTime ( ) . TotalSeconds / GetRotationDuration ( ) . TotalSeconds ;
14080 return ( float ) ratio * 100.0f ;
14181 }
14282
@@ -147,8 +87,8 @@ public float GetPercentageWorked()
14787 */
14888 public Duration GetHoursWorkedPerWeek ( )
14989 {
150- double days = GetRotation ( ) . GetDuration ( ) . TotalDays ;
151- double secPerWeek = GetRotation ( ) . GetWorkingTime ( ) . TotalSeconds * ( 7.0f / days ) ;
90+ double days = Rotation . GetDuration ( ) . TotalDays ;
91+ double secPerWeek = Rotation . GetWorkingTime ( ) . TotalSeconds * ( 7.0f / days ) ;
15292 return Duration . FromSeconds ( secPerWeek ) ;
15393 }
15494
@@ -164,15 +104,15 @@ public Duration GetHoursWorkedPerWeek()
164104 public int GetDayInRotation ( LocalDate date )
165105 {
166106 // calculate total number of days from start of rotation
167- long deltaDays = TimePeriod . DeltaDays ( rotationStart , date ) ;
107+ long deltaDays = TimePeriod . DeltaDays ( RotationStart , date ) ;
168108
169109 if ( deltaDays < 0 )
170110 {
171- string msg = string . Format ( WorkSchedule . GetMessage ( "end.earlier.than.start" ) , rotationStart , date ) ;
111+ string msg = string . Format ( WorkSchedule . GetMessage ( "end.earlier.than.start" ) , RotationStart , date ) ;
172112 throw new Exception ( msg ) ;
173113 }
174114
175- int dayInRotation = ( int ) ( deltaDays % GetRotation ( ) . GetDuration ( ) . Days ) + 1 ;
115+ int dayInRotation = ( int ) ( deltaDays % Rotation . GetDuration ( ) . Days ) + 1 ;
176116 return dayInRotation ;
177117 }
178118
@@ -189,15 +129,15 @@ public ShiftInstance GetShiftInstanceForDay(LocalDate day)
189129 {
190130 ShiftInstance instance = null ;
191131
192- Rotation shiftRotation = GetRotation ( ) ;
132+ Rotation shiftRotation = Rotation ;
193133 int dayInRotation = GetDayInRotation ( day ) ;
194134
195135 // shift or off shift
196136 TimePeriod period = shiftRotation . GetPeriods ( ) [ dayInRotation - 1 ] ;
197137
198138 if ( period . IsWorkingPeriod ( ) )
199139 {
200- LocalDateTime startDateTime = day . At ( period . GetStart ( ) ) ;
140+ LocalDateTime startDateTime = day . At ( period . StartTime ) ;
201141 instance = new ShiftInstance ( ( Shift ) period , startDateTime , this ) ;
202142 }
203143
@@ -218,7 +158,7 @@ public bool IsDayOff(LocalDate day)
218158
219159 bool dayOff = false ;
220160
221- Rotation shiftRotation = GetRotation ( ) ;
161+ Rotation shiftRotation = Rotation ;
222162 int dayInRotation = GetDayInRotation ( day ) ;
223163
224164 // shift or off shift
@@ -258,7 +198,7 @@ public Duration CalculateWorkingTime(LocalDateTime from, LocalDateTime to)
258198 LocalTime thisTime = from . TimeOfDay ;
259199 LocalDate toDate = to . Date ;
260200 LocalTime toTime = to . TimeOfDay ;
261- int dayCount = GetRotation ( ) . GetDayCount ( ) ;
201+ int dayCount = Rotation . GetDayCount ( ) ;
262202
263203 // get the working shift from yesterday
264204 Shift lastShift = null ;
@@ -326,7 +266,7 @@ public Duration CalculateWorkingTime(LocalDateTime from, LocalDateTime to)
326266 if ( rotationEndDate . CompareTo ( toDate ) < 0 )
327267 {
328268 n = dayCount ;
329- sum = sum . Plus ( GetRotation ( ) . GetWorkingTime ( ) ) ;
269+ sum = sum . Plus ( Rotation . GetWorkingTime ( ) ) ;
330270 }
331271 }
332272
@@ -338,21 +278,6 @@ public Duration CalculateWorkingTime(LocalDateTime from, LocalDateTime to)
338278 return sum ;
339279 }
340280
341- /**
342- * Get the work schedule that owns this team
343- *
344- * @return {@link WorkSchedule}
345- */
346- public WorkSchedule GetWorkSchedule ( )
347- {
348- return workSchedule ;
349- }
350-
351- internal void SetWorkSchedule ( WorkSchedule workSchedule )
352- {
353- this . workSchedule = workSchedule ;
354- }
355-
356281 /**
357282 * Compare one team to another
358283 */
@@ -374,12 +299,11 @@ public override string ToString()
374299 string text = "" ;
375300 try
376301 {
377- text = base . ToString ( ) + ", " + rs + ": " + GetRotationStart ( ) + ", " + GetRotation ( ) + ", " + rpct + ": "
302+ text = base . ToString ( ) + ", " + rs + ": " + RotationStart + ", " + Rotation + ", " + rpct + ": "
378303 + GetPercentageWorked ( ) . ToString ( "0.00" ) + "%" + ", " + avg + ": " + GetHoursWorkedPerWeek ( ) ;
379304 }
380305 catch ( Exception )
381306 {
382- // ignore
383307 }
384308
385309 return text ;
0 commit comments