use of org.n52.shetland.ogc.sensorML.elements.SmlIo 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 org.n52.shetland.ogc.sensorML.elements.SmlIo in project arctic-sea by 52North.
the class SensorMLDecoderV20 method parseInput.
@SuppressWarnings({ "rawtypes" })
private SmlIo parseInput(Input xbInput) throws DecodingException {
final SmlIo sosIo = new SmlIo();
sosIo.setIoName(xbInput.getName());
if (xbInput.isSetHref()) {
parseReference(xbInput, sosIo);
} else {
sosIo.setIoValue(parseDataComponentOrObservablePropertyType(xbInput));
}
return sosIo;
}
use of org.n52.shetland.ogc.sensorML.elements.SmlIo in project arctic-sea by 52North.
the class SensorMLEncoderv101 method createInputs.
/**
* Creates the inputs section of the SensorML description.
*
* @param inputs
* SOS SWE representation.
*
* @return XML Inputs element
*
* @throws EncodingException
* if an error occurs
*/
private Inputs createInputs(List<SmlIo> inputs) throws EncodingException {
Inputs xbInputs = Inputs.Factory.newInstance(getXmlOptions());
InputList xbInputList = xbInputs.addNewInputList();
int counter = 1;
for (SmlIo sosSMLIo : inputs) {
if (!sosSMLIo.isSetName()) {
sosSMLIo.setIoName("input_" + counter++);
}
addIoComponentPropertyType(xbInputList.addNewInput(), sosSMLIo);
}
return xbInputs;
}
use of org.n52.shetland.ogc.sensorML.elements.SmlIo 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)));
}
}
use of org.n52.shetland.ogc.sensorML.elements.SmlIo in project arctic-sea by 52North.
the class SensorMLEncoderv20 method createInputs.
// /**
// * Creates the location section of the SensorML description.
// *
// * @param dot
// * the described object
// * @param location
// * SOS location representation.
// *
// * @throws EncodingException
// * if an error occurs
// */
// private void createLocation(DescribedObjectType dot, SmlLocation location) throws EncodingException {
// dot.addNewLocation().addNewAbstractGeometry().set(encodeObjectToXmlGml32(location.getPoint()));
// }
/**
* Creates the inputs section of the SensorML description.
*
* @param inputs
* SOS SWE representation.
*
* @return XML Inputs element
*
* @throws EncodingException
* if an error occurs
*/
private Inputs createInputs(final List<SmlIo> inputs) throws EncodingException {
final Inputs xbInputs = Inputs.Factory.newInstance(getXmlOptions());
final InputListType xbInputList = xbInputs.addNewInputList();
int counter = 1;
for (final SmlIo sosSMLIo : inputs) {
if (!sosSMLIo.isSetName()) {
sosSMLIo.setIoName("input_" + counter++);
} else {
sosSMLIo.setIoName(NcName.makeValid(sosSMLIo.getIoName()));
}
addInput(xbInputList.addNewInput(), sosSMLIo);
}
return xbInputs;
}
Aggregations