コード例 #1
0
ファイル: AtsTaskService.java プロジェクト: eclipse/osee
  @Override
  public Collection<IAtsTask> createTasks(NewTaskData newTaskData) {
    AtsTaskEndpointApi taskEp = AtsClientService.getTaskEp();
    Response response = taskEp.create(newTaskData);

    Artifact teamWf = atsClient.getArtifact(newTaskData.getTeamWfUuid());

    JaxAtsTasks jaxTasks = response.readEntity(JaxAtsTasks.class);
    ArtifactEvent artifactEvent = new ArtifactEvent(AtsUtilCore.getAtsBranch());
    List<Long> artUuids = new LinkedList<>();
    for (JaxAtsTask task : jaxTasks.getTasks()) {
      String guid = ArtifactQuery.getGuidFromUuid(task.getUuid(), AtsUtilCore.getAtsBranch());
      artifactEvent
          .getArtifacts()
          .add(
              new EventBasicGuidArtifact(
                  EventModType.Added,
                  AtsUtilCore.getAtsBranch().getUuid(),
                  AtsArtifactTypes.Task.getGuid(),
                  guid));
      artUuids.add(task.getUuid());

      RelationLink relation = getRelation(teamWf, task);
      Artifact taskArt = atsClient.getArtifact(task.getUuid());

      DefaultBasicUuidRelation guidRelation =
          new DefaultBasicUuidRelation(
              AtsUtilCore.getAtsBranch().getUuid(),
              AtsRelationTypes.TeamWfToTask_Task.getGuid(),
              relation.getId(),
              relation.getGammaId(),
              getBasicGuidArtifact(teamWf),
              getBasicGuidArtifact(taskArt));

      artifactEvent
          .getRelations()
          .add(
              new EventBasicGuidRelation(
                  RelationEventType.Added,
                  newTaskData.getTeamWfUuid().intValue(),
                  new Long(task.getUuid()).intValue(),
                  guidRelation));
    }

    OseeEventManager.kickPersistEvent(getClass(), artifactEvent);

    List<IAtsTask> tasks = new LinkedList<>();
    for (Long uuid : artUuids) {
      tasks.add(
          AtsClientService.get()
              .getWorkItemFactory()
              .getTask(AtsClientService.get().getArtifact(uuid)));
    }
    return tasks;
  }
コード例 #2
0
ファイル: TaskManager.java プロジェクト: pkdevboxy/osee
  public static Result transitionToCompleted(
      TaskArtifact taskArt, double estimatedHours, double additionalHours, IAtsChangeSet changes) {
    if (taskArt.isInState(TeamState.Completed)) {
      return Result.TrueResult;
    }
    // Assign current user if unassigned
    try {
      if (taskArt.getStateMgr().isUnAssigned()) {
        taskArt.getStateMgr().setAssignee(AtsClientService.get().getUserService().getCurrentUser());
      }
      taskArt
          .getStateMgr()
          .updateMetrics(
              taskArt.getStateDefinition(),
              additionalHours,
              100,
              true,
              AtsClientService.get().getUserService().getCurrentUser());
      if (estimatedHours > 0.0) {
        taskArt.setSoleAttributeValue(AtsAttributeTypes.EstimatedHours, estimatedHours);
      }
      TransitionHelper helper =
          new TransitionHelper(
              "Transition to Completed",
              Arrays.asList(taskArt),
              TaskStates.Completed.getName(),
              null,
              null,
              changes,
              AtsClientService.get().getServices());
      IAtsTransitionManager transitionMgr = TransitionFactory.getTransitionManager(helper);
      TransitionResults results = transitionMgr.handleAll();

      if (results.isEmpty()) {
        return Result.TrueResult;
      }
      return new Result("Transition Error %s", results.toString());
    } catch (Exception ex) {
      OseeLog.log(Activator.class, Level.SEVERE, ex);
      return new Result(
          "Exception occurred while transitioning to completed (see error log) "
              + ex.getLocalizedMessage());
    }
  }
コード例 #3
0
ファイル: TaskManager.java プロジェクト: pkdevboxy/osee
  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;
  }
コード例 #4
0
ファイル: TaskManager.java プロジェクト: pkdevboxy/osee
 public static Result transitionToInWork(
     TaskArtifact taskArt,
     IAtsUser toUser,
     int percentComplete,
     double additionalHours,
     IAtsChangeSet changes)
     throws OseeCoreException {
   if (taskArt.isInState(TaskStates.InWork)) {
     return Result.TrueResult;
   }
   TransitionHelper helper =
       new TransitionHelper(
           "Transition to InWork",
           Arrays.asList(taskArt),
           TaskStates.InWork.getName(),
           Arrays.asList(toUser),
           null,
           changes,
           AtsClientService.get().getServices(),
           TransitionOption.OverrideAssigneeCheck);
   IAtsTransitionManager transitionMgr = TransitionFactory.getTransitionManager(helper);
   TransitionResults results = transitionMgr.handleAll();
   if (!results.isEmpty()) {
     return new Result("Transition Error %s", results.toString());
   }
   if (taskArt.getStateMgr().getPercentComplete(taskArt.getCurrentStateName()) != percentComplete
       || additionalHours > 0) {
     taskArt
         .getStateMgr()
         .updateMetrics(
             taskArt.getStateDefinition(),
             additionalHours,
             percentComplete,
             true,
             AtsClientService.get().getUserService().getCurrentUser());
   }
   if (changes != null) {
     taskArt.saveSMA(changes);
   }
   return Result.TrueResult;
 }
コード例 #5
0
ファイル: AtsBranchUtil.java プロジェクト: pkdevboxy/osee
 /**
  * Perform error checks and popup confirmation dialogs associated with creating a working branch.
  *
  * @param popup if true, errors are popped up to user; otherwise sent silently in Results
  * @return Result return of status
  */
 public static Result createWorkingBranch_Validate(TeamWorkFlowArtifact teamArt) {
   try {
     if (AtsClientService.get().getBranchService().isCommittedBranchExists(teamArt)) {
       return new Result(
           "Committed branch already exists. Can not create another working branch once changes have been committed.");
     }
     IOseeBranch parentBranch =
         AtsClientService.get().getBranchService().getConfiguredBranchForWorkflow(teamArt);
     if (parentBranch == null) {
       return new Result(
           "Parent Branch can not be determined.\n\nPlease specify "
               + "parent branch through Version Artifact or Team Definition Artifact.\n\n"
               + "Contact your team lead to configure this.");
     }
     Result result = AtsClientService.get().getBranchService().isCreateBranchAllowed(teamArt);
     if (result.isFalse()) {
       return result;
     }
   } catch (Exception ex) {
     OseeLog.log(Activator.class, Level.SEVERE, ex);
     return new Result("Exception occurred: " + ex.getLocalizedMessage());
   }
   return Result.TrueResult;
 }
コード例 #6
0
ファイル: AtsBranchUtil.java プロジェクト: pkdevboxy/osee
 public static Result deleteWorkingBranch(TeamWorkFlowArtifact teamArt, boolean pend)
     throws OseeCoreException {
   IOseeBranch branch = AtsClientService.get().getBranchService().getWorkingBranch(teamArt);
   if (branch != null) {
     IStatus status = null;
     if (pend) {
       status = BranchManager.deleteBranchAndPend(branch);
     } else {
       Job job = BranchManager.deleteBranch(branch);
       job.schedule();
       try {
         job.join();
       } catch (InterruptedException ex) {
         throw new OseeWrappedException(ex);
       }
       status = job.getResult();
     }
     if (status.isOK()) {
       return Result.TrueResult;
     }
     return new Result(status.getMessage());
   }
   return Result.TrueResult;
 }
コード例 #7
0
ファイル: AtsBranchUtil.java プロジェクト: pkdevboxy/osee
 /**
  * Create a working branch associated with this state machine artifact. This should NOT be called
  * by applications except in test cases or automated tools. Use createWorkingBranchWithPopups
  */
 public static Job createWorkingBranch_Create(final TeamWorkFlowArtifact teamArt, boolean pend)
     throws OseeCoreException {
   final IOseeBranch parentBranch =
       AtsClientService.get().getBranchService().getConfiguredBranchForWorkflow(teamArt);
   return createWorkingBranch_Create(teamArt, parentBranch, pend);
 }