Skip to content

Commit

Permalink
Avoid reading empty calendar exceptions from MPX files.
Browse files Browse the repository at this point in the history
  • Loading branch information
joniles committed Dec 21, 2017
1 parent be3ba28 commit c2ceb4f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions maven/src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<action dev="joniles" type="update">Gracefully handle POI issue 61677 to allow MPP affected MPP files to be read successfully.</action>
<action dev="joniles" type="update">Handle recurring calendar exceptions read from MSPDI files without an occurrence count.</action>
<action dev="joniles" type="update">Improve robustness of FastTrack schedule reader.</action>
<action dev="joniles" type="update">Avoid reading empty calendar exceptions from MPX files.</action>
</release>
<release date="20/11/2017" version="7.0.2">
<action dev="joniles" type="update">Further improvements to task pruning for Asta PP files.</action>
Expand Down
23 changes: 19 additions & 4 deletions src/net/sf/mpxj/mpx/MPXReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ private void populateCalendarHours(Record record, ProjectCalendarHours hours) th
}

/**
* Get a date range that correctly handles the cae where the end time
* Get a date range that correctly handles the case where the end time
* is midnight. In this instance the end time should be the start of the
* next day.
*
Expand Down Expand Up @@ -678,9 +678,24 @@ private void populateCalendarException(Record record, ProjectCalendar calendar)
ProjectCalendarException exception = calendar.addCalendarException(fromDate, toDate);
if (working)
{
exception.addRange(new DateRange(record.getTime(3), record.getTime(4)));
exception.addRange(new DateRange(record.getTime(5), record.getTime(6)));
exception.addRange(new DateRange(record.getTime(7), record.getTime(8)));
addExceptionRange(exception, record.getTime(3), record.getTime(4));
addExceptionRange(exception, record.getTime(5), record.getTime(6));
addExceptionRange(exception, record.getTime(7), record.getTime(8));
}
}

/**
* Add a range to an exception, ensure that we don't try to add null ranges.
*
* @param exception target exception
* @param start exception start
* @param finish exception finish
*/
private void addExceptionRange(ProjectCalendarException exception, Date start, Date finish)
{
if (start != null && finish != null)
{
exception.addRange(new DateRange(start, finish));
}
}

Expand Down

0 comments on commit c2ceb4f

Please sign in to comment.