use of org.geotoolkit.sml.xml.v101.SystemType in project geotoolkit by Geomatys.
the class SmlXMLBindingTest method DataSourceMarshalingTest.
@Test
public void DataSourceMarshalingTest() throws Exception {
final SystemType system = new SystemType();
final List<DataComponentPropertyType> fields = new ArrayList<>();
fields.add(DataComponentPropertyType.LATITUDE_FIELD);
fields.add(DataComponentPropertyType.LONGITUDE_FIELD);
fields.add(DataComponentPropertyType.TIME_FIELD);
final DataRecordType posRecord = new DataRecordType(null, fields);
final DataBlockDefinitionType definition = new DataBlockDefinitionType(null, Arrays.asList(posRecord), TextBlockType.DEFAULT_ENCODING);
final DataDefinition dataDefinition = new DataDefinition(definition);
final org.geotoolkit.sml.xml.v101.Values trajValues = new org.geotoolkit.sml.xml.v101.Values();
trajValues.setAny("test");
final DataSourceType datasource = new DataSourceType(dataDefinition, trajValues, null);
final Position pos = new Position(null, datasource);
system.setPosition(pos);
DataSourceType expds = (DataSourceType) pos.getAbstractProcess();
DataSourceType resds = (DataSourceType) system.getPosition().getAbstractProcess();
assertEquals(expds.getDataDefinition(), resds.getDataDefinition());
assertEquals(expds, resds);
assertEquals(pos.getAbstractProcess(), system.getPosition().getAbstractProcess());
assertEquals(pos.getPosition(), system.getPosition().getPosition());
assertEquals(pos, system.getPosition());
final SensorML sml = new SensorML("1.0.1", Arrays.asList(new SensorML.Member(system)));
Marshaller m = SensorMLMarshallerPool.getInstance().acquireMarshaller();
ObjectFactory factory = new ObjectFactory();
// m.marshal(factory.createPosition(pos), System.out);
// m.marshal(factory.createSystem(system), System.out);
// m.marshal(sml, System.out);
SensorMLMarshallerPool.getInstance().recycle(m);
}
use of org.geotoolkit.sml.xml.v101.SystemType in project arctic-sea by 52North.
the class SensorMLDecoderV101 method parseSensorML.
@SuppressFBWarnings("BC_VACUOUS_INSTANCEOF")
private SensorML parseSensorML(final SensorMLDocument xbSensorML) throws DecodingException {
final SensorML sensorML = new SensorML();
// get member process
for (final Member xbMember : xbSensorML.getSensorML().getMemberArray()) {
if (xbMember.getProcess() != null) {
if (xbMember.getProcess() instanceof AbstractProcessType) {
final AbstractProcessType xbAbstractProcess = xbMember.getProcess();
AbstractProcess abstractProcess = null;
if (xbAbstractProcess.schemaType() == SystemType.type) {
abstractProcess = parseSystem((SystemType) xbAbstractProcess);
} else if (xbAbstractProcess.schemaType() == ProcessModelType.type) {
abstractProcess = parseProcessModel((ProcessModelType) xbAbstractProcess);
} else if (xbAbstractProcess.schemaType() == ComponentType.type) {
abstractProcess = parseComponent((ComponentType) xbAbstractProcess);
} else {
throw unsupportedMemberProcess(xbMember);
}
sensorML.addMember(abstractProcess);
} else {
throw unsupportedMemberProcess(xbMember);
}
} else {
throw new DecodingException(XmlHelper.getLocalName(xbMember), "The process of a member of the SensorML Document is null (%s)!", xbMember.getProcess());
}
}
sensorML.setXml(xbSensorML.xmlText(getXmlOptions()));
return sensorML;
}
use of org.geotoolkit.sml.xml.v101.SystemType 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 org.geotoolkit.sml.xml.v101.SystemType in project arctic-sea by 52North.
the class SensorMLEncoderv101 method createProcessDescription.
private XmlObject createProcessDescription(final AbstractProcess sensorDesc) throws EncodingException {
// TODO Review: System -> return doc; ProcessModel -> return type
if (sensorDesc instanceof System) {
System system = (System) sensorDesc;
SystemDocument xbSystemDoc = SystemDocument.Factory.newInstance(getXmlOptions());
SystemType xbSystem = xbSystemDoc.addNewSystem();
addAbstractProcessValues(xbSystem, system);
addSystemValues(xbSystem, system);
return xbSystem;
} else if (sensorDesc instanceof ProcessModel) {
// TODO: set values
ProcessModel processModel = (ProcessModel) sensorDesc;
ProcessModelDocument xbProcessModelDoc = ProcessModelDocument.Factory.newInstance(getXmlOptions());
ProcessModelType xbProcessModel = xbProcessModelDoc.addNewProcessModel();
addAbstractProcessValues(xbProcessModel, processModel);
addProcessModelValues(xbProcessModel, processModel);
return xbProcessModel;
} else if (sensorDesc instanceof org.n52.shetland.ogc.sensorML.Component) {
org.n52.shetland.ogc.sensorML.Component component = (org.n52.shetland.ogc.sensorML.Component) sensorDesc;
ComponentDocument cd = ComponentDocument.Factory.newInstance(getXmlOptions());
ComponentType ct = cd.addNewComponent();
addAbstractProcessValues(ct, component);
return ct;
} else {
throw unsupportedDescriptionType();
}
}
use of org.geotoolkit.sml.xml.v101.SystemType in project arctic-sea by 52North.
the class SensorMLDecoderV101Test method should_decode_child_procedure_from_sml.
@Test
public void should_decode_child_procedure_from_sml() throws DecodingException {
SensorMLDocument xbSmlDoc = getSensorMLDoc();
SystemType xbSystem = (SystemType) xbSmlDoc.getSensorML().addNewMember().addNewProcess().substitute(SensorMLConstants.SYSTEM_QNAME, SystemType.type);
IdentifierList xbIdentifierList = xbSystem.addNewIdentification().addNewIdentifierList();
addIdentifier(xbIdentifierList, "anyname", OGCConstants.URN_UNIQUE_IDENTIFIER, TEST_ID_1);
ComponentList xbComponentList = xbSystem.addNewComponents().addNewComponentList();
addChildProcedure(xbComponentList, TEST_ID_2);
AbstractProcess absProcess = decodeAbstractProcess(xbSmlDoc);
assertThat(absProcess.getIdentifier(), is(TEST_ID_1));
// assertThat(absProcess.getChildProcedures().size(), is(1));
// SosProcedureDescription childProcedure = absProcess.getChildProcedures().iterator().next();
// assertThat(childProcedure, instanceOf(System.class));
// assertThat(childProcedure.getIdentifier(), is(TEST_ID_2));
}
Aggregations