private void updateDTOs() throws ValidationException, IllegalStateException {
// Create a new list of Criterion satisfaction
Set<CriterionSatisfaction> newList = new HashSet<CriterionSatisfaction>();
for (CriterionSatisfactionDTO satisfactionDTO : getWithCriterionAssignedDTOs()) {
CriterionSatisfaction satisfaction;
if (satisfactionDTO.isNewObject()) {
Criterion criterion = satisfactionDTO.getCriterionWithItsType()
.getCriterion();
Interval interval = satisfactionDTO.getInterval();
satisfaction = CriterionSatisfaction.create(criterion, worker,
interval);
// set the autogenerated code
currentCriterionSatisfaction = satisfaction;
setDefaultCode();
} else {
satisfaction = satisfactionDTO.getCriterionSatisfaction();
if (satisfactionDTO.isIsDeleted()) {
satisfaction.setIsDeleted(true);
} else {
satisfaction.setStartDate(satisfactionDTO.getStart());
if (satisfactionDTO.getEndDate() != null) {
satisfaction.finish(satisfactionDTO.getEnd());
} else {
satisfaction.noFinish();
}
}
}
newList.add(satisfaction);
}