Skip to content

Commit

Permalink
Minor bug fixes and enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
point85 committed Apr 13, 2018
1 parent 6670efc commit d066aad
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 49 deletions.
Binary file modified build/libs/Shift.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>POINT85</groupId>
<artifactId>SHIFT</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/org/point85/workschedule/Team.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@ public ShiftInstance getShiftInstanceForDay(LocalDate day) throws Exception {
ShiftInstance instance = null;

Rotation shiftRotation = getRotation();

if (shiftRotation.getDuration().equals(Duration.ZERO)) {
// no instance for that day
return instance;
}

int dayInRotation = getDayInRotation(day);

// shift or off shift
Expand Down
25 changes: 17 additions & 8 deletions src/main/java/org/point85/workschedule/WorkSchedule.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ of this software and associated documentation files (the "Software"), to deal
* @author Kent Randall
*
*/
public class WorkSchedule extends Named {
public class WorkSchedule extends Named implements Comparable<WorkSchedule> {
// name of resource bundle with translatable strings for exception messages
private static final String MESSAGES_BUNDLE_NAME = "Message";
private static final String MESSAGES_BUNDLE_NAME = "WorkScheduleMessage";

// resource bundle for exception messages
private static final ResourceBundle messages = ResourceBundle.getBundle(MESSAGES_BUNDLE_NAME, Locale.getDefault());
Expand Down Expand Up @@ -155,19 +155,19 @@ public List<ShiftInstance> getShiftInstancesForDay(LocalDate day) throws Excepti
if (instance == null) {
continue;
}

// check to see if this is a non-working day
boolean addShift = true;

LocalDate startDate = instance.getStartTime().toLocalDate();

for (NonWorkingPeriod nonWorkingPeriod : nonWorkingPeriods) {
if (nonWorkingPeriod.isInPeriod(startDate)) {
addShift = false;
break;
}
}

if (addShift) {
workingShifts.add(instance);
}
Expand Down Expand Up @@ -324,7 +324,8 @@ public NonWorkingPeriod createNonWorkingPeriod(String name, String description,
* Get total duration of rotation across all teams.
*
* @return Duration of rotation
* @throws Exception Exception
* @throws Exception
* Exception
*/
public Duration getRotationDuration() throws Exception {
Duration sum = Duration.ZERO;
Expand Down Expand Up @@ -363,7 +364,7 @@ public Duration getRotationWorkingTime() {
*/
public Duration calculateWorkingTime(LocalDateTime from, LocalDateTime to) throws Exception {
Duration sum = Duration.ZERO;

// now add up scheduled time by team
for (Team team : getTeams()) {
sum = sum.plus(team.calculateWorkingTime(from, to));
Expand Down Expand Up @@ -567,4 +568,12 @@ public Integer getVersion() {
public void setVersion(Integer version) {
this.version = version;
}

/**
* Compare one work schedule to another
*/
@Override
public int compareTo(WorkSchedule other) {
return getName().compareTo(other.getName());
}
}
40 changes: 0 additions & 40 deletions src/main/resources/Message.properties

This file was deleted.

File renamed without changes.

0 comments on commit d066aad

Please sign in to comment.