Esempio n. 1
0
 public static Job createWorkingBranch_Create(
     final TeamWorkFlowArtifact teamArt, final IOseeBranch parentBranch, boolean pend)
     throws OseeCoreException {
   Conditions.checkNotNull(teamArt, "Parent Team Workflow");
   Conditions.checkNotNull(parentBranch, "Parent Branch");
   TransactionRecord parentTransactionId = TransactionManager.getHeadTransaction(parentBranch);
   return createWorkingBranch(teamArt, parentTransactionId, pend);
 }
  @Override
  protected void doWork(IProgressMonitor monitor) throws Exception {
    Branch startBranch = uiData.getTxDelta().getStartTx().getBranch();
    Branch otherBranch = branchProvider.getBranch(monitor);
    checkForCancelledStatus(monitor);

    Conditions.checkNotNull(otherBranch, "other branch to compare to");

    TransactionRecord startTx = TransactionManager.getHeadTransaction(startBranch);
    TransactionRecord endTx = TransactionManager.getHeadTransaction(otherBranch);
    TransactionDelta txDelta = new TransactionDelta(startTx, endTx);
    uiData.setTxDelta(txDelta);

    Branch mergeBranch = BranchManager.getMergeBranch(startBranch, otherBranch, true);
    uiData.setMergeBranch(mergeBranch);

    if (otherBranch.equals(startBranch.getParentBranch())) {
      uiData.setCompareType(CompareType.COMPARE_CURRENTS_AGAINST_PARENT);
    } else {
      uiData.setCompareType(CompareType.COMPARE_CURRENTS_AGAINST_OTHER_BRANCH);
    }
  }
  @Override
  public ArrayList<ChangeBuilder> acquireChanges() throws OseeCoreException {
    Map<Integer, ChangeBuilder> attributesWasValueCache = new HashMap<Integer, ChangeBuilder>();
    Map<Integer, ModificationType> artModTypes = new HashMap<Integer, ModificationType>();
    Set<Integer> modifiedArtifacts = new HashSet<Integer>();
    IOseeStatement chStmt = ConnectionHandler.getStatement();
    boolean hasBranch = getSourceBranch() != null;
    long time = System.currentTimeMillis();
    try {
      if (getMonitor() != null) {
        getMonitor().subTask("Gathering Attribute Changes");
      }
      TransactionRecord fromTransactionId;
      TransactionRecord toTransaction;
      boolean hasSpecificArtifact = getSpecificArtifact() != null;

      for (ChangeBuilder changeBuilder :
          getChangeBuilders()) { // cache in map for performance look ups
        artModTypes.put(changeBuilder.getArtId(), changeBuilder.getModType());
      }
      // Changes per a branch
      if (hasBranch) {
        fromTransactionId = getSourceBranch().getBaseTransaction();
        toTransaction = TransactionManager.getHeadTransaction(getSourceBranch());
        chStmt.runPreparedQuery(
            ClientSessionManager.getSql(OseeSql.CHANGE_BRANCH_ATTRIBUTE_IS),
            getSourceBranch().getId(),
            fromTransactionId.getId());

      } // Changes per transaction number
      else {
        toTransaction = getTransaction();
        if (hasSpecificArtifact) {
          chStmt.runPreparedQuery(
              ClientSessionManager.getSql(OseeSql.CHANGE_TX_ATTRIBUTE_IS_FOR_SPECIFIC_ARTIFACT),
              toTransaction.getBranchId(),
              toTransaction.getId(),
              getSpecificArtifact().getArtId());
          fromTransactionId = getTransaction();
        } else {
          chStmt.runPreparedQuery(
              ClientSessionManager.getSql(OseeSql.CHANGE_TX_ATTRIBUTE_IS),
              toTransaction.getBranchId(),
              toTransaction.getId());
          fromTransactionId = TransactionManager.getPriorTransaction(toTransaction);
        }
      }
      loadIsValues(
          getSourceBranch(),
          getArtIds(),
          getChangeBuilders(),
          getNewAndDeletedArtifactIds(),
          getMonitor(),
          attributesWasValueCache,
          artModTypes,
          modifiedArtifacts,
          chStmt,
          hasBranch,
          time,
          fromTransactionId,
          toTransaction,
          hasSpecificArtifact);
      loadAttributeWasValues(
          getSourceBranch(),
          getTransaction(),
          getArtIds(),
          getMonitor(),
          attributesWasValueCache,
          hasBranch);
    } finally {
      chStmt.close();
    }
    return getChangeBuilders();
  }