Ejemplo n.º 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;
  }
Ejemplo n.º 2
0
 public static List<String> toGuids(Collection<? extends IAtsObject> atsObjects) {
   List<String> guids = new ArrayList<>(atsObjects.size());
   for (IAtsObject atsObj : atsObjects) {
     guids.add(AtsUtilCore.getGuid(atsObj));
   }
   return guids;
 }