Beispiel #1
0
  @SuppressWarnings("unchecked")
  @Override
  public <T extends IAtsWorkItem> Collection<T> getItems() throws OseeCoreException {
    QueryBuilder query =
        atsServer.getOrcsApi().getQueryFactory().fromBranch(AtsUtilCore.getAtsBranch());

    // WorkItem type
    if (clazz != null) {
      List<IArtifactType> artifactTypes = getArtifactTypes();
      query.andIsOfType(artifactTypes.toArray(new IArtifactType[artifactTypes.size()]));
    }

    // team
    if (teamDef != null) {
      query.and(
          AtsAttributeTypes.TeamDefinition, Collections.singleton(AtsUtilCore.getGuid(teamDef)));
    }

    // state
    if (stateType != null) {
      List<String> stateTypes = new ArrayList<>();
      for (StateType type : stateType) {
        stateTypes.add(type.name());
      }
      query.and(AtsAttributeTypes.CurrentStateType, stateTypes);
    }

    // Artifact Types
    if (artifactTypes != null && artifactTypes.length > 0) {
      query.andIsOfType(artifactTypes);
    }

    if (uuids != null && uuids.length > 0) {
      List<Long> artIds = new LinkedList<>();
      for (Long uuid : uuids) {
        artIds.add(uuid);
      }
      query.andUuids(artIds);
    }

    // attributes
    if (!andAttr.isEmpty()) {
      for (AtsAttributeQuery attrQuery : andAttr) {
        query.and(attrQuery.getAttrType(), attrQuery.getValues(), attrQuery.getQueryOption());
      }
    }

    if (!andRels.isEmpty()) {
      for (Entry<IRelationTypeSide, IAtsObject> entry : andRels.entrySet()) {
        query.andRelatedTo(entry.getKey(), (ArtifactReadable) entry.getValue().getStoreObject());
      }
    }

    Set<T> workItems = new HashSet<>();
    Iterator<ArtifactReadable> iterator = query.getResults().iterator();
    while (iterator.hasNext()) {
      workItems.add((T) atsServer.getWorkItemFactory().getWorkItem(iterator.next()));
    }
    return workItems;
  }
Beispiel #2
0
  public List<CpaDecision> load() {
    List<CpaDecision> decisions = new ArrayList<CpaDecision>();
    QueryBuilder queryBuilder =
        atsServer
            .getQuery()
            .andTypeEquals(AtsArtifactTypes.TeamWorkflow)
            .and(AtsAttributeTypes.ApplicabilityWorkflow, "true");
    if (Strings.isValid(programUuid)) {
      queryBuilder.and(AtsAttributeTypes.ProgramUuid, programUuid);
    }
    if (Conditions.hasValues(uuids)) {
      queryBuilder.and(AtsAttributeTypes.AtsId, uuids);
    }
    if (open != null) {
      queryBuilder.and(
          AtsAttributeTypes.CurrentStateType,
          (open ? StateType.Working.name() : StateType.Completed.name()));
    }
    HashCollection<String, CpaDecision> origPcrIdToDecision =
        new HashCollection<String, CpaDecision>();
    String pcrToolId = null;
    ElapsedTime time = new ElapsedTime("load cpa workflows");
    ResultSet<ArtifactReadable> results = queryBuilder.getResults();
    time.end(Units.SEC);
    time = new ElapsedTime("process cpa workflows");
    for (ArtifactReadable art : results) {
      IAtsTeamWorkflow teamWf = atsServer.getWorkItemFactory().getTeamWf(art);
      CpaDecision decision = CpaFactory.getDecision(teamWf, null);
      decision.setApplicability(
          art.getSoleAttributeValue(AtsAttributeTypes.ApplicableToProgram, ""));
      decision.setRationale(art.getSoleAttributeValue(AtsAttributeTypes.Rationale, ""));
      String pcrToolIdValue = art.getSoleAttributeValue(AtsAttributeTypes.PcrToolId, "");
      if (pcrToolId == null) {
        pcrToolId = pcrToolIdValue;
      }
      decision.setPcrSystem(pcrToolIdValue);
      boolean completed =
          art.getSoleAttributeValue(AtsAttributeTypes.CurrentStateType, "")
              .equals(StateType.Completed.name());
      decision.setComplete(completed);
      decision.setAssignees(teamWf.getStateMgr().getAssigneesStr());
      if (completed) {
        decision.setCompletedBy(teamWf.getCompletedBy().getName());
        decision.setCompletedDate(DateUtil.getMMDDYY(teamWf.getCompletedDate()));
      }

      // set location of decision workflow
      decision.setDecisionLocation(
          CpaUtil.getCpaPath(atsServer).path(teamWf.getAtsId()).build().toString());

      // set location of originating pcr
      String origPcrId = art.getSoleAttributeValue(AtsAttributeTypes.OriginatingPcrId);
      origPcrIdToDecision.put(origPcrId, decision);
      decision.setOrigPcrLocation(
          CpaUtil.getCpaPath(atsServer)
              .path(origPcrId)
              .queryParam("pcrSystem", decision.getPcrSystem())
              .build()
              .toString());

      // set location of duplicated pcr (if any)
      String duplicatedPcrId = art.getSoleAttributeValue(AtsAttributeTypes.DuplicatedPcrId, null);
      if (Strings.isValid(duplicatedPcrId)) {
        String duplicatedLocation =
            CpaUtil.getCpaPath(atsServer)
                .path(duplicatedPcrId)
                .queryParam("pcrSystem", decision.getPcrSystem())
                .build()
                .toString();
        decision.setDuplicatedPcrLocation(duplicatedLocation);
        decision.setDuplicatedPcrId(duplicatedPcrId);
      }

      decisions.add(decision);
    }
    time.end();

    time = new ElapsedTime("load issues");
    IAtsCpaService service = cpaRegistry.getServiceById(pcrToolId);
    for (Entry<String, CpaPcr> entry :
        service.getPcrsByIds(origPcrIdToDecision.keySet()).entrySet()) {
      for (CpaDecision decision : origPcrIdToDecision.getValues(entry.getKey())) {
        decision.setOriginatingPcr(entry.getValue());
      }
    }
    time.end();

    return decisions;
  }