cal = taskCalendar;
} else {
cal = defaultCalendar;
}
final MPXDuration duration;
boolean milestone = task.getMilestoneValue();
if (milestone == true) {
duration = MILESTONE_DURATION;
} else {
Date taskStart = task.getStart();
Date taskFinish = task.getFinish();
if (taskStart != null && taskFinish != null) {
//duration = cal.getDuration(taskStart, taskFinish);
duration = task.getDuration();
} else {
duration = task.getDuration();
}
}
//
// Create the new task object
//
GanttTask gtask = tm.createTask();
// gtask.setChecked();
// gtask.setColor();
gtask.setCompletionPercentage((int) task.getPercentageCompleteValue());
// gtask.setExpand()
// gtask.setLength();
gtask.setMilestone(milestone);
gtask.setName(task.getName() == null ? "-" : task.getName());
gtask.setNotes(task.getNotes());
Priority prio = task.getPriority();
if (prio != null) {
int priority = prio.getValue();
int p;
switch (priority) {
case Priority.HIGHEST:
case Priority.HIGHER:
case Priority.VERY_HIGH:
p = 2;
break;
case Priority.LOWEST:
case Priority.LOWER:
case Priority.VERY_LOW:
p = 0;
break;
default:
p = 1;
}
gtask.setPriority(p);
}
// gtask.setShape();
// gtask.setStartFixed()
// gtask.setTaskID()
gtask.setWebLink(task.getHyperlink());
Date taskStart = task.getStart();
assert taskStart!=null : "Task="+task+" has null start";
gtask.setStart(new GanttCalendar(taskStart));
// gtask.setDuration(tm.createLength((long) duration.getDuration()));
long longDuration = (long) Math.ceil(duration.convertUnits(TimeUnit.DAYS).getDuration());
if (longDuration > 0) {
gtask.setDuration(tm.createLength(longDuration));
}
else {
System.err.println("Task "+task.getName()+" has duration="+duration+" which is 0 as long integer. This duration has been ignored, task has got the default duration");