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();
 }
Пример #2
0
  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;
  }