Search in sources :

Example 21 with AbstractProcess

use of org.n52.shetland.ogc.sensorML.AbstractProcess in project arctic-sea by 52North.

the class SensorMLDecoderV101Test method should_decode_contact_from_sml.

@Test
public void should_decode_contact_from_sml() throws DecodingException {
    String role1 = "role1";
    String role2 = "role2";
    String orgName = "orgName";
    String individualName = "individualName";
    String posName = "posName";
    String contactInstructions = "contactInstructions";
    String hoursOfService = "hoursOfService";
    String adminArea = "adminArea";
    String city = "city";
    String country = "country";
    String email = "email";
    String postalCode = "postalCode";
    String deliveryPoint1 = "deliveryPoint1";
    String deliveryPoint2 = "deliveryPoint2";
    String onlineResource1 = "onlineResource1";
    String onlineResource2 = "onlineResource2";
    String phoneVoice1 = "phoneVoice1";
    String phoneVoice2 = "phoneVoice2";
    String phoneFax1 = "phoneFax1";
    String phoneFax2 = "phoneFax2";
    String affiliation = "affiliation";
    String name = "name";
    String phoneNumber = "phoneNumber";
    String surname = "surname";
    String userID = "userID";
    SensorMLDocument xbSmlDoc = getSensorMLDoc();
    SystemType xbSystem = (SystemType) xbSmlDoc.getSensorML().addNewMember().addNewProcess().substitute(SensorMLConstants.SYSTEM_QNAME, SystemType.type);
    Contact xbContact = xbSystem.addNewContact();
    ContactList xbContactList = xbContact.addNewContactList();
    // responsible party
    ContactList.Member xbMember1 = xbContactList.addNewMember();
    xbMember1.setRole(role1);
    ResponsibleParty xbRespPart = xbMember1.addNewResponsibleParty();
    xbRespPart.setOrganizationName(orgName);
    xbRespPart.setIndividualName(individualName);
    xbRespPart.setPositionName(posName);
    ContactInfo xbContactInfo = xbRespPart.addNewContactInfo();
    xbContactInfo.setContactInstructions(contactInstructions);
    xbContactInfo.setHoursOfService(hoursOfService);
    ContactInfo.Address xbAddress = xbContactInfo.addNewAddress();
    xbAddress.setAdministrativeArea(adminArea);
    xbAddress.setCity(city);
    xbAddress.setCountry(country);
    xbAddress.setElectronicMailAddress(email);
    xbAddress.setPostalCode(postalCode);
    xbAddress.addDeliveryPoint(deliveryPoint1);
    xbAddress.addDeliveryPoint(deliveryPoint2);
    xbContactInfo.addNewOnlineResource().setHref(onlineResource1);
    xbContactInfo.addNewOnlineResource().setHref(onlineResource2);
    ContactInfo.Phone phone = xbContactInfo.addNewPhone();
    phone.addVoice(phoneVoice1);
    phone.addVoice(phoneVoice2);
    phone.addFacsimile(phoneFax1);
    phone.addFacsimile(phoneFax2);
    // person
    ContactList.Member xbMember2 = xbContactList.addNewMember();
    xbMember2.setRole(role2);
    Person xbPerson = xbMember2.addNewPerson();
    xbPerson.setAffiliation(affiliation);
    xbPerson.setEmail(email);
    xbPerson.setName(name);
    xbPerson.setPhoneNumber(phoneNumber);
    xbPerson.setSurname(surname);
    xbPerson.setUserID(userID);
    AbstractProcess absProcess = decodeAbstractProcess(xbSmlDoc);
    assertThat(absProcess.getContact(), notNullValue());
    assertThat(absProcess.getContact().size(), is(1));
    assertThat(absProcess.getContact().get(0), instanceOf(SmlContactList.class));
    SmlContactList smlContactList = (SmlContactList) absProcess.getContact().get(0);
    assertThat(smlContactList.getMembers(), notNullValue());
    assertThat(smlContactList.getMembers().size(), is(2));
    assertThat(smlContactList.getMembers().get(0).getRole(), is(role1));
    assertThat(smlContactList.getMembers().get(0), instanceOf(SmlResponsibleParty.class));
    SmlResponsibleParty smlRespParty = (SmlResponsibleParty) smlContactList.getMembers().get(0);
    assertThat(smlRespParty.getAdministrativeArea(), is(adminArea));
    assertThat(smlRespParty.getCity(), is(city));
    assertThat(smlRespParty.getContactInstructions(), is(contactInstructions));
    assertThat(smlRespParty.getCountry(), is(country));
    assertThat(smlRespParty.getDeliveryPoint().size(), is(2));
    assertThat(smlRespParty.getDeliveryPoint().get(0), is(deliveryPoint1));
    assertThat(smlRespParty.getDeliveryPoint().get(1), is(deliveryPoint2));
    assertThat(smlRespParty.getEmail(), is(email));
    assertThat(smlRespParty.getHoursOfService(), is(hoursOfService));
    assertThat(smlRespParty.getIndividualName(), is(individualName));
    assertThat(smlRespParty.getOnlineResources().size(), is(2));
    assertThat(smlRespParty.getOnlineResources().get(0), is(onlineResource1));
    assertThat(smlRespParty.getOnlineResources().get(1), is(onlineResource2));
    assertThat(smlRespParty.getOrganizationName(), is(orgName));
    assertThat(smlRespParty.getPhoneFax().size(), is(2));
    assertThat(smlRespParty.getPhoneFax().get(0), is(phoneFax1));
    assertThat(smlRespParty.getPhoneFax().get(1), is(phoneFax2));
    assertThat(smlRespParty.getPhoneVoice().size(), is(2));
    assertThat(smlRespParty.getPhoneVoice().get(0), is(phoneVoice1));
    assertThat(smlRespParty.getPhoneVoice().get(1), is(phoneVoice2));
    assertThat(smlRespParty.getPositionName(), is(posName));
    assertThat(smlRespParty.getPostalCode(), is(postalCode));
    assertThat(smlContactList.getMembers().get(1).getRole(), is(role2));
    assertThat(smlContactList.getMembers().get(1), instanceOf(SmlPerson.class));
    SmlPerson smlPerson = (SmlPerson) smlContactList.getMembers().get(1);
    assertThat(smlPerson.getAffiliation(), is(affiliation));
    assertThat(smlPerson.getEmail(), is(email));
    assertThat(smlPerson.getName(), is(name));
    assertThat(smlPerson.getPhoneNumber(), is(phoneNumber));
    assertThat(smlPerson.getSurname(), is(surname));
    assertThat(smlPerson.getUserID(), is(userID));
}
Also used : SmlResponsibleParty(org.n52.shetland.ogc.sensorML.SmlResponsibleParty) AbstractProcess(org.n52.shetland.ogc.sensorML.AbstractProcess) SystemType(net.opengis.sensorML.x101.SystemType) ContactList(net.opengis.sensorML.x101.ContactListDocument.ContactList) SmlContactList(org.n52.shetland.ogc.sensorML.SmlContactList) SmlResponsibleParty(org.n52.shetland.ogc.sensorML.SmlResponsibleParty) ResponsibleParty(net.opengis.sensorML.x101.ResponsiblePartyDocument.ResponsibleParty) Contact(net.opengis.sensorML.x101.ContactDocument.Contact) SensorMLDocument(net.opengis.sensorML.x101.SensorMLDocument) SmlContactList(org.n52.shetland.ogc.sensorML.SmlContactList) ContactInfo(net.opengis.sensorML.x101.ContactInfoDocument.ContactInfo) SmlPerson(org.n52.shetland.ogc.sensorML.SmlPerson) Person(net.opengis.sensorML.x101.PersonDocument.Person) SmlPerson(org.n52.shetland.ogc.sensorML.SmlPerson) Test(org.junit.Test)

Example 22 with AbstractProcess

use of org.n52.shetland.ogc.sensorML.AbstractProcess in project arctic-sea by 52North.

the class SensorMLDecoderV101Test method should_set_identifier_by_identifier_prefix_and_suffix.

@Test
public void should_set_identifier_by_identifier_prefix_and_suffix() throws DecodingException {
    SensorMLDocument xbSmlDoc = getSensorMLDoc();
    SystemType xbSystem = (SystemType) xbSmlDoc.getSensorML().addNewMember().addNewProcess().substitute(SensorMLConstants.SYSTEM_QNAME, SystemType.type);
    IdentifierList xbIdentifierList = xbSystem.addNewIdentification().addNewIdentifierList();
    String definiton = OGCConstants.URN_UNIQUE_IDENTIFIER_START + "anything" + OGCConstants.URN_UNIQUE_IDENTIFIER_END;
    addIdentifier(xbIdentifierList, "any name", definiton, TEST_ID_1);
    addIdentifier(xbIdentifierList, "any other name", null, TEST_ID_2);
    AbstractProcess absProcess = decodeAbstractProcess(xbSmlDoc);
    assertThat(absProcess.getIdentifier(), is(TEST_ID_1));
    assertThat(absProcess.getIdentifications().size(), is(2));
}
Also used : SensorMLDocument(net.opengis.sensorML.x101.SensorMLDocument) AbstractProcess(org.n52.shetland.ogc.sensorML.AbstractProcess) SystemType(net.opengis.sensorML.x101.SystemType) IdentifierList(net.opengis.sensorML.x101.IdentificationDocument.Identification.IdentifierList) Test(org.junit.Test)

Example 23 with AbstractProcess

use of org.n52.shetland.ogc.sensorML.AbstractProcess 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)

Example 24 with AbstractProcess

use of org.n52.shetland.ogc.sensorML.AbstractProcess 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();
    }
}
Also used : ProcessModel(org.n52.shetland.ogc.sensorML.ProcessModel) ComponentType(net.opengis.sensorML.x101.ComponentType) AbstractDataComponentType(net.opengis.swe.x101.AbstractDataComponentType) ComponentDocument(net.opengis.sensorML.x101.ComponentDocument) SystemType(net.opengis.sensorML.x101.SystemType) ProcessModelDocument(net.opengis.sensorML.x101.ProcessModelDocument) System(org.n52.shetland.ogc.sensorML.System) SystemDocument(net.opengis.sensorML.x101.SystemDocument) SmlComponent(org.n52.shetland.ogc.sensorML.elements.SmlComponent) Component(net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList.Component) SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) ProcessModelType(net.opengis.sensorML.x101.ProcessModelType)

Aggregations

AbstractProcess (org.n52.shetland.ogc.sensorML.AbstractProcess)15 SystemType (net.opengis.sensorML.x101.SystemType)14 SensorMLDocument (net.opengis.sensorML.x101.SensorMLDocument)12 Test (org.junit.Test)10 XmlObject (org.apache.xmlbeans.XmlObject)6 SmlComponent (org.n52.shetland.ogc.sensorML.elements.SmlComponent)6 SweAbstractDataComponent (org.n52.shetland.ogc.swe.SweAbstractDataComponent)6 Capabilities (net.opengis.sensorML.x101.CapabilitiesDocument.Capabilities)5 Component (net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList.Component)4 IdentifierList (net.opengis.sensorML.x101.IdentificationDocument.Identification.IdentifierList)4 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)4 ComponentType (net.opengis.sensorML.x101.ComponentType)3 AbstractSensorML (org.n52.shetland.ogc.sensorML.AbstractSensorML)3 SensorML (org.n52.shetland.ogc.sensorML.SensorML)3 System (org.n52.shetland.ogc.sensorML.System)3 DecodingException (org.n52.svalbard.decode.exception.DecodingException)3 AbstractProcessType (net.opengis.sensorML.x101.AbstractProcessType)2 ComponentList (net.opengis.sensorML.x101.ComponentsDocument.Components.ComponentList)2 ContactList (net.opengis.sensorML.x101.ContactListDocument.ContactList)2 ProcessModelType (net.opengis.sensorML.x101.ProcessModelType)2