Iterator r = form.getResources().iterator();
while(r.hasNext()){
EnterpriseResourceData enterpriseResource=(EnterpriseResourceData)r.next();
if (enterpriseResource.getUniqueId()!=EnterpriseResource.UNASSIGNED_ID){
ResourceData resource=new ResourceData();
resource.setEnterpriseResource(enterpriseResource);
resourceMap.put(enterpriseResource.getUniqueId(), resource);
resources.add(resource);
}
}
projectData.setResources(resources);
Map<Long,ResourceData> idMap=new HashMap<Long,ResourceData>();
Iterator ir = form.getImportedResources().iterator();
Iterator sr = form.getSelectedResources().iterator();
while(ir.hasNext()){
EnterpriseResourceData enterpriseSrc=(EnterpriseResourceData)ir.next();
EnterpriseResourceData enterpriseDest=(EnterpriseResourceData)sr.next();
if (enterpriseDest.getUniqueId()!=EnterpriseResource.UNASSIGNED_ID){
ResourceData resource=new ResourceData();
resource.setEnterpriseResource(enterpriseDest);
idMap.put(enterpriseSrc.getUniqueId(),resourceMap.get(enterpriseDest.getUniqueId()));
}
}
//remove assignments that have lost resources
for (TaskData task:(Collection<TaskData>)projectData.getTasks()){
if (task.getAssignments()!=null)
for (AssignmentData assignment:(Collection<AssignmentData>)task.getAssignments()){
ResourceData resourceData=idMap.get(assignment.getUniqueId());
if (resourceData==null){
//assignment becomes unassigned
assignment.setResource(null);
assignment.setResourceId(-1L);
}else{
assignment.setResource(resourceData.getEnterpriseResource());
assignment.setResourceId(resourceData.getEnterpriseResource().getUniqueId());
}
}
}
//remove distributions that have lost resources
Collection<DistributionData> dists=(Collection<DistributionData>)projectData.getDistributions();
if (dists!=null)
for (Iterator<DistributionData> i=dists.iterator();i.hasNext();){
DistributionData dist=i.next();
ResourceData resourceData=idMap.get(dist.getResourceId());
if (resourceData==null){
i.remove();
}else{
dist.setResourceId(resourceData.getEnterpriseResource().getUniqueId());
}
}
}
// if (Environment.isNoPodServer()){ //claur