Search in sources :

Example 1 with DocumentCitationType

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

the class DocumentCitationTypeEncoder method encode.

@Override
public XmlObject encode(DocumentCitation documentCitation, EncodingContext context) throws EncodingException {
    DocumentCitationType dct = DocumentCitationType.Factory.newInstance(getXmlOptions());
    if (documentCitation.isSetDate()) {
        dct.addNewDate().addNewCIDate().addNewDate().setDateTime(documentCitation.getDate().get().toGregorianCalendar());
    }
    if (documentCitation.isSetName()) {
        dct.setName2(documentCitation.getFirstName().getValue());
    }
    if (documentCitation.isSetLinks()) {
        for (Nillable<String> link : documentCitation.getLinks()) {
            if (link.isPresent()) {
                dct.addNewLink().setStringValue(link.get());
            } else {
                Link l = dct.addNewLink();
                l.setNil();
                if (link.getNilReason().isPresent()) {
                    l.setNilReason(link.getNilReason().get());
                }
            }
        }
    }
    return dct;
}
Also used : DocumentCitationType(eu.europa.ec.inspire.schemas.base2.x20.DocumentCitationType) Link(eu.europa.ec.inspire.schemas.base2.x20.DocumentCitationType.Link)

Example 2 with DocumentCitationType

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

the class DocumentCitationTypeDecoder method decode.

@Override
public DocumentCitation decode(XmlObject xmlObject) throws DecodingException {
    if (xmlObject instanceof DocumentCitationType) {
        DocumentCitation documentCitation = new DocumentCitation();
        DocumentCitationType dct = (DocumentCitationType) xmlObject;
        documentCitation.setDescription(dct.getDescription().getStringValue());
        if (dct.isNilDate()) {
            if (dct.getDate().isSetNilReason()) {
                documentCitation.setDate(Nillable.<DateTime>nil(dct.getDate().getNilReason().toString()));
            }
        } else {
            documentCitation.setDate(new DateTime(dct.getDate().getCIDate().getDate().getDate().getTime()));
        }
        if (dct.getLinkArray() != null) {
            for (Link link : dct.getLinkArray()) {
                if (link.isNil() && link.isSetNilReason()) {
                    documentCitation.addLink(Nillable.<String>nil(link.getNilReason().toString()));
                } else {
                    documentCitation.addLink(link.getStringValue());
                }
            }
        }
        return documentCitation;
    }
    throw new UnsupportedDecoderInputException(this, xmlObject);
}
Also used : DocumentCitationType(eu.europa.ec.inspire.schemas.base2.x20.DocumentCitationType) DocumentCitation(org.n52.shetland.inspire.base2.DocumentCitation) UnsupportedDecoderInputException(org.n52.svalbard.decode.exception.UnsupportedDecoderInputException) DateTime(org.joda.time.DateTime) Link(eu.europa.ec.inspire.schemas.base2.x20.DocumentCitationType.Link)

Aggregations

DocumentCitationType (eu.europa.ec.inspire.schemas.base2.x20.DocumentCitationType)2 Link (eu.europa.ec.inspire.schemas.base2.x20.DocumentCitationType.Link)2 DateTime (org.joda.time.DateTime)1 DocumentCitation (org.n52.shetland.inspire.base2.DocumentCitation)1 UnsupportedDecoderInputException (org.n52.svalbard.decode.exception.UnsupportedDecoderInputException)1