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); } }
private void makeChanges7(TeamWorkFlowArtifact teamArt) throws OseeCoreException { SkynetTransaction transaction = TransactionManager.createTransaction(AtsUtil.getAtsBranch(), "Remote Event Test"); TransitionHelper helper = new TransitionHelper( "Remote Event Test", Arrays.asList(teamArt), TeamState.Analyze.getName(), Collections.singleton(AtsClientService.get().getUserAdmin().getCurrentUser()), null, TransitionOption.None); TransitionManager transitionMgr = new TransitionManager(helper, transaction); TransitionResults results = transitionMgr.handleAll(); if (!results.isEmpty()) { throw new OseeStateException(results.toString()); } transaction.execute(); }
public static Result moveTasks(TeamWorkFlowArtifact newParent, List<TaskArtifact> taskArts) throws OseeCoreException { for (TaskArtifact taskArt : taskArts) { // task dropped on same awa as current parent; do nothing if (taskArt.getParentAWA().equals(newParent)) { return Result.FalseResult; } // Validate able to move tasks; WorkDefinitions must match boolean taskOverridesItsWorkDefinition = AtsClientService.get() .getWorkDefinitionAdmin() .isTaskOverridingItsWorkDefinition(taskArt); IWorkDefinitionMatch match = AtsClientService.get() .getWorkDefinitionAdmin() .getWorkDefinitionForTaskNotYetCreated(newParent); if (!taskOverridesItsWorkDefinition && !taskArt.getWorkDefinition().equals(match.getWorkDefinition())) { return new Result( "Desitination Task WorkDefinition does not match current Task WorkDefintion; Move Aborted"); } } // Move Tasks SkynetTransaction transaction = TransactionManager.createTransaction(AtsUtilCore.getAtsBranch(), "Drop Add Tasks"); for (Artifact art : taskArts) { if (art.isOfType(AtsArtifactTypes.Task)) { TaskArtifact taskArt = (TaskArtifact) art; taskArt.clearCaches(); if (taskArt.getParentAWA() != null) { taskArt.deleteRelation(AtsRelationTypes.TeamWfToTask_TeamWf, taskArt.getParentAWA()); } taskArt.addRelation(AtsRelationTypes.TeamWfToTask_TeamWf, newParent); taskArt.persist(transaction); taskArt.clearCaches(); } } transaction.execute(); return Result.TrueResult; }
@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(); }