protected void renumberProject() throws Exception {
    Session session = SessionFactory.getInstance().getSession(false);
    // renumber tasks
    Map<Long, Long> idMap = new HashMap<Long, Long>();
    for (TaskData task : (Collection<TaskData>) projectData.getTasks()) {
      long oldUniqueId = task.getUniqueId();
      long uniqueId = session.getId();
      task.setUniqueId(uniqueId);
      idMap.put(oldUniqueId, uniqueId);
      if (task.getAssignments() != null)
        for (AssignmentData assignment : (Collection<AssignmentData>) task.getAssignments()) {
          assignment.setTaskId(uniqueId);
        }
    }

    Collection<DistributionData> dists =
        (Collection<DistributionData>) projectData.getDistributions();
    if (dists != null)
      for (Iterator<DistributionData> i = dists.iterator(); i.hasNext(); ) {
        DistributionData dist = i.next();
        dist.setTaskId(idMap.get(dist.getTaskId()));
      }

    // renumber project
    projectData.setUniqueId(session.getId());
  }
  protected boolean importResources() throws Exception {
    ResourceMappingForm form = getResourceMapping();

    if (form != null && !form.isLocal()) {
      //			if (Environment.isNoPodServer()){ //claur
      //				//importLocalResources.execute(null);
      //				Project existingProject=form.getExistingProject();
      //				existingProject.setMaster(true);
      //				retrieveResourcesForMerge(existingProject);
      //			}

      if (!form.execute()) return false;
      if (form.isLocal()) {
        return true;
      }

      List<ResourceData> resources = new ArrayList<ResourceData>();
      Map<Long, ResourceData> resourceMap = new HashMap<Long, ResourceData>();

      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
    //			Project existingProject=form.getExistingProject();
    //			projectData.setUniqueId(existingProject.getUniqueId()); //should be elsewhere, but it's
    // easiest here in the import job
    //		}

    return true;
  }