Пример #1
0
  private void doPortWork(
      TeamWorkFlowArtifact sourceWorkflow, TeamWorkFlowArtifact destinationWorkflow)
      throws OseeCoreException {
    if (destinationWorkflow.getWorkingBranchForceCacheUpdate() == null) {
      AtsBranchUtil.createWorkingBranch_Create(destinationWorkflow, true);
    }

    Branch destinationBranch = destinationWorkflow.getWorkingBranchForceCacheUpdate();
    Branch portBranch = getPortBranchFromWorkflow(sourceWorkflow, destinationWorkflow);
    if (portBranch == null) {
      logf(
          "Source workflow [%s] not ready for port to Workflow [%s].",
          sourceWorkflow, destinationWorkflow);
      return;
    }

    try {
      if (portBranch.getBranchState().isCommitted()) {
        logf("Skipping completed workflow [%s].", destinationWorkflow);
      } else {
        ConflictManagerExternal conflictManager =
            new ConflictManagerExternal(destinationBranch, portBranch);
        BranchManager.commitBranch(null, conflictManager, false, false);
        logf("Commit complete for workflow [%s].", destinationWorkflow);
      }
    } catch (OseeCoreException ex) {
      logf("Resolve conflicts for workflow [%s].", destinationWorkflow);
    }
  }
  @Override
  public Object executeWithException(ExecutionEvent event, IStructuredSelection selection)
      throws OseeCoreException {
    Branch selectedBranch =
        Handlers.getBranchesFromStructuredSelection(selection).iterator().next();

    EntryDialog ed =
        new EntryDialog(
            "Set Associated Artifact",
            "Set Associated Artifact for Branch\n\n\""
                + selectedBranch.getName()
                + "\""
                + (selectedBranch.getAssociatedArtifactId() != null
                    ? "\n\nCurrently: " + selectedBranch.getAssociatedArtifactId()
                    : "")
                + "\n\nEnter new Artifact Id to associate:");
    ed.setEntry(String.valueOf(selectedBranch.getAssociatedArtifactId()));
    if (ed.open() == 0) {
      String artId = ed.getEntry();
      Artifact associatedArtifact =
          ArtifactQuery.getArtifactFromId(Integer.parseInt(artId), BranchManager.getCommonBranch());
      if (MessageDialog.openConfirm(
          Displays.getActiveShell(),
          "Set Associated Artifact",
          "Set Associated Artifact for Branch\n\n\""
              + selectedBranch.getName()
              + "\"\nto\nArtifact: "
              + associatedArtifact)) {
        selectedBranch.setAssociatedArtifactId(Integer.parseInt(artId));
        BranchManager.persist(selectedBranch);
      }
    }

    return null;
  }
  @Override
  protected ReadableBranch innerCall() throws Exception {
    Conditions.checkNotNull(branchToken, "branch");
    Conditions.checkNotNull(branchType, "branchType");

    Branch branch = cache.get(branchToken);
    Conditions.checkNotNull(branch, "branch");

    BranchType original = branch.getBranchType();

    try {
      branch.setBranchType(branchType);
      cache.storeItems(branch);
    } catch (Exception ex) {
      branch.setBranchType(original);
      throw ex;
    } finally {
      // TODO Event ?
    }
    return branch;
  }
  @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);
    }
  }
Пример #5
0
  public static boolean handleCommitInProgressPostPrompt(
      final ConflictManagerExternal conflictManager, int userOption, boolean skipPrompts)
      throws OseeCoreException {
    boolean toReturn = false;
    Branch sourceBranch = conflictManager.getSourceBranch();
    Branch destinationBranch = conflictManager.getDestinationBranch();

    if (userOption == COMMIT) { // Commit
      BranchManager.commitBranch(null, conflictManager, archiveBranch, false);
      toReturn = true;
    } else if (userOption == LAUNCH_MERGE_VIEW) { // Launch Merge
      MergeView.openView(sourceBranch, destinationBranch, sourceBranch.getBaseTransaction());
    } else if (userOption == DELETE_MERGE) { // Delete Merge
      deleteSingleMergeBranches(sourceBranch, destinationBranch, skipPrompts);
    } else if (userOption == FORCE_COMMIT) { // Force Commit, admin only
      BranchManager.commitBranch(null, conflictManager, archiveBranch, true);
      toReturn = true;
    } else if (userOption == CANCEL) {
      // do nothing
    }
    return toReturn;
  }
Пример #6
0
 public static Image getImage(Branch branch) {
   Image image = null;
   BranchType branchType = branch.getBranchType();
   switch (branchType) {
     case SYSTEM_ROOT:
       image = ImageManager.getImage(FrameworkImage.BRANCH_SYSTEM_ROOT);
       break;
     case BASELINE:
       image = ImageManager.getImage(FrameworkImage.BRANCH_BASELINE);
       break;
     case WORKING:
       image = ImageManager.getImage(FrameworkImage.BRANCH_WORKING);
       break;
     case MERGE:
       image = ImageManager.getImage(FrameworkImage.BRANCH_MERGE);
       break;
   }
   return image;
 }
  public Collection<Branch> updateCache(
      AbstractBranchCacheMessage cacheMessage, IOseeCache<String, Branch> cache)
      throws OseeCoreException {
    List<Branch> updatedItems = new ArrayList<Branch>();

    Map<Integer, Integer> branchToAssocArt = cacheMessage.getBranchToAssocArt();

    preLoadTransactions(cacheMessage);

    for (BranchRow srcItem : cacheMessage.getBranchRows()) {
      int branchId = srcItem.getBranchId();
      Branch updated =
          factory.createOrUpdate(
              cache,
              srcItem.getBranchId(),
              srcItem.getStorageState(),
              srcItem.getBranchGuid(),
              srcItem.getBranchName(),
              srcItem.getBranchType(),
              srcItem.getBranchState(),
              srcItem.getBranchArchived().isArchived());
      updatedItems.add(updated);

      Integer artifactId = branchToAssocArt.get(branchId);
      if (artifactId != null) {
        updated.setAssociatedArtifactId(artifactId);
      }

      updated.setBaseTransaction(getTx(cacheMessage.getBranchToBaseTx(), branchId));
      updated.setSourceTransaction(getTx(cacheMessage.getBranchToSourceTx(), branchId));
    }

    for (Entry<Integer, Integer> entry : cacheMessage.getChildToParent().entrySet()) {
      Branch parent = cache.getById(entry.getValue());
      if (parent != null) {
        Branch child = cache.getById(entry.getKey());
        if (child != null) {
          child.setParentBranch(parent);
        }
      }
    }
    for (Triplet<String, String, String> entry : cacheMessage.getMergeBranches()) {
      IOseeBranch sourceBranch =
          Strings.isValid(entry.getFirst()) ? cache.getByGuid(entry.getFirst()) : null;
      IOseeBranch destinationBranch =
          Strings.isValid(entry.getSecond()) ? cache.getByGuid(entry.getSecond()) : null;

      Branch branch = cache.getByGuid(entry.getThird());
      MergeBranch mergeBranch = null;
      try {
        mergeBranch = (MergeBranch) branch;
        mergeBranch.setSourceBranch(sourceBranch);
        mergeBranch.setDestinationBranch(destinationBranch);
      } catch (ClassCastException ex) {
        throw new OseeCoreException(
            ex,
            "Problem casting branch [%s] to MergeBranch, source: [%s], dest: [%s]",
            branch,
            sourceBranch,
            destinationBranch);
      }
    }
    return updatedItems;
  }
 public static void loadFromCache(AbstractBranchCacheMessage message, Collection<Branch> types)
     throws OseeCoreException {
   for (Branch br : types) {
     Integer branchId = br.getId();
     message
         .getBranchRows()
         .add(
             new BranchRow(
                 br.getId(),
                 br.getGuid(),
                 br.getName(),
                 br.getBranchType(),
                 br.getBranchState(),
                 br.getArchiveState(),
                 br.getStorageState()));
     if (br.hasParentBranch()) {
       message.getChildToParent().put(branchId, br.getParentBranch().getId());
     }
     addTxRecord(message.getBranchToBaseTx(), branchId, br.getBaseTransaction());
     addTxRecord(message.getBranchToSourceTx(), branchId, br.getSourceTransaction());
     addAssocArtifact(message.getBranchToAssocArt(), branchId, br.getAssociatedArtifactId());
     if (br.getBranchType().isMergeBranch()) {
       addMergeBranches(message.getMergeBranches(), (MergeBranch) br);
     }
   }
 }
  private void loadAttributeWasValues(
      Branch sourceBranch,
      TransactionRecord transactionId,
      Set<Integer> artIds,
      IProgressMonitor monitor,
      Map<Integer, ChangeBuilder> attributesWasValueCache,
      boolean hasBranch)
      throws OseeCoreException, OseeDataStoreException {
    if (!artIds.isEmpty()) {
      int sqlParamter; // Will either be a branch id or transaction id
      Branch wasValueBranch;
      String sql;

      if (hasBranch) {
        wasValueBranch = sourceBranch;
        sql = ClientSessionManager.getSql(OseeSql.CHANGE_BRANCH_ATTRIBUTE_WAS);
        sqlParamter = wasValueBranch.getId();
      } else {
        wasValueBranch = transactionId.getBranch();
        sql = ClientSessionManager.getSql(OseeSql.CHANGE_TX_ATTRIBUTE_WAS);
        sqlParamter = transactionId.getId();
      }

      int queryId = ArtifactLoader.getNewQueryId();
      Timestamp insertTime = GlobalTime.GreenwichMeanTimestamp();
      List<Object[]> datas = new LinkedList<Object[]>();
      IOseeStatement chStmt = ConnectionHandler.getStatement();

      try {
        // insert into the artifact_join_table
        for (int artId : artIds) {
          datas.add(
              new Object[] {
                queryId, insertTime, artId, wasValueBranch.getId(), SQL3DataType.INTEGER
              });
        }
        ArtifactLoader.insertIntoArtifactJoin(datas);
        chStmt.runPreparedQuery(sql, sqlParamter, queryId);
        int previousAttrId = -1;

        while (chStmt.next()) {
          int attrId = chStmt.getInt("attr_id");

          if (previousAttrId != attrId) {
            String wasValue = chStmt.getString("was_value");
            if (attributesWasValueCache.containsKey(attrId)
                && attributesWasValueCache.get(attrId) instanceof AttributeChangeBuilder) {
              AttributeChangeBuilder changeBuilder =
                  (AttributeChangeBuilder) attributesWasValueCache.get(attrId);

              if (changeBuilder.getArtModType() != ModificationType.NEW) {
                if (changeBuilder.getModType() != ModificationType.DELETED
                    && changeBuilder.getModType() != ModificationType.ARTIFACT_DELETED) {
                  changeBuilder.setModType(ModificationType.MODIFIED);
                }
                changeBuilder.setWasValue(wasValue);
              }
            }
            previousAttrId = attrId;
          }
        }
      } finally {
        ArtifactLoader.clearQuery(queryId);
        chStmt.close();
      }
      if (getMonitor() != null) {
        monitor.worked(12);
      }
    }
  }
Пример #10
0
 @Override
 String getColumnText(Branch branch) {
   return String.valueOf(branch.getUuid());
 }