Set<Task> tasksToUpdate = new HashSet<Task>();
tasksToUpdate.add(task1ToUpdate);
tasksToUpdate.add(task2ToUpdate);
// charge to update
charge1ToUpdate = new ChargeImpl();
calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, 2005);
calendar.set(Calendar.MONTH, 11);
calendar.set(Calendar.DAY_OF_MONTH, 03);
userForChargeToUpdate = new UserImpl();
userForChargeToUpdate.setPersistanceId(2);
userForChargeToUpdate.setPersistanceVersion(1);
charge1ToUpdate.setPersistanceId(1);
charge1ToUpdate.setDay(calendar.getTime());
charge1ToUpdate.setTimeUsedToday(2);
charge1ToUpdate.setDaysNeededToFinish(4);
charge1ToUpdate.setUser(userForChargeToUpdate);
charge1ToUpdate.setPersistanceVersion(2);
charge2ToUpdate = new ChargeImpl();
calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, 2005);
calendar.set(Calendar.MONTH, 11);
calendar.set(Calendar.DAY_OF_MONTH, 04);
charge2ToUpdate.setPersistanceId(2);
charge2ToUpdate.setDay(calendar.getTime());
charge2ToUpdate.setTimeUsedToday(1);
charge2ToUpdate.setDaysNeededToFinish(2);
charge2ToUpdate.setUser(userForChargeToUpdate);
charge2ToUpdate.setPersistanceVersion(2);
Set<Charge> chargesToUpdate = new HashSet<Charge>();
chargesToUpdate.add(charge1ToUpdate);
chargesToUpdate.add(charge2ToUpdate);
// add the charges to task1
task1ToUpdate.setCharges(chargesToUpdate);
// Story to Update
storyToUpdate = new StoryImpl();
storyToUpdate.setProject(project);
storyToUpdate.setDescription("faire un report d'avancement des tâches");
storyToUpdate.setDaysEstimated(4);
storyToUpdate.setPersistanceId(1);
storyToUpdate.setPersistanceVersion(2);
storyToUpdate.setShortDescription("avancement des tâches");
storyToUpdate.setTasks(tasksToUpdate);
storyToUpdate.setBusinessValue(businessValue);
storyToUpdate.setRiskLevel(riskLevel);
// tasks to add
task1ToAdd = new TaskImpl();
task1ToAdd.setOwner(null);
task1ToAdd.setDaysEstimated(8);
task1ToAdd.setPersistanceId(0);
task1ToAdd.setPersistanceVersion(0);
task1ToAdd.setShortDescription("première tâche ajoutée");
task2ToAdd = new TaskImpl();
task2ToAdd.setOwner(null);
task2ToAdd.setDaysEstimated(9);
task2ToAdd.setPersistanceId(0);
task2ToAdd.setPersistanceVersion(0);
task2ToAdd.setShortDescription("seconde tâche ajoutée");
// Set of task
Set<Task> setToAdd = new HashSet<Task>();
setToAdd.add(task1ToAdd);
setToAdd.add(task2ToAdd);
// charge to add
charge1ToAdd = new ChargeImpl();
calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, 2005);
calendar.set(Calendar.MONTH, 6);
calendar.set(Calendar.DAY_OF_MONTH, 03);
userForChargeToAdd = new UserImpl();
userForChargeToAdd.setPersistanceId(1);
userForChargeToAdd.setPersistanceVersion(2);
charge1ToAdd.setPersistanceId(0);
charge1ToAdd.setDay(calendar.getTime());
charge1ToAdd.setTimeUsedToday(1);
charge1ToAdd.setDaysNeededToFinish(98);
charge1ToAdd.setUser(userForChargeToAdd);
charge1ToAdd.setPersistanceVersion(0);
charge2ToAdd = new ChargeImpl();
calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, 2005);
calendar.set(Calendar.MONTH, 6);