*/
private TaskElement createTask(OrderElementDTO task, boolean importCalendar) {
OrderElement orderElement = task.orderElement;
TaskElement taskElement;
TaskSource taskSource;
if (task.children.size() == 0) {
taskSource = TaskSource.create(
orderElement.getCurrentSchedulingDataForVersion(),
orderElement.getHoursGroups());
taskElement = taskSource
.createTaskWithoutDatesInitializedAndLinkItToTaskSource();
if (importCalendar && task.calendarName != null) {
taskElement.setCalendar(findBaseCalendar(task.calendarName));
}
setPositionConstraint((Task) taskElement, task);
} else {
taskSource = TaskSource.createForGroup(orderElement
.getCurrentSchedulingDataForVersion());
taskElement = taskSource
.createTaskGroupWithoutDatesInitializedAndLinkItToTaskSource();
List<TaskElement> taskElements = new ArrayList<TaskElement>();
for (OrderElementDTO importTask : task.children) {
taskElements.add(createTask(importTask, importCalendar));
}
for (MilestoneDTO milestone : task.milestones) {
taskElements.add(createTaskMilestone(milestone));
}
for (TaskElement childTaskElement : taskElements) {
((TaskGroup) taskElement).addTaskElement(childTaskElement);
}
}
taskElement.setStartDate(task.startDate);
taskElement.setEndDate(task.endDate);
task.taskElement = taskElement;
return taskElement;
}