Search in sources :

Example 6 with Member

use of net.opengis.sensorML.x101.SensorMLDocument.SensorML.Member 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;
}
Also used : AbstractProcessType(net.opengis.sensorML.x101.AbstractProcessType) AbstractComponentType(net.opengis.sensorML.x101.AbstractComponentType) AbstractDerivableComponentType(net.opengis.sensorML.x101.AbstractDerivableComponentType) ComponentType(net.opengis.sensorML.x101.ComponentType) AbstractProcess(org.n52.shetland.ogc.sensorML.AbstractProcess) SystemType(net.opengis.sensorML.x101.SystemType) DecodingException(org.n52.svalbard.decode.exception.DecodingException) SensorML(org.n52.shetland.ogc.sensorML.SensorML) AbstractSensorML(org.n52.shetland.ogc.sensorML.AbstractSensorML) Member(net.opengis.sensorML.x101.SensorMLDocument.SensorML.Member) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 7 with Member

use of net.opengis.sensorML.x101.SensorMLDocument.SensorML.Member in project arctic-sea by 52North.

the class SensorMLDecoderV101 method parseContactListMembers.

private SmlContact parseContactListMembers(final ContactList contactList) {
    SmlContactList smlContactList = new SmlContactList();
    if (contactList.getMemberArray() != null && contactList.getMemberArray().length > 0) {
        for (ContactList.Member member : contactList.getMemberArray()) {
            SmlContact thisSmlContact = null;
            if (member.getPerson() != null) {
                thisSmlContact = parsePerson(member.getPerson());
            } else if (member.getResponsibleParty() != null) {
                thisSmlContact = parseResponsibleParty(member.getResponsibleParty());
            } else if (member.isSetHref()) {
                thisSmlContact = new SmlReferencedContact();
                thisSmlContact.setHref(member.getHref());
                if (member.isSetTitle()) {
                    thisSmlContact.setTitle(member.getTitle());
                }
            }
            if (thisSmlContact != null) {
                if (member.getRole() != null) {
                    thisSmlContact.setRole(member.getRole());
                }
                smlContactList.addMember(thisSmlContact);
            }
        }
    }
    return smlContactList;
}
Also used : SmlReferencedContact(org.n52.shetland.ogc.sensorML.SmlReferencedContact) SmlContactList(org.n52.shetland.ogc.sensorML.SmlContactList) ContactList(net.opengis.sensorML.x101.ContactListDocument.ContactList) SmlContactList(org.n52.shetland.ogc.sensorML.SmlContactList) SmlContact(org.n52.shetland.ogc.sensorML.SmlContact)

Example 8 with Member

use of net.opengis.sensorML.x101.SensorMLDocument.SensorML.Member 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");
    }
}
Also used : SmlResponsibleParty(org.n52.shetland.ogc.sensorML.SmlResponsibleParty) SensorMLDocument(net.opengis.sensorML.x101.SensorMLDocument) SystemType(net.opengis.sensorML.x101.SystemType) XmlObject(org.apache.xmlbeans.XmlObject) ContactList(net.opengis.sensorML.x101.ContactListDocument.ContactList) SmlResponsibleParty(org.n52.shetland.ogc.sensorML.SmlResponsibleParty) ResponsibleParty(net.opengis.sensorML.x101.ResponsiblePartyDocument.ResponsibleParty) SensorML(org.n52.shetland.ogc.sensorML.SensorML) SmlPerson(org.n52.shetland.ogc.sensorML.SmlPerson) Person(net.opengis.sensorML.x101.PersonDocument.Person) Member(net.opengis.sensorML.x101.ContactListDocument.ContactList.Member) System(org.n52.shetland.ogc.sensorML.System) SmlPerson(org.n52.shetland.ogc.sensorML.SmlPerson) Test(org.junit.Test)

Example 9 with Member

use of net.opengis.sensorML.x101.SensorMLDocument.SensorML.Member 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;
}
Also used : AbstractProcessType(net.opengis.sensorML.x101.AbstractProcessType) EncodingException(org.n52.svalbard.encode.exception.EncodingException) AbstractProcess(org.n52.shetland.ogc.sensorML.AbstractProcess) ComponentList(net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList) SensorML(org.n52.shetland.ogc.sensorML.SensorML) AbstractSensorML(org.n52.shetland.ogc.sensorML.AbstractSensorML) SchemaType(org.apache.xmlbeans.SchemaType) Components(net.opengis.sensorML.x101.ComponentsDocument.Components) SensorMLDocument(net.opengis.sensorML.x101.SensorMLDocument) XmlException(org.apache.xmlbeans.XmlException) XmlObject(org.apache.xmlbeans.XmlObject) SmlComponent(org.n52.shetland.ogc.sensorML.elements.SmlComponent) Component(net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList.Component) SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) Member(net.opengis.sensorML.x101.SensorMLDocument.SensorML.Member) SmlComponent(org.n52.shetland.ogc.sensorML.elements.SmlComponent)

Aggregations

ContactList (net.opengis.sensorML.x101.ContactListDocument.ContactList)5 Member (net.opengis.sensorML.x101.SensorMLDocument.SensorML.Member)4 SensorML (org.n52.shetland.ogc.sensorML.SensorML)4 SmlPerson (org.n52.shetland.ogc.sensorML.SmlPerson)4 AbstractProcessType (net.opengis.sensorML.x101.AbstractProcessType)3 SensorMLDocument (net.opengis.sensorML.x101.SensorMLDocument)3 SystemType (net.opengis.sensorML.x101.SystemType)3 SmlContactList (org.n52.shetland.ogc.sensorML.SmlContactList)3 SmlResponsibleParty (org.n52.shetland.ogc.sensorML.SmlResponsibleParty)3 Member (net.opengis.sensorML.x101.ContactListDocument.ContactList.Member)2 Person (net.opengis.sensorML.x101.PersonDocument.Person)2 ResponsibleParty (net.opengis.sensorML.x101.ResponsiblePartyDocument.ResponsibleParty)2 XmlObject (org.apache.xmlbeans.XmlObject)2 Test (org.junit.Test)2 AbstractProcess (org.n52.shetland.ogc.sensorML.AbstractProcess)2 AbstractSensorML (org.n52.shetland.ogc.sensorML.AbstractSensorML)2 SmlContact (org.n52.shetland.ogc.sensorML.SmlContact)2 System (org.n52.shetland.ogc.sensorML.System)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 AbstractComponentType (net.opengis.sensorML.x101.AbstractComponentType)1