use of net.opengis.sensorML.x101.SensorMLDocument in project arctic-sea by 52North.
the class SensorMLDecoderV101 method addSensorMLWrapperForXmlDescription.
private String addSensorMLWrapperForXmlDescription(final AbstractProcessType xbProcessType) {
final SensorMLDocument xbSensorMLDoc = SensorMLDocument.Factory.newInstance(getXmlOptions());
final net.opengis.sensorML.x101.SensorMLDocument.SensorML xbSensorML = xbSensorMLDoc.addNewSensorML();
xbSensorML.setVersion(SensorMLConstants.VERSION_V101);
final Member member = xbSensorML.addNewMember();
final AbstractProcessType xbAbstractProcessType = (AbstractProcessType) member.addNewProcess().substitute(getQnameForType(xbProcessType.schemaType()), xbProcessType.schemaType());
xbAbstractProcessType.set(xbProcessType);
return xbSensorMLDoc.xmlText(getXmlOptions());
}
use of net.opengis.sensorML.x101.SensorMLDocument 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 net.opengis.sensorML.x101.SensorMLDocument in project arctic-sea by 52North.
the class SensorMLEncoderV101Test method should_merge_and_encode_multiple_contacts.
@Test
public void should_merge_and_encode_multiple_contacts() throws EncodingException {
final SensorML sensorML = new SensorML();
final System system = new System();
sensorML.addMember(system);
final SmlPerson p1 = createPerson("1");
final SmlResponsibleParty rp1 = createResponsibleParty("1");
system.addContact(p1);
system.addContact(rp1);
final SensorMLDocument xbSensorML = SensorMLDocument.Factory.newInstance();
final SystemType xbSystem = SystemType.Factory.newInstance();
final ContactList xbContactList = xbSystem.addNewContact().addNewContactList();
final Person xbP1 = xbContactList.addNewMember().addNewPerson();
setPersonValues(p1, xbP1);
final ResponsibleParty xbRP1 = xbContactList.addNewMember().addNewResponsibleParty();
setResponsiblePartyValues(rp1, xbRP1);
final XmlObject xbProcess = xbSensorML.addNewSensorML().addNewMember().addNewProcess().set(xbSystem);
XmlHelper.substituteElement(xbProcess, xbSystem);
xbSensorML.getSensorML().setVersion("1.0.1");
sensorML.setXml(xbSensorML.xmlText());
final SystemType xbEncodedSystem = encodeSystem(sensorML);
assertThat(xbEncodedSystem.sizeOfContactArray(), is(1));
assertThat(xbEncodedSystem.getContactArray(0).isSetContactList(), is(true));
assertThat(xbEncodedSystem.getContactArray(0).getContactList().sizeOfMemberArray(), is(2));
boolean personChecked = false, responsiblePartyChecked = false;
for (final Member member : xbEncodedSystem.getContactArray(0).getContactList().getMemberArray()) {
if (member.isSetPerson()) {
checkPerson(p1, member.getPerson());
personChecked = true;
} else if (member.isSetResponsibleParty()) {
checkResponsibleParty(rp1, member.getResponsibleParty());
responsiblePartyChecked = true;
}
}
if (!personChecked) {
fail("sml:Person not found in contact/contactList");
}
if (!responsiblePartyChecked) {
fail("sml:ResponsibleParty not found in contact/ContactList");
}
}
use of net.opengis.sensorML.x101.SensorMLDocument in project arctic-sea by 52North.
the class SensorMLEncoderV101Test method should_merge_and_encode_two_same_contact_responsibleParty_only_once.
@Test
public void should_merge_and_encode_two_same_contact_responsibleParty_only_once() throws EncodingException {
final SensorML sensorML = new SensorML();
final System system = new System();
sensorML.addMember(system);
final SmlResponsibleParty p1 = createResponsibleParty("1");
system.addContact(p1);
final SensorMLDocument xbSensorML = SensorMLDocument.Factory.newInstance();
final SystemType xbSystem = SystemType.Factory.newInstance();
final ResponsibleParty xbP1 = xbSystem.addNewContact().addNewResponsibleParty();
setResponsiblePartyValues(p1, xbP1);
final XmlObject xbProcess = xbSensorML.addNewSensorML().addNewMember().addNewProcess().set(xbSystem);
XmlHelper.substituteElement(xbProcess, xbSystem);
xbSensorML.getSensorML().setVersion("1.0.1");
sensorML.setXml(xbSensorML.xmlText());
final SystemType xbEncodedSystem = encodeSystem(sensorML);
assertThat(xbEncodedSystem.sizeOfContactArray(), is(1));
assertThat(xbEncodedSystem.getContactArray(0).isSetResponsibleParty(), is(true));
checkResponsibleParty(p1, xbEncodedSystem.getContactArray(0).getResponsibleParty());
}
use of net.opengis.sensorML.x101.SensorMLDocument in project arctic-sea by 52North.
the class SensorMLEncoderV101Test method should_merge_and_encode_two_same_contact_person_only_once.
@Test
public void should_merge_and_encode_two_same_contact_person_only_once() throws EncodingException {
final SensorML sensorML = new SensorML();
final System system = new System();
sensorML.addMember(system);
final SmlPerson p1 = createPerson("1");
system.addContact(p1);
final SensorMLDocument xbSensorML = SensorMLDocument.Factory.newInstance();
final SystemType xbSystem = SystemType.Factory.newInstance();
final Person xbP1 = xbSystem.addNewContact().addNewPerson();
setPersonValues(p1, xbP1);
final XmlObject xbProcess = xbSensorML.addNewSensorML().addNewMember().addNewProcess().set(xbSystem);
XmlHelper.substituteElement(xbProcess, xbSystem);
xbSensorML.getSensorML().setVersion("1.0.1");
sensorML.setXml(xbSensorML.xmlText());
final SystemType xbEncodedSystem = encodeSystem(sensorML);
assertThat(xbEncodedSystem.sizeOfContactArray(), is(1));
assertThat(xbEncodedSystem.getContactArray(0).isSetPerson(), is(true));
checkPerson(p1, xbEncodedSystem.getContactArray(0).getPerson());
}
Aggregations