Skip to content

Commit

Permalink
Set task start, finish and percent complete when reading SDEF files.
Browse files Browse the repository at this point in the history
  • Loading branch information
joniles committed Jul 1, 2019
1 parent 7c74424 commit 81cdefc
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
</properties>
<body>
<release date="git master" version="7.9.1">
<action dev="joniles" type="update">Set task start, finish and percent complete when reading SDEF files.</action>
</release>
<release date="01/07/2019" version="7.9.0">
<action dev="joniles" type="add">Add support for reading SDEF files.</action>
Expand Down
1 change: 1 addition & 0 deletions src/main/java/net/sf/mpxj/sdef/ActivityRecord.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class ActivityRecord extends AbstractSDEFRecord
task.setText(8, getString(13));
task.setText(9, getString(14));
task.setGUID(UUID.nameUUIDFromBytes(activityID.getBytes()));
task.setMilestone(task.getDuration() != null && task.getDuration().getDuration() == 0);
context.getEventManager().fireTaskReadEvent(task);
}

Expand Down
36 changes: 33 additions & 3 deletions src/main/java/net/sf/mpxj/sdef/ProgressRecord.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@
* along with this library; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/

package net.sf.mpxj.sdef;

import java.util.Date;

import net.sf.mpxj.Duration;
import net.sf.mpxj.Task;
import net.sf.mpxj.TimeUnit;
Expand All @@ -36,7 +39,7 @@ class ProgressRecord extends AbstractSDEFRecord
{
return FIELDS;
}

@Override public void process(Context context)
{
Double totalCost = getDouble(4);
Expand All @@ -47,7 +50,7 @@ class ProgressRecord extends AbstractSDEFRecord
{
totalFloat = Duration.getInstance(-totalFloat.getDuration(), TimeUnit.DAYS);
}

Task task = context.getTask(getString(0));
task.setActualStart(getDate(1));
task.setActualFinish(getDate(2));
Expand All @@ -60,8 +63,35 @@ class ProgressRecord extends AbstractSDEFRecord
task.setLateStart(getDate(9));
task.setLateFinish(getDate(10));
task.setTotalSlack(totalFloat);

Date start = task.getActualStart() == null ? task.getEarlyStart() : task.getActualStart();
Date finish = task.getActualFinish() == null ? task.getEarlyFinish() : task.getActualFinish();
double percentComplete = 0;

if (task.getActualFinish() == null)
{
Duration duration = task.getDuration();
Duration remainingDuration = task.getRemainingDuration();
if (duration != null && remainingDuration != null)
{
double durationValue = duration.getDuration();
double remainingDurationValue = remainingDuration.getDuration();
if (durationValue != 0 && remainingDurationValue < durationValue)
{
percentComplete = ((durationValue - remainingDurationValue) * 100.0)/durationValue;
}
}
}
else
{
percentComplete = 100.0;
}

task.setStart(start);
task.setFinish(finish);
task.setPercentageComplete(Double.valueOf(percentComplete));
}

private static final SDEFField[] FIELDS = new SDEFField[]
{
new StringField("Activity ID", 10),
Expand Down

0 comments on commit 81cdefc

Please sign in to comment.