use of net.opengis.swe.x101.SimpleDataRecordType in project arctic-sea by 52North.
the class SweCommonEncoderv101Test method should_encode_simpleDataRecordWithFields.
@Test
public void should_encode_simpleDataRecordWithFields() throws EncodingException {
final String field0Value = "field-0-value";
final String field0Name = "field-0";
final String field1Name = "field-1";
final Boolean field1Value = Boolean.TRUE;
final XmlObject encode = sweCommonEncoderv101.encode(new SweSimpleDataRecord().addField(new SweField(field0Name, new SweText().setValue(field0Value))).addField(new SweField(field1Name, new SweBoolean().setValue(field1Value))));
assertThat(encode, instanceOf(SimpleDataRecordType.class));
final SimpleDataRecordType xbSimpleDataRecord = (SimpleDataRecordType) encode;
final AnyScalarPropertyType field0 = xbSimpleDataRecord.getFieldArray(0);
final AnyScalarPropertyType field1 = xbSimpleDataRecord.getFieldArray(1);
assertThat(xbSimpleDataRecord.getFieldArray().length, is(2));
assertThat(field0.isSetText(), is(TRUE));
assertThat(field0.getName(), is(field0Name));
assertThat(field0.getText().getValue(), is(field0Value));
assertThat(field1.isSetBoolean(), is(TRUE));
assertThat(field1.getName(), is(field1Name));
assertThat(field1.getBoolean().getValue(), is(field1Value));
}
use of net.opengis.swe.x101.SimpleDataRecordType in project arctic-sea by 52North.
the class SensorMLDecoderV101Test method addCapabilitiesInsertionMetadata.
private void addCapabilitiesInsertionMetadata(SimpleDataRecordType xbSimpleDataRecord, String value, String name) {
AnyScalarPropertyType xbField = xbSimpleDataRecord.addNewField();
xbField.setName(name);
xbField.addNewText().setValue(value);
xbField.getText().addNewName().setStringValue(name);
}
use of net.opengis.swe.x101.SimpleDataRecordType in project arctic-sea by 52North.
the class SensorMLDecoderV101Test method should_decode_parent_procedures_from_sml.
@Test
public void should_decode_parent_procedures_from_sml() throws DecodingException {
SensorMLDocument xbSmlDoc = getSensorMLDoc();
SystemType xbSystem = (SystemType) xbSmlDoc.getSensorML().addNewMember().addNewProcess().substitute(SensorMLConstants.SYSTEM_QNAME, SystemType.type);
Capabilities xbCapabilities = xbSystem.addNewCapabilities();
xbCapabilities.setName(SensorMLConstants.ELEMENT_NAME_PARENT_PROCEDURES);
SimpleDataRecordType xbSimpleDataRecord = (SimpleDataRecordType) xbCapabilities.addNewAbstractDataRecord().substitute(SweConstants.QN_SIMPLEDATARECORD_SWE_101, SimpleDataRecordType.type);
addCapabilitiesInsertionMetadata(xbSimpleDataRecord, TEST_ID_1, TEST_NAME_1);
addCapabilitiesInsertionMetadata(xbSimpleDataRecord, TEST_ID_2, TEST_NAME_2);
AbstractProcess absProcess = decodeAbstractProcess(xbSmlDoc);
// assertThat(absProcess.getParentProcedures().size(), is(2));
assertThat(absProcess.getCapabilities().size(), is(1));
// List<String> parentProcedures = new ArrayList<String>(absProcess.getParentProcedures());
// Collections.sort(parentProcedures);
// assertThat(parentProcedures.get(0), is(TEST_ID_1));
// assertThat(parentProcedures.get(1), is(TEST_ID_2));
}
use of net.opengis.swe.x101.SimpleDataRecordType in project arctic-sea by 52North.
the class SensorMLDecoderV101Test method should_decode_offerings_from_sml.
@Test
public void should_decode_offerings_from_sml() throws DecodingException {
SensorMLDocument xbSmlDoc = getSensorMLDoc();
SystemType xbSystem = (SystemType) xbSmlDoc.getSensorML().addNewMember().addNewProcess().substitute(SensorMLConstants.SYSTEM_QNAME, SystemType.type);
Capabilities xbCapabilities = xbSystem.addNewCapabilities();
xbCapabilities.setName(SensorMLConstants.ELEMENT_NAME_OFFERINGS);
SimpleDataRecordType xbSimpleDataRecord = (SimpleDataRecordType) xbCapabilities.addNewAbstractDataRecord().substitute(SweConstants.QN_SIMPLEDATARECORD_SWE_101, SimpleDataRecordType.type);
addCapabilitiesInsertionMetadata(xbSimpleDataRecord, TEST_ID_1, TEST_NAME_1);
addCapabilitiesInsertionMetadata(xbSimpleDataRecord, TEST_ID_2, TEST_NAME_2);
AbstractProcess absProcess = decodeAbstractProcess(xbSmlDoc);
// assertThat(absProcess.getOfferings().size(), is(2));
assertThat(absProcess.getCapabilities().size(), is(1));
// List<SosOffering> sosOfferings = new ArrayList<SosOffering>(absProcess.getOfferings());
// Collections.sort(sosOfferings);
// assertThat(sosOfferings.get(0).getIdentifier(), is(TEST_ID_1));
// assertThat(sosOfferings.get(0).getOfferingName(), is(TEST_NAME_1));
// assertThat(sosOfferings.get(1).getIdentifier(), is(TEST_ID_2));
// assertThat(sosOfferings.get(1).getOfferingName(), is(TEST_NAME_2));
}
use of net.opengis.swe.x101.SimpleDataRecordType in project arctic-sea by 52North.
the class SensorMLEncoderv101 method createCharacteristics.
/**
* Creates the characteristics section of the SensorML description.
*
* @param smlCharacteristics
* SOS characteristics list
*
* @return XML Characteristics array
*
* @throws EncodingException
* If an error occurs
*/
private Characteristics[] createCharacteristics(final List<SmlCharacteristics> smlCharacteristics) throws EncodingException {
final List<Characteristics> characteristicsList = Lists.newArrayListWithExpectedSize(smlCharacteristics.size());
for (final SmlCharacteristics sosSMLCharacteristics : smlCharacteristics) {
final Characteristics xbCharacteristics = Characteristics.Factory.newInstance(getXmlOptions());
if (sosSMLCharacteristics.isSetName()) {
xbCharacteristics.setName(sosSMLCharacteristics.getName());
}
if (sosSMLCharacteristics.isSetAbstractDataRecord()) {
if (sosSMLCharacteristics.getDataRecord() instanceof SweSimpleDataRecord) {
final SimpleDataRecordType xbSimpleDataRecord = (SimpleDataRecordType) xbCharacteristics.addNewAbstractDataRecord().substitute(SweConstants.QN_SIMPLEDATARECORD_SWE_101, SimpleDataRecordType.type);
if (sosSMLCharacteristics.isSetTypeDefinition()) {
xbSimpleDataRecord.setDefinition(sosSMLCharacteristics.getTypeDefinition());
}
if (sosSMLCharacteristics.getDataRecord().isSetFields()) {
for (final SweField field : sosSMLCharacteristics.getDataRecord().getFields()) {
final AnyScalarPropertyType xbField = xbSimpleDataRecord.addNewField();
xbField.setName(field.getName().getValue());
addSweSimpleTypeToField(xbField, field.getElement());
}
}
} else if (sosSMLCharacteristics.getDataRecord() instanceof SweDataRecord) {
throw unsupportedCharacteristicsType(SweAggregateType.DataRecord);
} else {
throw unsupportedCharacteristicsType(sosSMLCharacteristics.getDataRecord().getClass().getName());
}
} else if (sosSMLCharacteristics.isSetHref()) {
if (sosSMLCharacteristics.isSetName()) {
xbCharacteristics.setName(sosSMLCharacteristics.getName());
}
xbCharacteristics.setHref(sosSMLCharacteristics.getHref());
if (sosSMLCharacteristics.isSetTitle()) {
xbCharacteristics.setTitle(sosSMLCharacteristics.getTitle());
}
}
characteristicsList.add(xbCharacteristics);
}
return characteristicsList.toArray(new Characteristics[characteristicsList.size()]);
}
Aggregations