if (assignments.size()>0)
for (Iterator j=assignments.iterator();j.hasNext();){
Object obj=j.next();
AssignmentData assignmentData=null;
Assignment assignment=null;
Resource resource;
boolean assigned=true;
int s;
// if (loadResources!=null&&obj instanceof PersistedAssignment){ //claur
// PersistedAssignment pa=(PersistedAssignment)obj;
// assignment=pa.getAssignment();
// s=pa.getSnapshot();
//
// long resId=pa.getResourceId();
// Node node=(Node)resourceNodeMap.get(resId);
// resource=node==null?ResourceImpl.getUnassignedInstance():(Resource)node.getImpl();
//
// if (resource==null) assigned=false;
// }else{
assignmentData=(AssignmentData)obj;
if (loadResources==null){
EnterpriseResourceData r=assignmentData.getResource();
if (r==null) assigned=false;
resource=(r==null)?ResourceImpl.getUnassignedInstance():(Resource)((Node)resourceNodeMap.get(r)).getImpl();
}else{
long resId=assignmentData.getResourceId();
Node node=(Node)resourceNodeMap.get(resId);
resource=node==null?ResourceImpl.getUnassignedInstance():(Resource)node.getImpl();
}
if (assignmentData.getSerialized() != null){
try {
assignment=(Assignment)deserialize(assignmentData,reindex);
} catch (Exception e) {
e.printStackTrace();
}
}
if (assignmentData.getSerialized() == null||(assignmentData.getSerialized() != null&&assignment==null)) { // timesheet created
assignment = Assignment.getInstance(task,resource, 1.0, 0);
if (assignment.getCachedStart() == null) { //doesn't occur filtered above
System.out.println("==== no cached start found " + task.getName());
} else {
task.setActualStart(assignment.getCachedStart().getTime());
task.setActualFinish(assignment.getCachedEnd().getTime());
}
}
assignment.setCachedStart(assignmentData.getCachedStart());
assignment.setCachedEnd(assignmentData.getCachedEnd());
assignment.setTimesheetStatus(assignmentData.getTimesheetStatus());
long lastUpdate = (assignmentData.getLastTimesheetUpdate() == null) ? 0 : assignmentData.getLastTimesheetUpdate().getTime();
assignment.setLastTimesheetUpdate(lastUpdate);
assignment.setWorkflowState(assignmentData.getWorkflowState());
s=assignmentData.getSnapshotId();
// }
assignment.getDetail().setTask(task);
assignment.getDetail().setResource(resource);
Object snapshotId=new Integer(s);
TaskSnapshot snapshot=(TaskSnapshot)task.getSnapshot(snapshotId);
//TODO was commented but needed for loading because task.getSnapshot(snapshotId)==null
//for snapshots other than CURRENT
if (snapshot==null){
snapshot=new TaskSnapshot();
snapshot.setCurrentSchedule(task.getCurrentSchedule());
task.setSnapshot(snapshotId,snapshot);
}
if (Snapshottable.TIMESHEET.equals(snapshotId)) {
assignment.setTimesheetAssignment(true);
}
//
snapshot.addAssignment(assignment);