if (isPresent(form.getEntryId(i))) {
id = Integer.parseInt(form.getEntryId(i));
}
if (form.getDeleted(i) != null && form.getDeleted(i).equals("true")) {
TimeEntry entry = getEntry(timeEntries, id);
session.delete(entry);
rowDeleted = true;
continue;
}
Date startTime = null;
if (isPresent(form.getStartTime(i))) {
startTime = dateTimeFormat.parse(form.getStartTime(i));
}
Date endTime = null;
if (isPresent(form.getEndTime(i))) {
endTime = dateTimeFormat.parse(form.getEndTime(i));
}
int person1Id = 0;
if (isPresent(form.getPerson1Id(i))) {
person1Id = Integer.parseInt(form.getPerson1Id(i));
}
int person2Id = 0;
if (isPresent(form.getPerson2Id(i))) {
person2Id = Integer.parseInt(form.getPerson2Id(i));
}
double duration = 0;
if (isPresent(form.getDuration(i))) {
duration = decimalParser.parse(form.getDuration(i));
}
Date reportDate = null;
if (isPresent(form.getReportDate(i))) {
reportDate = dateFormat.parse(form.getReportDate(i));
}
if (id == 0) {
if (startTime != null || duration > 0) {
TimeEntry entry = new TimeEntry();
entry.setTaskId(Integer.parseInt(form.getOid()));
entry.setStartTime(startTime);
entry.setEndTime(endTime);
entry.setDuration(duration);
hoursWorked += entry.getEffort();
entry.setPerson1Id(person1Id);
entry.setPerson2Id(person2Id);
entry.setReportDate(reportDate);
session.save(entry);
}
} else {
TimeEntry entry = getEntry(timeEntries, id);
entry.setStartTime(startTime);
entry.setEndTime(endTime);
entry.setDuration(duration);
hoursWorked += entry.getEffort();
entry.setPerson1Id(person1Id);
entry.setPerson2Id(person2Id);
entry.setReportDate(reportDate);
}
}
Task task = (Task)session.load(Task.class, new Integer(form.getOid()));
//log.info("task estimate: "+task.getEstimatedHours()+", actual = "+hoursWorked);