use of net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList.Component in project arctic-sea by 52North.
the class SensorMLDecoderV101Test method addChildProcedure.
private void addChildProcedure(ComponentList xbComponentList, String identifier) {
Component xbComponent = xbComponentList.addNewComponent();
xbComponent.setName(SensorMLConstants.ELEMENT_NAME_CHILD_PROCEDURES);
SystemType xbSystem = (SystemType) xbComponent.addNewProcess().substitute(SensorMLConstants.SYSTEM_QNAME, SystemType.type);
IdentifierList xbIdentifierList = xbSystem.addNewIdentification().addNewIdentifierList();
addIdentifier(xbIdentifierList, "anyname", OGCConstants.URN_UNIQUE_IDENTIFIER, identifier);
}
use of net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList.Component in project arctic-sea by 52North.
the class SensorMLDecoderV101 method parseComponents.
private List<SmlComponent> parseComponents(final Components components) throws DecodingException {
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;
}
use of net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList.Component in project arctic-sea by 52North.
the class SensorMLEncoderV101Test method should_encode_single_contact_person.
// @Test
// public void should_encode_features_of_interest() throws EncodingException {
// final SensorML sensorMl = new SensorML();
// final System system = new System();
// sensorMl.addMember(system);
// system.addFeatureOfInterest(TEST_ID_1);
// system.addFeatureOfInterest(TEST_ID_2);
// final SimpleDataRecordType xbSimpleDataRecord =
// encodeSimpleDataRecord(sensorMl, SensorMLConstants.ELEMENT_NAME_FEATURES_OF_INTEREST, 2);
// validateField(xbSimpleDataRecord.getFieldArray()[0], SensorMLConstants.FEATURE_OF_INTEREST_FIELD_NAME + 1,
// SensorMLConstants.FEATURE_OF_INTEREST_FIELD_DEFINITION, TEST_ID_1);
// validateField(xbSimpleDataRecord.getFieldArray()[1], SensorMLConstants.FEATURE_OF_INTEREST_FIELD_NAME + 2,
// SensorMLConstants.FEATURE_OF_INTEREST_FIELD_DEFINITION, TEST_ID_2);
// }
//
// @Test
// public void should_encode_offerings() throws EncodingException {
// final SensorML sensorMl = new SensorML();
// final System system = new System();
// sensorMl.addMember(system);
// system.addOffering(new SosOffering(TEST_ID_1, TEST_NAME_1));
// system.addOffering(new SosOffering(TEST_ID_2, TEST_NAME_2));
// final SimpleDataRecordType xbSimpleDataRecord =
// encodeSimpleDataRecord(sensorMl, SensorMLConstants.ELEMENT_NAME_OFFERINGS, 2);
// validateField(xbSimpleDataRecord.getFieldArray()[0], TEST_NAME_1, SensorMLConstants.OFFERING_FIELD_DEFINITION,
// TEST_ID_1);
// validateField(xbSimpleDataRecord.getFieldArray()[1], TEST_NAME_2, SensorMLConstants.OFFERING_FIELD_DEFINITION,
// TEST_ID_2);
// }
//
// @Test
// public void should_encode_parent_procedures() throws EncodingException {
// final SensorML sensorMl = new SensorML();
// final System system = new System();
// sensorMl.addMember(system);
// system.addParentProcedure(TEST_ID_1);
// system.addParentProcedure(TEST_ID_2);
// final SimpleDataRecordType xbSimpleDataRecord =
// encodeSimpleDataRecord(sensorMl, SensorMLConstants.ELEMENT_NAME_PARENT_PROCEDURES, 2);
// validateField(xbSimpleDataRecord.getFieldArray()[0], SensorMLConstants.PARENT_PROCEDURE_FIELD_NAME + 1,
// SensorMLConstants.PARENT_PROCEDURE_FIELD_DEFINITION, TEST_ID_1);
// validateField(xbSimpleDataRecord.getFieldArray()[1], SensorMLConstants.PARENT_PROCEDURE_FIELD_NAME + 2,
// SensorMLConstants.PARENT_PROCEDURE_FIELD_DEFINITION, TEST_ID_2);
// }
//
// @Test
// public void should_encode_child_procedures() throws EncodingException {
// final SensorML sensorMl = new SensorML();
// final System system = new System();
// sensorMl.addMember(system);
// final System childProcedure = new System();
// childProcedure.setIdentifier(TEST_CHILD_1);
// system.addChildProcedure(childProcedure);
// childProcedure.addFeatureOfInterest(TEST_ID_1);
// final SystemType xbSystemType = encodeSystem(sensorMl);
// assertThat(xbSystemType.getComponents().getComponentList().sizeOfComponentArray(), is(1));
// final Component xbComponent = xbSystemType.getComponents().getComponentList().getComponentArray(0);
// assertThat(xbComponent.getProcess(), instanceOf(SystemType.class));
// final SystemType xbComponentSystem = (SystemType) xbComponent.getProcess();
// final SimpleDataRecordType xbSimpleDataRecord =
// encodeSimpleDataRecord(xbComponentSystem, SensorMLConstants.ELEMENT_NAME_FEATURES_OF_INTEREST, 1);
// validateField(xbSimpleDataRecord.getFieldArray(0), SensorMLConstants.FEATURE_OF_INTEREST_FIELD_NAME,
// SensorMLConstants.FEATURE_OF_INTEREST_FIELD_DEFINITION, TEST_ID_1);
// }
//
// @Test
// @SuppressWarnings("unchecked")
// public void should_aggregate_child_outputs() throws EncodingException {
// final SweQuantity q1 = new SweQuantity();
// q1.setDefinition("def1");
// q1.setUom("uom1");
// final SmlIo<?> output1 = new SmlIo<SweQuantity>(q1);
//
// final SweQuantity q2 = new SweQuantity();
// q2.setDefinition("def2");
// q2.setUom("uom2");
// final SmlIo<?> output2 = new SmlIo<SweQuantity>(q2);
//
// final SweQuantity q3 = new SweQuantity();
// q3.setDefinition("def3");
// q3.setUom("uom3");
// final SmlIo<?> output3 = new SmlIo<SweQuantity>(q3);
//
// final SensorML sensorMl = new SensorML();
// sensorMl.setIdentifier("sensorMl");
// final System system = new System();
// system.setIdentifier("system");
// sensorMl.addMember(system);
// system.getOutputs().add(output1);
//
// final SensorML childSml = new SensorML();
// childSml.setIdentifier("childSml");
// final System childSystem = new System();
// childSystem.setIdentifier("childSystem");
// childSml.addMember(childSystem);
// system.addChildProcedure(childSml);
// childSystem.getOutputs().add(output2);
//
// final SensorML grandchildSml = new SensorML();
// grandchildSml.setIdentifier("grandchildSml");
// final System grandchildSystem = new System();
// grandchildSystem.setIdentifier("grandchildSystem");
// grandchildSml.addMember(grandchildSystem);
// childSystem.addChildProcedure(grandchildSml);
// grandchildSystem.getOutputs().add(output3);
//
// encodeSystem(sensorMl);
//
// assertThat(system.getOutputs(), hasItems(output1, output2, output3));
// assertThat(childSystem.getOutputs(), hasItems(output2, output3));
// assertThat(grandchildSystem.getOutputs(), hasItem(output3));
// }
@Test
public void should_encode_single_contact_person() throws EncodingException {
final SensorML sensorML = new SensorML();
final System system = new System();
sensorML.addMember(system);
final SmlPerson contact = createPerson("");
system.addContact(contact);
final SystemType xbSystem = encodeSystem(sensorML);
assertThat(xbSystem.sizeOfContactArray(), is(1));
assertThat(xbSystem.getContactArray(0).getContactList().getMemberArray(0).isSetPerson(), is(true));
checkPerson(contact, xbSystem.getContactArray(0).getContactList().getMemberArray(0).getPerson());
}
use of net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList.Component in project arctic-sea by 52North.
the class SensorMLEncoderv101 method createComponents.
/**
* Creates the components section of the SensorML description.
*
* @param sosComponents
* SOS SWE representation.
*
* @return encoded sml:components
*
* @throws EncodingException
* if the encoding fails
*/
private Components createComponents(List<SmlComponent> sosComponents) throws EncodingException {
Components components = Components.Factory.newInstance(getXmlOptions());
ComponentList componentList = components.addNewComponentList();
for (SmlComponent sosSMLComponent : sosComponents) {
Component component = componentList.addNewComponent();
if (sosSMLComponent.getName() != null) {
component.setName(sosSMLComponent.getName());
}
if (sosSMLComponent.getHref() != null) {
component.setHref(sosSMLComponent.getHref());
if (sosSMLComponent.getTitle() != null) {
component.setTitle(sosSMLComponent.getTitle());
}
} else if (sosSMLComponent.getProcess() != null) {
XmlObject xmlObject = null;
if (sosSMLComponent.getProcess().isSetXml()) {
try {
xmlObject = XmlObject.Factory.parse(sosSMLComponent.getProcess().getXml());
} catch (XmlException xmle) {
throw new EncodingException("Error while encoding SensorML child procedure description " + "from stored SensorML encoded sensor description with XMLBeans", xmle);
}
} else {
if (sosSMLComponent.getProcess() instanceof SensorML) {
xmlObject = createSensorDescriptionFromObject(((SensorML) sosSMLComponent.getProcess()).getMembers().iterator().next());
} else if (sosSMLComponent.getProcess() instanceof AbstractProcess) {
xmlObject = createSensorDescriptionFromObject(sosSMLComponent.getProcess());
}
}
if (xmlObject != null) {
AbstractProcessType xbProcess = null;
if (xmlObject instanceof SensorMLDocument) {
final SensorMLDocument smlDoc = (SensorMLDocument) xmlObject;
for (final Member member : smlDoc.getSensorML().getMemberArray()) {
xbProcess = member.getProcess();
break;
}
} else if (xmlObject instanceof AbstractProcessType) {
xbProcess = (AbstractProcessType) xmlObject;
}
if (xbProcess == null) {
throw new EncodingException("The sensor type is not supported by this SOS");
}
// TODO add feature/parentProcs/childProcs to component - is
// this already done?
SchemaType schemaType = xbProcess.schemaType();
component.addNewProcess().substitute(getQnameForType(schemaType), schemaType).set(xbProcess);
}
}
}
return components;
}
use of net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList.Component in project arctic-sea by 52North.
the class SensorMLEncoderv101 method addIoComponentPropertyType.
/**
* Adds a SOS SWE simple type to a XML SML IO component.
*
* @param ioComponentPropertyType
* SML IO component
* @param sosSMLIO
* SOS SWE simple type.
*
* @throws EncodingException
* if the encoding fails
*/
private void addIoComponentPropertyType(IoComponentPropertyType ioComponentPropertyType, SmlIo sosSMLIO) throws EncodingException {
ioComponentPropertyType.setName(sosSMLIO.getIoName());
if (sosSMLIO.isSetHref()) {
ioComponentPropertyType.setHref(sosSMLIO.getTitle());
if (sosSMLIO.isSetTitle()) {
ioComponentPropertyType.setTitle(sosSMLIO.getTitle());
}
} else {
XmlObject encodeObjectToXml;
XmlObject xml = encodeObjectToXml(SweConstants.NS_SWE_101, sosSMLIO.getIoValue());
if (xml instanceof DataArrayDocument) {
encodeObjectToXml = ((DataArrayDocument) xml).getDataArray1();
} else {
encodeObjectToXml = xml;
}
sosSMLIO.getIoValue().accept(new SweDataComponentAdder(ioComponentPropertyType)).map(h -> (AbstractDataComponentType) h.set(encodeObjectToXml)).ifPresent(h -> sosSMLIO.getIoValue().accept(new SweDataComponentSubstituter(h)));
}
}
Aggregations