Search in sources :

Example 1 with ContactType

use of eu.europa.ec.inspire.schemas.base2.x20.ContactType in project arctic-sea by 52North.

the class RelatedPartyTypeDecoder method parseContact.

private Contact parseContact(RelatedPartyType rpt) throws DecodingException {
    ContactType ct = rpt.getContact().getContact();
    Contact contact = new Contact();
    contact.setAddress(parseAddress(ct));
    contact.setContactInstructions(parseContactInstructions(ct));
    contact.setElectronicMailAddress(parseElectronicMailAddress(ct));
    contact.setTelephoneFacsimile(parseTelephoneFacsimile(ct));
    contact.setTelephoneVoice(parseTelephoneVoice(ct));
    contact.setWebsite(parseWebsite(ct));
    return contact;
}
Also used : ContactType(eu.europa.ec.inspire.schemas.base2.x20.ContactType) Contact(org.n52.shetland.inspire.base2.Contact)

Example 2 with ContactType

use of eu.europa.ec.inspire.schemas.base2.x20.ContactType in project arctic-sea by 52North.

the class RelatedPartyTypeEncoder method createContact.

private ContactType createContact(Contact contact) {
    ContactType ct = ContactType.Factory.newInstance();
    ct.addNewAddress().setNil();
    if (contact.getAddress().isNil() && contact.getAddress().getNilReason().isPresent()) {
        ct.getAddress().setNilReason(contact.getAddress().getNilReason().get());
    }
    ct.addNewContactInstructions();
    if (contact.getElectronicMailAddress().isPresent()) {
        ct.addNewElectronicMailAddress().setStringValue(contact.getElectronicMailAddress().get());
    } else if (contact.getElectronicMailAddress().isNil()) {
        ct.addNewElectronicMailAddress().setNil();
        if (contact.getElectronicMailAddress().getNilReason().isPresent()) {
            ct.getElectronicMailAddress().setNilReason(contact.getElectronicMailAddress().getNilReason().get());
        }
    }
    if (contact.getTelephoneFacsimile().isPresent()) {
        for (Nillable<String> telephoneFacsimile : contact.getTelephoneFacsimile().get()) {
            if (telephoneFacsimile.isPresent()) {
                ct.addNewTelephoneFacsimile().setStringValue(telephoneFacsimile.get());
            }
        }
    } else if (contact.getTelephoneFacsimile().isNil()) {
        TelephoneFacsimile tf = ct.addNewTelephoneFacsimile();
        tf.setNil();
        if (contact.getTelephoneFacsimile().getNilReason().isPresent()) {
            tf.setNilReason(contact.getTelephoneFacsimile().getNilReason().get());
        }
    }
    if (contact.getTelephoneVoice().isPresent()) {
        for (Nillable<String> telephoneVoice : contact.getTelephoneVoice().get()) {
            if (telephoneVoice.isPresent()) {
                ct.addNewTelephoneVoice().setStringValue(telephoneVoice.get());
            }
        }
    } else if (contact.getTelephoneVoice().isNil()) {
        TelephoneVoice tv = ct.addNewTelephoneVoice();
        tv.setNil();
        if (contact.getTelephoneVoice().getNilReason().isPresent()) {
            tv.setNilReason(contact.getTelephoneVoice().getNilReason().get());
        }
    }
    if (contact.getWebsite().isPresent()) {
        ct.addNewWebsite().setStringValue(contact.getWebsite().get());
    } else if (contact.getWebsite().isNil()) {
        Website w = ct.addNewWebsite();
        w.setNil();
        if (contact.getWebsite().getNilReason().isPresent()) {
            w.setNilReason(contact.getWebsite().getNilReason().get());
        }
    }
    return ct;
}
Also used : TelephoneFacsimile(eu.europa.ec.inspire.schemas.base2.x20.ContactType.TelephoneFacsimile) ContactType(eu.europa.ec.inspire.schemas.base2.x20.ContactType) TelephoneVoice(eu.europa.ec.inspire.schemas.base2.x20.ContactType.TelephoneVoice) Website(eu.europa.ec.inspire.schemas.base2.x20.ContactType.Website)

Aggregations

ContactType (eu.europa.ec.inspire.schemas.base2.x20.ContactType)2 TelephoneFacsimile (eu.europa.ec.inspire.schemas.base2.x20.ContactType.TelephoneFacsimile)1 TelephoneVoice (eu.europa.ec.inspire.schemas.base2.x20.ContactType.TelephoneVoice)1 Website (eu.europa.ec.inspire.schemas.base2.x20.ContactType.Website)1 Contact (org.n52.shetland.inspire.base2.Contact)1