Search in sources :

Example 1 with Member

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

the class SensorMLEncoderv101 method mergeContacts.

@SuppressWarnings("unused")
private Contact[] mergeContacts(final Contact[] contacts, final ContactList additionalContactsList) {
    final Set<Person> mergedPersons = Sets.newHashSet();
    final Set<ResponsibleParty> mergedResponsibleParties = Sets.newHashSet();
    for (final Contact contact : contacts) {
        if (isContactListSetAndContainingElements(contact)) {
            for (final net.opengis.sensorML.x101.ContactListDocument.ContactList.Member member : contact.getContactList().getMemberArray()) {
                if (member.isSetPerson()) {
                    mergedPersons.add(member.getPerson());
                } else if (member.isSetResponsibleParty()) {
                    mergedResponsibleParties.add(member.getResponsibleParty());
                }
            }
        } else if (contact.isSetPerson()) {
            mergedPersons.add(contact.getPerson());
        } else if (contact.isSetResponsibleParty()) {
            mergedResponsibleParties.add(contact.getResponsibleParty());
        }
    }
    for (final net.opengis.sensorML.x101.ContactListDocument.ContactList.Member member : additionalContactsList.getMemberArray()) {
        if (member.isSetPerson() && !isContained(member.getPerson(), mergedPersons)) {
            mergedPersons.add(member.getPerson());
        } else if (member.isSetResponsibleParty() && !isContained(member.getResponsibleParty(), mergedResponsibleParties)) {
            mergedResponsibleParties.add(member.getResponsibleParty());
        }
    }
    final Contact newContact = Contact.Factory.newInstance();
    final ContactList newContactList = ContactList.Factory.newInstance();
    mergedResponsibleParties.forEach(responsibleParty -> newContactList.addNewMember().addNewResponsibleParty().set(responsibleParty));
    mergedPersons.forEach(person -> newContactList.addNewMember().addNewPerson().set(person));
    if (newContactList.sizeOfMemberArray() == 1) {
        if (newContactList.getMemberArray(0).isSetPerson()) {
            newContact.addNewPerson().set(newContactList.getMemberArray(0).getPerson());
        } else if (newContactList.getMemberArray(0).isSetResponsibleParty()) {
            newContact.addNewResponsibleParty().set(newContactList.getMemberArray(0).getResponsibleParty());
        }
    } else {
        newContact.addNewContactList().set(newContactList);
    }
    final Contact[] result = { newContact };
    return result;
}
Also used : ContactList(net.opengis.sensorML.x101.ContactListDocument.ContactList) SmlContactList(org.n52.shetland.ogc.sensorML.SmlContactList) ResponsibleParty(net.opengis.sensorML.x101.ResponsiblePartyDocument.ResponsibleParty) SmlResponsibleParty(org.n52.shetland.ogc.sensorML.SmlResponsibleParty) SmlPerson(org.n52.shetland.ogc.sensorML.SmlPerson) Person(net.opengis.sensorML.x101.PersonDocument.Person) Contact(net.opengis.sensorML.x101.ContactDocument.Contact) SmlContact(org.n52.shetland.ogc.sensorML.SmlContact)

Example 2 with Member

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

the class SensorMLEncoderv101 method createContactList.

private ContactList createContactList(final List<SmlContact> contacts) {
    final ContactList xbContacts = ContactList.Factory.newInstance();
    contacts.forEach(smlContact -> {
        if (smlContact.isSetHref()) {
            ContactList.Member member = xbContacts.addNewMember();
            member.setHref(smlContact.getHref());
            if (smlContact.isSetTitle()) {
                member.setTitle(smlContact.getTitle());
            }
            if (smlContact.isSetRole()) {
                member.setRole(smlContact.getRole());
            }
        } else if (smlContact instanceof SmlPerson) {
            ContactList.Member member = xbContacts.addNewMember();
            member.addNewPerson().set(createPerson((SmlPerson) smlContact));
            if (smlContact.isSetRole()) {
                member.setRole(smlContact.getRole());
            }
        } else if (smlContact instanceof SmlResponsibleParty) {
            ContactList.Member member = xbContacts.addNewMember();
            member.addNewResponsibleParty().set(createResponsibleParty((SmlResponsibleParty) smlContact));
            if (smlContact.isSetRole()) {
                member.setRole(smlContact.getRole());
            }
        } else if (smlContact instanceof SmlContactList) {
            SmlContactList contactList = (SmlContactList) smlContact;
            ContactList innerContactList = createContactList(contactList.getMembers());
            int innerContactLength = innerContactList.getMemberArray().length;
            for (int i = 0; i < innerContactLength; i++) {
                xbContacts.addNewMember().set(innerContactList.getMemberArray(i));
            }
        }
    });
    return xbContacts;
}
Also used : SmlResponsibleParty(org.n52.shetland.ogc.sensorML.SmlResponsibleParty) SmlContactList(org.n52.shetland.ogc.sensorML.SmlContactList) ContactList(net.opengis.sensorML.x101.ContactListDocument.ContactList) SmlContactList(org.n52.shetland.ogc.sensorML.SmlContactList) Member(net.opengis.sensorML.x101.SensorMLDocument.SensorML.Member) SmlPerson(org.n52.shetland.ogc.sensorML.SmlPerson)

Example 3 with Member

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

the class SensorMLEncoderv101 method createDocumentationList.

/**
 * Create a XML DocuemntList from SOS documentList
 *
 * @param sosDocumentationList
 *            SOS documentList
 *
 * @return XML DocumentList element
 */
private DocumentList createDocumentationList(final SmlDocumentationList sosDocumentationList) {
    final DocumentList documentList = DocumentList.Factory.newInstance();
    if (sosDocumentationList.isSetDescription()) {
        documentList.addNewDescription().setStringValue(sosDocumentationList.getDescription());
    }
    if (sosDocumentationList.isSetMembers()) {
        sosDocumentationList.getMember().forEach(sosMember -> {
            net.opengis.sensorML.x101.DocumentListDocument.DocumentList.Member member = documentList.addNewMember();
            member.setName(sosMember.getName());
            member.setDocument(createDocument(sosMember.getDocumentation()));
        });
    }
    return documentList;
}
Also used : DocumentList(net.opengis.sensorML.x101.DocumentListDocument.DocumentList)

Example 4 with Member

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

the class SensorMLEncoderV101Test method should_encode_multiple_contacts_in_contactList.

@Test
public void should_encode_multiple_contacts_in_contactList() throws EncodingException {
    final SensorML sensorML = new SensorML();
    final System system = new System();
    sensorML.addMember(system);
    final SmlPerson contact1 = createPerson("1");
    final SmlPerson contact2 = createPerson("2");
    system.addContact(contact1);
    system.addContact(contact2);
    final SystemType xbSystem = encodeSystem(sensorML);
    assertThat(xbSystem.sizeOfContactArray(), is(1));
    assertThat(xbSystem.getContactArray(0).isSetContactList(), is(true));
    final ContactList xbContactList = xbSystem.getContactArray(0).getContactList();
    assertThat(xbContactList.sizeOfMemberArray(), is(2));
    final Member member = xbContactList.getMemberArray(0);
    final Member member2 = xbContactList.getMemberArray(1);
    assertThat(member.isSetPerson(), is(true));
    assertThat(member2.isSetPerson(), is(true));
    if (member.getPerson().getName().equals(contact1.getName())) {
        checkPerson(contact1, member.getPerson());
        checkPerson(contact2, member2.getPerson());
    } else {
        checkPerson(contact1, member2.getPerson());
        checkPerson(contact2, member.getPerson());
    }
}
Also used : SystemType(net.opengis.sensorML.x101.SystemType) ContactList(net.opengis.sensorML.x101.ContactListDocument.ContactList) SensorML(org.n52.shetland.ogc.sensorML.SensorML) 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 5 with Member

use of net.opengis.sensorML.x101.SensorMLDocument.SensorML.Member 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());
}
Also used : AbstractProcessType(net.opengis.sensorML.x101.AbstractProcessType) SensorMLDocument(net.opengis.sensorML.x101.SensorMLDocument) Member(net.opengis.sensorML.x101.SensorMLDocument.SensorML.Member)

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