Creates new create methods for Task and TaskGroup

TaskSource has two new methods. One method for create a Task and other for create a TaskGroup
assinging them to the TaskSource.
Task has one new method to create a task without initialize its dates.

FEA: ItEr77S05BasicProjectImport
This commit is contained in:
Alba Carro 2012-08-29 17:51:24 +02:00 committed by Manuel Rego Casasnovas
parent 317759cd63
commit 184f27d0c0
2 changed files with 41 additions and 0 deletions

View file

@ -52,6 +52,29 @@ public class TaskSource extends BaseEntity {
return result;
}
/**
* Needed for import external tasks.
*
* @return Task New Task
*/
public Task createTaskWithoutDatesInitializedAndLinkItToTaskSource() {
TaskElement task = Task.createTaskWithoutDatesInitialized(this);
this.setTask(task);
return (Task) task;
}
/**
* Needed for import external tasks.
*
* @return Task New Task
*/
public TaskGroup createTaskGroupWithoutDatesInitializedAndLinkItToTaskSource() {
TaskElement task = TaskGroup.create(this);
this.setTask(task);
return (TaskGroup) task;
}
public static TaskSourceSynchronization mustAdd(
TaskSource taskSource) {
return new TaskSourceMustBeAdded(taskSource);

View file

@ -96,6 +96,24 @@ public class Task extends TaskElement implements ITaskPositionConstrained {
return result;
}
/**
* Needed for import external tasks.
*
* Creates a Task without initializing the dates.
*
* @param taskSource
* TaskSouce for create the task
*
* @return Task New Task
*/
public static Task createTaskWithoutDatesInitialized(TaskSource taskSource) {
Task task = new Task();
OrderElement orderElement = taskSource.getOrderElement();
orderElement.applyInitialPositionConstraintTo(task);
Task result = create(task, taskSource);
return result;
}
@Override
protected void initializeDates() {
EffortDuration workHours = EffortDuration.hours(getWorkHours());