startDate.setDate(7);
startDate.setHours(11);
startDate.setMinutes(0);
startDate.setSeconds(0);
BOTask task1 = new BOTask();
task1.setTaskID(1);
task1.setTaskName("task1");
Date task1StartDate = (Date) startDate.clone();
task1StartDate.setDate(7);
task1StartDate.setHours(11);
task1StartDate.setMinutes(0);
task1StartDate.setSeconds(0);
task1.setStartDate(task1StartDate);
task1.setDurationInDays(1);
Date task1EndDate = DateRange.calculateEndDate(task1StartDate, 1);
task1.setEndDate(task1EndDate);
BOTask task2 = new BOTask();
task2.setTaskID(2);
task2.setTaskName("task2");
Date task2StartDate = DateRange.getStartDateForTheSuccessor(task1.getEndDate(), 1);
task2.setStartDate(task2StartDate);
task2.setDurationInDays(1);
Date task2EndDate = DateRange.calculateEndDate(task2StartDate, 1);
task2.setEndDate(task2EndDate);
BOTask task3 = new BOTask();
task3.setTaskID(3);
task3.setTaskName("task3");
task3.setStartDate(task1.getStartDate());
task3.setDurationInDays(task1.getDurationInDays()+task2.getDurationInDays());
task3.setEndDate(task2.getEndDate());
BOTask task4 = new BOTask();
task4.setTaskID(4);
task4.setTaskName("task4");
Date task4StartDate = DateRange.getStartDateForTheSuccessor(task1.getEndDate(), 1);
task4StartDate.setDate(7);
task4StartDate.setHours(11);
task4StartDate.setMinutes(0);
task4StartDate.setSeconds(0);
task4.setStartDate(task4StartDate);
task4.setDurationInDays(1);
Date task4EndDate = DateRange.calculateEndDate(task4StartDate, 1);
task4.setEndDate(task4EndDate);
BOTask task5 = new BOTask();
task5.setTaskID(5);
task5.setTaskName("task5");
Date task5StartDate = DateRange.getStartDateForTheSuccessor(task5.getEndDate(), 1);
task5.setStartDate(task5StartDate);
task5.setDurationInDays(1);
Date task5EndDate = DateRange.calculateEndDate(task5StartDate, 1);
task5.setEndDate(task5EndDate);
BOTask task6 = new BOTask();
task6.setTaskID(6);
task6.setTaskName("task6");
task6.setStartDate(task6.getStartDate());
task6.setDurationInDays(task4.getDurationInDays()+task5.getDurationInDays());
task6.setEndDate(task6.getEndDate());
// parent child
task1.setParentTask(task3);
task2.setParentTask(task3);
LinkedHashSet<BOTask> task3Kids = new LinkedHashSet<BOTask>();
task3Kids.add(task1);
task3Kids.add(task2);
task3.setChildTasks(task3Kids);
task4.setParentTask(task6);
task5.setParentTask(task6);
LinkedHashSet<BOTask> task6Kids = new LinkedHashSet<BOTask>();
task6Kids.add(task4);
task6Kids.add(task5);
task6.setChildTasks(task6Kids);
//Successors and predecessors
LinkedHashSet<BOTask> task2Pre = new LinkedHashSet<BOTask>();
task2Pre.add(task1);
task2.setPreviousTasks(task2Pre);
LinkedHashSet<BOTask> task1Suc = new LinkedHashSet<BOTask>();
task1Suc.add(task2);
task1Suc.add(task4);
task1Suc.add(task5);
task1.setDependentTasks(task1Suc);
LinkedHashSet<BOTask> task4Pre = new LinkedHashSet<BOTask>();
task4Pre.add(task1);
task4.setPreviousTasks(task4Pre);
LinkedHashSet<BOTask> task5Pre = new LinkedHashSet<BOTask>();
task5Pre.add(task4);
task5Pre.add(task1);
task5.setPreviousTasks(task5Pre);
LinkedHashSet<BOTask> task4Suc = new LinkedHashSet<BOTask>();
task4Suc.add(task5);
task4.setDependentTasks(task4Suc);
startDate.setDate(8);
System.out.println(Thread.currentThread().getName() + "B4 Modify");
System.out.println(Thread.currentThread().getName() + task1.toString());
System.out.println(Thread.currentThread().getName() + task2.toString());
System.out.println(Thread.currentThread().getName() + task3.toString());
System.out.println(Thread.currentThread().getName() + task4.toString());
System.out.println(Thread.currentThread().getName() + task5.toString());
System.out.println(Thread.currentThread().getName() + task6.toString());
startDate.setDate(9);
task1.setStartDate(startDate);
modifyTask(task1);
System.out.println(Thread.currentThread().getName() + "After Modify");
System.out.println(Thread.currentThread().getName() + task1.toString());
System.out.println(Thread.currentThread().getName() + task2.toString());
System.out.println(Thread.currentThread().getName() + task3.toString());
System.out.println(Thread.currentThread().getName() + task4.toString());
System.out.println(Thread.currentThread().getName() + task5.toString());
System.out.println(Thread.currentThread().getName() + task6.toString());
}