Esempio n. 1
0
  private Branch getPortBranchFromWorkflow(
      TeamWorkFlowArtifact sourceWorkflow, TeamWorkFlowArtifact destinationWorkflow)
      throws OseeCoreException {
    if (!sourceWorkflow.isRelated(AtsRelationTypes.Port_To, destinationWorkflow)) {
      sourceWorkflow.addRelation(AtsRelationTypes.Port_To, destinationWorkflow);
      sourceWorkflow.persist("create port relation");
    }

    Collection<Branch> branches =
        BranchManager.getBranchesByName(
            String.format("Porting [%s] branch", sourceWorkflow.getAtsId()));

    if (branches.isEmpty()) {
      TransactionRecord transRecord =
          (TransactionRecord)
              AtsClientService.get().getBranchService().getEarliestTransactionId(sourceWorkflow);
      if (transRecord == null) {
        return null;
      } else {
        return BranchManager.createWorkingBranchFromTx(
            transRecord, String.format("Porting [%s] branch", sourceWorkflow.getAtsId()), null);
      }
    } else {
      return branches.iterator().next();
    }
  }