// Set submitter and approver associations
timecard.setSubmitter(getPersonDao().findByUsername(timecardVO.getSubmitterName()));
timecard.setApprover(getPersonDao().findByUsername(timecardVO.getApproverName()));
// Set allocations
TimeAllocationVO allocations[] = timecardVO.getAllocations();
for (int i=0; i<allocations.length; i++) {
// Create TimeAllocation from TimeAllocationVO
TimeAllocationVO allocationVO = allocations[i];
TimeAllocation allocation = TimeAllocation.Factory.newInstance();
getTimeAllocationDao().timeAllocationVOToEntity(allocationVO, allocation, true);
// Connect to timecard
timecard.addTimeAllocation(allocation);
// Connect to task
allocation.setTask(getTaskDao().load(allocationVO.getTaskId()));
}
// Create the timecard
getTimecardDao().create(timecard);
return timecard.getId();