Search in sources :

Example 1 with ResponsibleParty

use of net.opengis.sensorML.x101.ResponsiblePartyDocument.ResponsibleParty 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 ResponsibleParty

use of net.opengis.sensorML.x101.ResponsiblePartyDocument.ResponsibleParty in project arctic-sea by 52North.

the class SensorMLEncoderV101Test method checkResponsibleParty.

private void checkResponsibleParty(final SmlResponsibleParty responsibleParty, final ResponsibleParty xbResponsibleParty) {
    assertThat(xbResponsibleParty.getIndividualName(), is(responsibleParty.getIndividualName()));
    assertThat(xbResponsibleParty.getOrganizationName(), is(responsibleParty.getOrganizationName()));
    assertThat(xbResponsibleParty.getPositionName(), is(responsibleParty.getPositionName()));
    final ContactInfo xbContactInfo = xbResponsibleParty.getContactInfo();
    assertThat(xbContactInfo.getContactInstructions(), is(responsibleParty.getContactInstructions()));
    assertThat(xbContactInfo.getHoursOfService(), is(responsibleParty.getHoursOfService()));
    assertThat(xbContactInfo.getOnlineResourceArray(0).getHref(), is(responsibleParty.getOnlineResources().get(0)));
    final Phone xbPhone = xbContactInfo.getPhone();
    assertThat(xbPhone.getVoiceArray(0), is(responsibleParty.getPhoneVoice().get(0)));
    assertThat(xbPhone.getFacsimileArray(0), is(responsibleParty.getPhoneFax().get(0)));
    final Address xbAddress = xbContactInfo.getAddress();
    assertThat(xbAddress.getAdministrativeArea(), is(responsibleParty.getAdministrativeArea()));
    assertThat(xbAddress.getCity(), is(responsibleParty.getCity()));
    assertThat(xbAddress.getCountry(), is(responsibleParty.getCountry()));
    assertThat(xbAddress.getElectronicMailAddress(), is(responsibleParty.getEmail()));
    assertThat(xbAddress.getDeliveryPointArray(0), is(responsibleParty.getDeliveryPoint().get(0)));
    assertThat(xbAddress.getPostalCode(), is(responsibleParty.getPostalCode()));
}
Also used : Address(net.opengis.sensorML.x101.ContactInfoDocument.ContactInfo.Address) Phone(net.opengis.sensorML.x101.ContactInfoDocument.ContactInfo.Phone) ContactInfo(net.opengis.sensorML.x101.ContactInfoDocument.ContactInfo)

Example 3 with ResponsibleParty

use of net.opengis.sensorML.x101.ResponsiblePartyDocument.ResponsibleParty in project arctic-sea by 52North.

the class SensorMLEncoderV101Test method should_encode_single_contact_responsibleParty.

@Test
public void should_encode_single_contact_responsibleParty() throws EncodingException {
    final SensorML sensorML = new SensorML();
    final System system = new System();
    sensorML.addMember(system);
    final SmlResponsibleParty responsibleParty = createResponsibleParty("");
    system.addContact(responsibleParty);
    final SystemType xbSystem = encodeSystem(sensorML);
    assertThat(xbSystem.sizeOfContactArray(), is(1));
    assertThat(xbSystem.getContactArray(0).getContactList().getMemberArray(0).isSetResponsibleParty(), is(true));
    final ResponsibleParty xbResponsibleParty = xbSystem.getContactArray(0).getContactList().getMemberArray(0).getResponsibleParty();
    checkResponsibleParty(responsibleParty, xbResponsibleParty);
}
Also used : SmlResponsibleParty(org.n52.shetland.ogc.sensorML.SmlResponsibleParty) SystemType(net.opengis.sensorML.x101.SystemType) SmlResponsibleParty(org.n52.shetland.ogc.sensorML.SmlResponsibleParty) ResponsibleParty(net.opengis.sensorML.x101.ResponsiblePartyDocument.ResponsibleParty) SensorML(org.n52.shetland.ogc.sensorML.SensorML) System(org.n52.shetland.ogc.sensorML.System) Test(org.junit.Test)

Example 4 with ResponsibleParty

use of net.opengis.sensorML.x101.ResponsiblePartyDocument.ResponsibleParty 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 5 with ResponsibleParty

use of net.opengis.sensorML.x101.ResponsiblePartyDocument.ResponsibleParty 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());
}
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) SmlResponsibleParty(org.n52.shetland.ogc.sensorML.SmlResponsibleParty) ResponsibleParty(net.opengis.sensorML.x101.ResponsiblePartyDocument.ResponsibleParty) SensorML(org.n52.shetland.ogc.sensorML.SensorML) System(org.n52.shetland.ogc.sensorML.System) Test(org.junit.Test)

Aggregations

ResponsibleParty (net.opengis.sensorML.x101.ResponsiblePartyDocument.ResponsibleParty)5 SmlResponsibleParty (org.n52.shetland.ogc.sensorML.SmlResponsibleParty)5 SystemType (net.opengis.sensorML.x101.SystemType)4 Test (org.junit.Test)4 ContactInfo (net.opengis.sensorML.x101.ContactInfoDocument.ContactInfo)3 ContactList (net.opengis.sensorML.x101.ContactListDocument.ContactList)3 Person (net.opengis.sensorML.x101.PersonDocument.Person)3 SensorMLDocument (net.opengis.sensorML.x101.SensorMLDocument)3 SensorML (org.n52.shetland.ogc.sensorML.SensorML)3 SmlPerson (org.n52.shetland.ogc.sensorML.SmlPerson)3 System (org.n52.shetland.ogc.sensorML.System)3 Contact (net.opengis.sensorML.x101.ContactDocument.Contact)2 Address (net.opengis.sensorML.x101.ContactInfoDocument.ContactInfo.Address)2 Phone (net.opengis.sensorML.x101.ContactInfoDocument.ContactInfo.Phone)2 XmlObject (org.apache.xmlbeans.XmlObject)2 SmlContactList (org.n52.shetland.ogc.sensorML.SmlContactList)2 Member (net.opengis.sensorML.x101.ContactListDocument.ContactList.Member)1 AbstractProcess (org.n52.shetland.ogc.sensorML.AbstractProcess)1 SmlContact (org.n52.shetland.ogc.sensorML.SmlContact)1