private List<SmlComponent> parseComponents(final Components components) throws OwsExceptionReport { final List<SmlComponent> sosSmlComponents = Lists.newLinkedList(); if (components.isSetComponentList() && components.getComponentList().getComponentArray() != null) { for (final Component component : components.getComponentList().getComponentArray()) { if (component.isSetProcess() || component.isSetHref()) { final SmlComponent sosSmlcomponent = new SmlComponent(component.getName()); AbstractProcess abstractProcess = null; if (component.isSetProcess()) { if (component.getProcess() instanceof SystemType) { abstractProcess = new System(); parseSystem((SystemType) component.getProcess(), (System) abstractProcess); } else { abstractProcess = new AbstractProcess(); parseAbstractProcess(component.getProcess(), abstractProcess); } } else { abstractProcess = new AbstractProcess(); abstractProcess.setIdentifier(component.getHref()); } sosSmlcomponent.setProcess(abstractProcess); sosSmlComponents.add(sosSmlcomponent); } } } return sosSmlComponents; }
/** * Parses the capabilities, processing and removing special insertion metadata * * @param abstractProcess The AbstractProcess to which capabilities and insertion metadata are * added * @param capabilitiesArray XML capabilities * @throws OwsExceptionReport * if an error occurs */ private void parseCapabilities( final AbstractProcess abstractProcess, final Capabilities[] capabilitiesArray) throws OwsExceptionReport { for (final Capabilities xbcaps : capabilitiesArray) { final Object o = CodingHelper.decodeXmlElement(xbcaps.getAbstractDataRecord()); if (o instanceof DataRecord) { final DataRecord record = (DataRecord) o; final SmlCapabilities caps = new SmlCapabilities(); caps.setDataRecord(record).setName(xbcaps.getName()); abstractProcess.addCapabilities(caps); // check if this capabilities is insertion metadata if (SensorMLConstants.ELEMENT_NAME_OFFERINGS.equals(caps.getName())) { abstractProcess.addOfferings( SosOffering.fromSet( caps.getDataRecord().getSweAbstractSimpleTypeFromFields(SweText.class))); } else if (SensorMLConstants.ELEMENT_NAME_PARENT_PROCEDURES.equals(caps.getName())) { abstractProcess.addParentProcedures(parseCapabilitiesMetadata(caps, xbcaps).keySet()); } else if (SensorMLConstants.ELEMENT_NAME_FEATURES_OF_INTEREST.equals(caps.getName())) { abstractProcess.addFeaturesOfInterest(parseCapabilitiesMetadata(caps, xbcaps).keySet()); } } else { throw new InvalidParameterValueException() .at(XmlHelper.getLocalName(xbcaps)) .withMessage( "Error while parsing the capabilities of " + "the SensorML (the capabilities data record " + "is not of type DataRecordPropertyType)!"); } } }
private void parseAbstractProcess( final AbstractProcessType xbAbstractProcess, final AbstractProcess abstractProcess) throws OwsExceptionReport { if (xbAbstractProcess.getId() != null) { abstractProcess.setGmlId(xbAbstractProcess.getId()); } if (xbAbstractProcess.getIdentificationArray() != null) { parseIdentifications(abstractProcess, xbAbstractProcess.getIdentificationArray()); } if (xbAbstractProcess.getClassificationArray() != null) { abstractProcess.setClassifications( parseClassification(xbAbstractProcess.getClassificationArray())); } if (xbAbstractProcess.getCharacteristicsArray() != null) { abstractProcess.setCharacteristics( parseCharacteristics(xbAbstractProcess.getCharacteristicsArray())); } if (xbAbstractProcess.getCapabilitiesArray() != null) { parseCapabilities(abstractProcess, xbAbstractProcess.getCapabilitiesArray()); final List<Integer> capsToRemove = checkCapabilitiesForRemoval(xbAbstractProcess.getCapabilitiesArray()); for (final Integer integer : capsToRemove) { xbAbstractProcess.removeCapabilities(integer); } } if (xbAbstractProcess.isSetDescription()) { abstractProcess.addDescription(xbAbstractProcess.getDescription().getStringValue()); } if (xbAbstractProcess.isSetValidTime()) { abstractProcess.setValidTime(parseValidTime(xbAbstractProcess.getValidTime())); } if (xbAbstractProcess.getContactArray() != null) { abstractProcess.setContact(parseContact(xbAbstractProcess.getContactArray())); } if (xbAbstractProcess.getDocumentationArray() != null) { abstractProcess.setDocumentation( parseDocumentation(xbAbstractProcess.getDocumentationArray())); } if (xbAbstractProcess.getHistoryArray() != null) { abstractProcess.setHistory(parseHistory(xbAbstractProcess.getHistoryArray())); } if (xbAbstractProcess.getKeywordsArray() != null) { abstractProcess.setKeywords(parseKeywords(xbAbstractProcess.getKeywordsArray())); } if (xbAbstractProcess.getNameArray() != null) { final int length = xbAbstractProcess.getNameArray().length; for (int i = 0; i < length; i++) { final Object decodedElement = CodingHelper.decodeXmlElement(xbAbstractProcess.getNameArray(i)); if (decodedElement instanceof CodeType) { abstractProcess.addName((CodeType) decodedElement); } } } }
private void parseAbstractComponent( final AbstractComponentType xbAbstractComponent, final AbstractProcess abstractProcess) throws OwsExceptionReport { if (xbAbstractComponent.isSetInputs()) { abstractProcess.setInputs(parseInputs(xbAbstractComponent.getInputs())); } if (xbAbstractComponent.isSetOutputs()) { abstractProcess.setOutputs(parseOutputs(xbAbstractComponent.getOutputs())); } if (xbAbstractComponent.isSetParameters()) { abstractProcess.setParameters(parseParameters(xbAbstractComponent.getParameters())); } }
/** * Parses the identifications and sets the AbstractProcess' identifiers * * @param abstractProcess The AbstractProcess to which identifiers are added * @param identificationArray XML identification */ private void parseIdentifications( final AbstractProcess abstractProcess, final Identification[] identificationArray) { for (final Identification xbIdentification : identificationArray) { if (xbIdentification.getIdentifierList() != null) { for (final Identifier xbIdentifier : xbIdentification.getIdentifierList().getIdentifierArray()) { if (xbIdentifier.getName() != null && xbIdentifier.getTerm() != null) { final SmlIdentifier identifier = new SmlIdentifier( xbIdentifier.getName(), xbIdentifier.getTerm().getDefinition(), xbIdentifier.getTerm().getValue()); abstractProcess.addIdentifier(identifier); if (isIdentificationProcedureIdentifier(identifier)) { abstractProcess.setIdentifier(identifier.getValue()); } } } } } }