コード例 #1
0
  /*
   * Replaces all the participants in this action with their equivalent objects
   * in the current state. Calling this function solves the problem that happens
   * when you clone actions -- their hashtables point to participant objects
   * that were part of the previous, non-cloned state. Hence, this function
   * should be called after this object is cloned.
   */
  public void refetchParticipants(
      ArtifactStateRepository artifactRep,
      CustomerStateRepository customerRep,
      EmployeeStateRepository employeeRep,
      ProjectStateRepository projectRep,
      ToolStateRepository toolRep) {
    // proj participants:
    Hashtable<Project, Boolean> newProjs = new Hashtable<Project, Boolean>();
    Iterator<Map.Entry<Project, Boolean>> projsIterator = projs.entrySet().iterator();
    while (projsIterator.hasNext()) {
      Map.Entry<Project, Boolean> entry = projsIterator.next();
      Project oldProj = entry.getKey();
      if (oldProj instanceof TheProject) {
        Project newProj =
            projectRep.getTheProjectStateRepository().get(((TheProject) oldProj).getName());
        Boolean activeStatus = projs.get(oldProj);
        newProjs.put(newProj, activeStatus);
      }
    }
    projs.clear();
    projs.putAll(newProjs);

    // emp participants:
    Hashtable<Employee, Boolean> newEmps = new Hashtable<Employee, Boolean>();
    Iterator<Map.Entry<Employee, Boolean>> empsIterator = emps.entrySet().iterator();
    while (empsIterator.hasNext()) {
      Map.Entry<Employee, Boolean> entry = empsIterator.next();
      Employee oldEmp = entry.getKey();
      if (oldEmp instanceof SoftwareDeveloper) {
        Employee newEmp =
            employeeRep
                .getSoftwareDeveloperStateRepository()
                .get(((SoftwareDeveloper) oldEmp).getName());
        Boolean activeStatus = emps.get(oldEmp);
        newEmps.put(newEmp, activeStatus);
      }
    }
    emps.clear();
    emps.putAll(newEmps);
  }
コード例 #2
0
  /*
   * Replaces all the participants in this action with their equivalent objects
   * in the current state. Calling this function solves the problem that happens
   * when you clone actions -- their hashtables point to participant objects
   * that were part of the previous, non-cloned state. Hence, this function
   * should be called after this object is cloned.
   */
  public void refetchParticipants(
      ArtifactStateRepository artifactRep,
      CustomerStateRepository customerRep,
      EmployeeStateRepository employeeRep,
      ProjectStateRepository projectRep,
      ToolStateRepository toolRep) {
    // timothy participants:
    Hashtable<Employee, Boolean> newTimothys = new Hashtable<Employee, Boolean>();
    Iterator<Map.Entry<Employee, Boolean>> timothysIterator = timothys.entrySet().iterator();
    while (timothysIterator.hasNext()) {
      Map.Entry<Employee, Boolean> entry = timothysIterator.next();
      Employee oldTimothy = entry.getKey();
      if (oldTimothy instanceof SoftwareDeveloper) {
        Employee newTimothy =
            employeeRep
                .getSoftwareDeveloperStateRepository()
                .get(((SoftwareDeveloper) oldTimothy).getName());
        Boolean activeStatus = timothys.get(oldTimothy);
        newTimothys.put(newTimothy, activeStatus);
      }
    }
    timothys.clear();
    timothys.putAll(newTimothys);

    // reda participants:
    Hashtable<Employee, Boolean> newRedas = new Hashtable<Employee, Boolean>();
    Iterator<Map.Entry<Employee, Boolean>> redasIterator = redas.entrySet().iterator();
    while (redasIterator.hasNext()) {
      Map.Entry<Employee, Boolean> entry = redasIterator.next();
      Employee oldReda = entry.getKey();
      if (oldReda instanceof SoftwareDeveloper) {
        Employee newReda =
            employeeRep
                .getSoftwareDeveloperStateRepository()
                .get(((SoftwareDeveloper) oldReda).getName());
        Boolean activeStatus = redas.get(oldReda);
        newRedas.put(newReda, activeStatus);
      }
    }
    redas.clear();
    redas.putAll(newRedas);

    // code participants:
    Hashtable<Artifact, Boolean> newCodes = new Hashtable<Artifact, Boolean>();
    Iterator<Map.Entry<Artifact, Boolean>> codesIterator = codes.entrySet().iterator();
    while (codesIterator.hasNext()) {
      Map.Entry<Artifact, Boolean> entry = codesIterator.next();
      Artifact oldCode = entry.getKey();
      if (oldCode instanceof Code) {
        Artifact newCode =
            artifactRep.getCodeStateRepository().get(((Code) oldCode).getDescription());
        Boolean activeStatus = codes.get(oldCode);
        newCodes.put(newCode, activeStatus);
      }
    }
    codes.clear();
    codes.putAll(newCodes);

    // proj participants:
    Hashtable<Project, Boolean> newProjs = new Hashtable<Project, Boolean>();
    Iterator<Map.Entry<Project, Boolean>> projsIterator = projs.entrySet().iterator();
    while (projsIterator.hasNext()) {
      Map.Entry<Project, Boolean> entry = projsIterator.next();
      Project oldProj = entry.getKey();
      if (oldProj instanceof TheProject) {
        Project newProj =
            projectRep.getTheProjectStateRepository().get(((TheProject) oldProj).getName());
        Boolean activeStatus = projs.get(oldProj);
        newProjs.put(newProj, activeStatus);
      }
    }
    projs.clear();
    projs.putAll(newProjs);

    // associateduserstories participants:
    Hashtable<Artifact, Boolean> newAssociatedUserStoriess = new Hashtable<Artifact, Boolean>();
    Iterator<Map.Entry<Artifact, Boolean>> associateduserstoriessIterator =
        associateduserstoriess.entrySet().iterator();
    while (associateduserstoriessIterator.hasNext()) {
      Map.Entry<Artifact, Boolean> entry = associateduserstoriessIterator.next();
      Artifact oldAssociatedUserStories = entry.getKey();
      if (oldAssociatedUserStories instanceof UserStories) {
        Artifact newAssociatedUserStories =
            artifactRep
                .getUserStoriesStateRepository()
                .get(((UserStories) oldAssociatedUserStories).getName());
        Boolean activeStatus = associateduserstoriess.get(oldAssociatedUserStories);
        newAssociatedUserStoriess.put(newAssociatedUserStories, activeStatus);
      }
    }
    associateduserstoriess.clear();
    associateduserstoriess.putAll(newAssociatedUserStoriess);

    // releaseplan participants:
    Hashtable<Artifact, Boolean> newReleasePlans = new Hashtable<Artifact, Boolean>();
    Iterator<Map.Entry<Artifact, Boolean>> releaseplansIterator =
        releaseplans.entrySet().iterator();
    while (releaseplansIterator.hasNext()) {
      Map.Entry<Artifact, Boolean> entry = releaseplansIterator.next();
      Artifact oldReleasePlan = entry.getKey();
      if (oldReleasePlan instanceof ReleasePlan) {
        Artifact newReleasePlan =
            artifactRep
                .getReleasePlanStateRepository()
                .get(((ReleasePlan) oldReleasePlan).getName());
        Boolean activeStatus = releaseplans.get(oldReleasePlan);
        newReleasePlans.put(newReleasePlan, activeStatus);
      }
    }
    releaseplans.clear();
    releaseplans.putAll(newReleasePlans);
  }