Example #1
0
  @Override
  public void writeTo(
      Object object,
      Class<?> type,
      Type genericType,
      Annotation[] annotations,
      MediaType mediaType,
      MultivaluedMap<String, Object> httpHeaders,
      OutputStream entityStream)
      throws IOException, WebApplicationException {
    JsonGenerator writer = null;
    if (type.isAssignableFrom(ArtifactReadable.class)) {
      ArtifactReadable artifact = (ArtifactReadable) object;
      try {
        writer = jsonFactory.createJsonGenerator(entityStream);
        //         writer.setPrettyPrinter(new DefaultPr)
        writer.writeStartObject();
        writer.writeNumberField("uuid", artifact.getLocalId());
        if (matches(IdentityView.class, annotations)) {
          writer.writeStringField("Name", artifact.getName());
        } else {
          AttributeTypes attributeTypes = getAttibuteTypes();
          Collection<? extends IAttributeType> attrTypes = attributeTypes.getAll();
          ResultSet<? extends AttributeReadable<Object>> attributes = artifact.getAttributes();
          if (!attributes.isEmpty()) {
            for (IAttributeType attrType : attrTypes) {
              if (artifact.isAttributeTypeValid(attrType)) {
                List<Object> attributeValues = artifact.getAttributeValues(attrType);
                if (!attributeValues.isEmpty()) {

                  if (attributeValues.size() > 1) {
                    writer.writeArrayFieldStart(attrType.getName());
                    for (Object value : attributeValues) {
                      writer.writeObject(value);
                    }
                    writer.writeEndArray();
                  } else if (attributeValues.size() == 1) {
                    Object value = attributeValues.iterator().next();
                    writer.writeObjectField(attrType.getName(), value);
                  }
                }
              }
            }
          }
        }
        writer.writeEndObject();
      } finally {
        if (writer != null) {
          writer.flush();
        }
      }
    }
  }
  /** used recursively when originally passed a directory, thus an array of files is accepted */
  private static void retrieveData(
      IProgressMonitor monitor,
      Collection<TeamWorkFlowArtifact> teamArts,
      IAttributeType attributeType,
      XResultData rd)
      throws OseeCoreException {
    monitor.subTask("Retrieving Actions");

    int x = 1;
    rd.addRaw(AHTML.beginMultiColumnTable(95));
    rd.addRaw(
        AHTML.addHeaderRowMultiColumnTable(
            new String[] {"HRID", "Bulld", "UI", attributeType.getName(), "RPCR", "Change"}));
    for (TeamWorkFlowArtifact teamArt : teamArts) {
      String rcprId = teamArt.getSoleAttributeValue(AtsAttributeTypes.LegacyPcrId, "");
      String result =
          String.format(
              "Processing %s/%s RPCR %s for \"%s\"",
              x, teamArts.size(), rcprId, teamArt.getTeamDefinition().getName());
      monitor.subTask(result);
      rd.log("\nRPCR " + rcprId);
      for (ICommitConfigArtifact commitConfigArt :
          AtsBranchManagerCore.getConfigArtifactsConfiguredToCommitTo(teamArt)) {
        processTeam(
            teamArt,
            BranchManager.getBranchByGuid(commitConfigArt.getBaslineBranchGuid()).getShortName(),
            attributeType,
            commitConfigArt,
            rd);
      }
      x++;

      //          System.err.println("Developmental purposes only, don't release with this");
      //          if (x >= 5)
      //          break;
    }
    rd.addRaw(AHTML.endMultiColumnTable());
  }
 public Collection<String> getAttributeValueList(IAttributeType attributeType) {
   return getAttributeValueList(attributeType.getName());
 }