@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(); } } } }
private void checkBackTrace( ArtifactReadable subsystemRequirement, String current, IRelationTypeSide relType, IAttributeType attrType) throws IOException { /** * when the parent criticality is lower than the child, we check to see if the child traces to * any parent with /* the higher criticality (thus justifying the criticality of the child) */ List<ArtifactReadable> tracedToRequirements = Lists.newArrayList(subsystemRequirement.getRelated(relType)); String maxCriticality = "E"; String parentCriticality = "E"; for (ArtifactReadable parent : tracedToRequirements) { parentCriticality = parent.getSoleAttributeAsString(attrType, "V"); if (attrType.equals(CoreAttributeTypes.SafetyCriticality)) { parentCriticality = convertSafetyCriticalityToDAL(parentCriticality); } maxCriticality = maxCriticality(maxCriticality, parentCriticality); } if (current.compareTo(maxCriticality) != 0) { writer.writeCell(String.format("%s [Error:<%s]", current, maxCriticality)); } else { writer.writeCell(current); } }
/** 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()); }
@Override public String getStorageString() { return "DNE" + TOKEN + attributeType.getGuid().toString(); }