예제 #1
0
 /**
  * Copy Phases from Type
  *
  * @param type Project Type
  * @return count
  */
 public int copyPhasesFrom(MProjectType type) {
   //	create phases
   int count = 0;
   int taskCount = 0;
   MProjectTypePhase[] typePhases = type.getPhases();
   for (int i = 0; i < typePhases.length; i++) {
     MProjectPhase toPhase = new MProjectPhase(this, typePhases[i]);
     if (toPhase.save()) {
       count++;
       taskCount += toPhase.copyTasksFrom(typePhases[i]);
     }
   }
   log.fine("#" + count + "/" + taskCount + " - " + type);
   if (typePhases.length != count)
     log.log(Level.SEVERE, "Count difference - Type=" + typePhases.length + " <> Saved=" + count);
   return count;
 } //	copyPhasesFrom
예제 #2
0
  /**
   * Copy Phases/Tasks from other Project
   *
   * @param fromProject project
   * @return number of items copied
   */
  public int copyPhasesFrom(MProject fromProject) {
    if (isProcessed() || fromProject == null) return 0;
    int count = 0;
    int taskCount = 0;
    //	Get Phases
    MProjectPhase[] myPhases = getPhases();
    MProjectPhase[] fromPhases = fromProject.getPhases();
    //	Copy Phases
    for (int i = 0; i < fromPhases.length; i++) {
      //	Check if Phase already exists
      int C_Phase_ID = fromPhases[i].getC_Phase_ID();
      boolean exists = false;
      if (C_Phase_ID == 0) exists = false;
      else {
        for (int ii = 0; ii < myPhases.length; ii++) {
          if (myPhases[ii].getC_Phase_ID() == C_Phase_ID) {
            exists = true;
            break;
          }
        }
      }
      //	Phase exist
      if (exists) log.info("Phase already exists here, ignored - " + fromPhases[i]);
      else {
        MProjectPhase toPhase = new MProjectPhase(getCtx(), 0, get_TrxName());
        PO.copyValues(fromPhases[i], toPhase, getAD_Client_ID(), getAD_Org_ID());
        toPhase.setC_Project_ID(getC_Project_ID());
        toPhase.setC_Order_ID(0);
        toPhase.setIsComplete(false);
        if (toPhase.save()) {
          count++;
          taskCount += toPhase.copyTasksFrom(fromPhases[i]);
        }
      }
    }
    if (fromPhases.length != count)
      log.warning("Count difference - Project=" + fromPhases.length + " <> Saved=" + count);

    return count + taskCount;
  } //	copyPhasesFrom