Exemple #1
0
  @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;
  }