Search in sources :

Example 6 with ResponsibleParty

use of org.opengis.metadata.citation.ResponsibleParty in project sis by apache.

the class NilReasonTest method testNilObjectComparison.

/**
 * Tests the comparison of {@link NilObject} instances.
 */
@Test
public void testNilObjectComparison() {
    final Citation e1 = NilReason.TEMPLATE.createNilObject(Citation.class);
    final Citation e2 = NilReason.MISSING.createNilObject(Citation.class);
    final Citation e3 = NilReason.TEMPLATE.createNilObject(Citation.class);
    assertEquals("NilObject.hashCode()", e1.hashCode(), e3.hashCode());
    assertFalse("NilObject.hashCode()", e1.hashCode() == e2.hashCode());
    assertEquals("NilObject.equals(Object)", e1, e3);
    assertFalse("NilObject.equals(Object)", e1.equals(e2));
    assertInstanceOf("e1", LenientComparable.class, e1);
    final LenientComparable c = (LenientComparable) e1;
    assertTrue(c.equals(e3, ComparisonMode.STRICT));
    assertFalse(c.equals(e2, ComparisonMode.STRICT));
    assertFalse(c.equals(e2, ComparisonMode.BY_CONTRACT));
    assertTrue(c.equals(e2, ComparisonMode.IGNORE_METADATA));
    assertTrue(c.equals(e2, ComparisonMode.APPROXIMATIVE));
    assertTrue(c.equals(e2, ComparisonMode.DEBUG));
    // Following object should alway be different because it does not implement the same interface.
    final ResponsibleParty r1 = NilReason.TEMPLATE.createNilObject(ResponsibleParty.class);
    assertFalse(c.equals(r1, ComparisonMode.STRICT));
    assertFalse(c.equals(r1, ComparisonMode.BY_CONTRACT));
    assertFalse(c.equals(r1, ComparisonMode.IGNORE_METADATA));
    assertFalse(c.equals(r1, ComparisonMode.APPROXIMATIVE));
    assertFalse(c.equals(r1, ComparisonMode.DEBUG));
}
Also used : Citation(org.opengis.metadata.citation.Citation) LenientComparable(org.apache.sis.util.LenientComparable) ResponsibleParty(org.opengis.metadata.citation.ResponsibleParty) Test(org.junit.Test)

Example 7 with ResponsibleParty

use of org.opengis.metadata.citation.ResponsibleParty in project tika by apache.

the class GeographicInformationParser method getMetaDataIdentificationInfo.

private void getMetaDataIdentificationInfo(Metadata metadata, DefaultMetadata defaultMetaData) {
    ArrayList<Identification> identifications = (ArrayList<Identification>) defaultMetaData.getIdentificationInfo();
    for (Identification i : identifications) {
        DefaultDataIdentification defaultDataIdentification = (DefaultDataIdentification) i;
        if (i.getCitation() != null && i.getCitation().getTitle() != null)
            metadata.add("IdentificationInfoCitationTitle ", i.getCitation().getTitle().toString());
        ArrayList<CitationDate> dateArrayList = (ArrayList<CitationDate>) i.getCitation().getDates();
        for (CitationDate d : dateArrayList) {
            if (d.getDateType() != null)
                metadata.add("CitationDate ", d.getDateType().name() + "-->" + d.getDate());
        }
        ArrayList<ResponsibleParty> responsiblePartyArrayList = (ArrayList<ResponsibleParty>) i.getCitation().getCitedResponsibleParties();
        for (ResponsibleParty r : responsiblePartyArrayList) {
            if (r.getRole() != null)
                metadata.add("CitedResponsiblePartyRole ", r.getRole().toString());
            if (r.getIndividualName() != null)
                metadata.add("CitedResponsiblePartyName ", r.getIndividualName().toString());
            if (r.getOrganisationName() != null)
                metadata.add("CitedResponsiblePartyOrganizationName ", r.getOrganisationName().toString());
            if (r.getPositionName() != null)
                metadata.add("CitedResponsiblePartyPositionName ", r.getPositionName().toString());
            if (r.getContactInfo() != null) {
                for (String s : r.getContactInfo().getAddress().getElectronicMailAddresses()) {
                    metadata.add("CitedResponsiblePartyEMail ", s.toString());
                }
            }
        }
        if (i.getAbstract() != null)
            metadata.add("IdentificationInfoAbstract ", i.getAbstract().toString());
        for (Progress p : i.getStatus()) {
            metadata.add("IdentificationInfoStatus ", p.name());
        }
        ArrayList<Format> formatArrayList = (ArrayList<Format>) i.getResourceFormats();
        for (Format f : formatArrayList) {
            if (f.getName() != null)
                metadata.add("ResourceFormatSpecificationAlternativeTitle ", f.getName().toString());
        }
        CheckedHashSet<Locale> localeCheckedHashSet = (CheckedHashSet<Locale>) defaultDataIdentification.getLanguages();
        for (Locale l : localeCheckedHashSet) {
            metadata.add("IdentificationInfoLanguage-->", l.getDisplayLanguage(Locale.ENGLISH));
        }
        CodeListSet<TopicCategory> categoryList = (CodeListSet<TopicCategory>) defaultDataIdentification.getTopicCategories();
        for (TopicCategory t : categoryList) {
            metadata.add("IdentificationInfoTopicCategory-->", t.name());
        }
        ArrayList<Keywords> keywordList = (ArrayList<Keywords>) i.getDescriptiveKeywords();
        int j = 1;
        for (Keywords k : keywordList) {
            j++;
            ArrayList<InternationalString> stringList = (ArrayList<InternationalString>) k.getKeywords();
            for (InternationalString s : stringList) {
                metadata.add("Keywords " + j, s.toString());
            }
            if (k.getType() != null)
                metadata.add("KeywordsType " + j, k.getType().name());
            if (k.getThesaurusName() != null && k.getThesaurusName().getTitle() != null)
                metadata.add("ThesaurusNameTitle " + j, k.getThesaurusName().getTitle().toString());
            if (k.getThesaurusName() != null && k.getThesaurusName().getAlternateTitles() != null)
                metadata.add("ThesaurusNameAlternativeTitle " + j, k.getThesaurusName().getAlternateTitles().toString());
            ArrayList<CitationDate> citationDates = (ArrayList<CitationDate>) k.getThesaurusName().getDates();
            for (CitationDate cd : citationDates) {
                if (cd.getDateType() != null)
                    metadata.add("ThesaurusNameDate ", cd.getDateType().name() + "-->" + cd.getDate());
            }
        }
        ArrayList<DefaultLegalConstraints> constraintList = (ArrayList<DefaultLegalConstraints>) i.getResourceConstraints();
        for (DefaultLegalConstraints c : constraintList) {
            for (Restriction r : c.getAccessConstraints()) {
                metadata.add("AccessContraints ", r.name());
            }
            for (InternationalString s : c.getOtherConstraints()) {
                metadata.add("OtherConstraints ", s.toString());
            }
            for (Restriction r : c.getUseConstraints()) {
                metadata.add("UserConstraints ", r.name());
            }
        }
        Collection<Extent> extentList = ((DefaultDataIdentification) i).getExtents();
        for (Extent e : extentList) {
            ArrayList<GeographicExtent> geoElements = (ArrayList<GeographicExtent>) e.getGeographicElements();
            for (GeographicExtent g : geoElements) {
                if (g instanceof DefaultGeographicDescription) {
                    if (((DefaultGeographicDescription) g).getGeographicIdentifier() != null && ((DefaultGeographicDescription) g).getGeographicIdentifier().getCode() != null)
                        metadata.add("GeographicIdentifierCode ", ((DefaultGeographicDescription) g).getGeographicIdentifier().getCode().toString());
                    if (((DefaultGeographicDescription) g).getGeographicIdentifier() != null && ((DefaultGeographicDescription) g).getGeographicIdentifier().getAuthority() != null && ((DefaultGeographicDescription) g).getGeographicIdentifier().getAuthority().getTitle() != null)
                        metadata.add("GeographicIdentifierAuthorityTitle ", ((DefaultGeographicDescription) g).getGeographicIdentifier().getAuthority().getTitle().toString());
                    for (InternationalString s : ((DefaultGeographicDescription) g).getGeographicIdentifier().getAuthority().getAlternateTitles()) {
                        metadata.add("GeographicIdentifierAuthorityAlternativeTitle ", s.toString());
                    }
                    for (CitationDate cd : ((DefaultGeographicDescription) g).getGeographicIdentifier().getAuthority().getDates()) {
                        if (cd.getDateType() != null && cd.getDate() != null)
                            metadata.add("GeographicIdentifierAuthorityDate ", cd.getDateType().name() + " " + cd.getDate().toString());
                    }
                }
            }
        }
    }
}
Also used : Locale(java.util.Locale) CodeListSet(org.apache.sis.util.collection.CodeListSet) Keywords(org.opengis.metadata.identification.Keywords) GeographicExtent(org.opengis.metadata.extent.GeographicExtent) Extent(org.opengis.metadata.extent.Extent) CheckedArrayList(org.apache.sis.internal.util.CheckedArrayList) ArrayList(java.util.ArrayList) DefaultDataIdentification(org.apache.sis.metadata.iso.identification.DefaultDataIdentification) Identification(org.opengis.metadata.identification.Identification) InternationalString(org.opengis.util.InternationalString) Format(org.opengis.metadata.distribution.Format) DefaultLegalConstraints(org.apache.sis.metadata.iso.constraint.DefaultLegalConstraints) DefaultDataIdentification(org.apache.sis.metadata.iso.identification.DefaultDataIdentification) CitationDate(org.opengis.metadata.citation.CitationDate) Progress(org.opengis.metadata.identification.Progress) TopicCategory(org.opengis.metadata.identification.TopicCategory) ResponsibleParty(org.opengis.metadata.citation.ResponsibleParty) CheckedHashSet(org.apache.sis.internal.util.CheckedHashSet) GeographicExtent(org.opengis.metadata.extent.GeographicExtent) DefaultGeographicDescription(org.apache.sis.metadata.iso.extent.DefaultGeographicDescription) Restriction(org.opengis.metadata.constraint.Restriction) InternationalString(org.opengis.util.InternationalString)

Example 8 with ResponsibleParty

use of org.opengis.metadata.citation.ResponsibleParty in project sis by apache.

the class CodeListMarshallingTest method testISO_URL.

/**
 * Tests marshaling using the ISO URL.
 *
 * @throws JAXBException if an error occurred while marshaling the XML.
 */
@Test
public void testISO_URL() throws JAXBException {
    final String expected = getResponsiblePartyXML("http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/");
    final ResponsibleParty rp = unmarshal(ResponsibleParty.class, expected);
    assertEquals(Role.PRINCIPAL_INVESTIGATOR, rp.getRole());
    final MarshallerPool pool = getMarshallerPool();
    final Marshaller marshaller = pool.acquireMarshaller();
    marshaller.setProperty(XML.METADATA_VERSION, VERSION_2007);
    marshaller.setProperty(XML.SCHEMAS, Collections.singletonMap("gmd", // Intentionally omit trailing '/'.
    "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas"));
    final String actual = marshal(marshaller, rp);
    pool.recycle(marshaller);
    assertXmlEquals(expected, actual, "xmlns:*");
}
Also used : Marshaller(javax.xml.bind.Marshaller) MarshallerPool(org.apache.sis.xml.MarshallerPool) ResponsibleParty(org.opengis.metadata.citation.ResponsibleParty) Test(org.junit.Test)

Example 9 with ResponsibleParty

use of org.opengis.metadata.citation.ResponsibleParty in project sis by apache.

the class DefaultCitationTest method testUnmarshalling.

/**
 * Tests XML unmarshalling for a metadata version.
 * The version is not specified since it should be detected automatically.
 *
 * @param  file  file containing the metadata to unmarshal.
 */
private void testUnmarshalling(final String file) throws JAXBException {
    final DefaultCitation c = unmarshalFile(DefaultCitation.class, file);
    assertTitleEquals("title", "Fight against poverty", c);
    final CitationDate date = getSingleton(c.getDates());
    assertEquals("date", date.getDate(), TestUtilities.date("2015-10-17 00:00:00"));
    assertEquals("dateType", DateType.valueOf("adopted"), date.getDateType());
    assertEquals("presentationForm", PresentationForm.valueOf("physicalObject"), getSingleton(c.getPresentationForms()));
    final Iterator<ResponsibleParty> it = c.getCitedResponsibleParties().iterator();
    final Contact contact = assertResponsibilityEquals(Role.ORIGINATOR, "Maid Marian", it.next());
    assertEquals("Contact instruction", "Send carrier pigeon.", String.valueOf(contact.getContactInstructions()));
    final OnlineResource resource = contact.getOnlineResource();
    assertEquals("Resource name", "IP over Avian Carriers", String.valueOf(resource.getName()));
    assertEquals("Resource description", "High delay, low throughput, and low altitude service.", String.valueOf(resource.getDescription()));
    assertEquals("Resource linkage", "https://tools.ietf.org/html/rfc1149", String.valueOf(resource.getLinkage()));
    assertEquals("Resource function", OnLineFunction.OFFLINE_ACCESS, resource.getFunction());
    // Thanks to xlink:href, the Contact shall be the same instance as above.
    assertSame("contact", contact, assertResponsibilityEquals(Role.valueOf("funder"), "Robin Hood", it.next()));
    assertFalse(it.hasNext());
}
Also used : OnlineResource(org.opengis.metadata.citation.OnlineResource) CitationDate(org.opengis.metadata.citation.CitationDate) ResponsibleParty(org.opengis.metadata.citation.ResponsibleParty) Contact(org.opengis.metadata.citation.Contact)

Example 10 with ResponsibleParty

use of org.opengis.metadata.citation.ResponsibleParty in project sis by apache.

the class ServicesForUtility method createCitation.

/**
 * Returns the build-in citation for the given primary key, or {@code null}.
 *
 * @param  key  the primary key of the desired citation.
 * @return the requested citation, or {@code null} if unknown.
 *
 * @todo The content is hard-coded for now. But the plan for a future version is to fetch richer information
 *       from a database, including for example the responsible party and the URL. However that method would
 *       need to make sure that the given key is present in the alternate titles, since we rely on that when
 *       checking for code spaces.
 */
public static Citation createCitation(final String key) {
    CharSequence title;
    CharSequence alternateTitle = null;
    CharSequence edition = null;
    String code = null;
    String codeSpace = null;
    String version = null;
    Identifier[] alternateIdentifiers = null;
    CharSequence citedResponsibleParty = null;
    PresentationForm presentationForm = null;
    // Copy citedResponsibleParty from those citations.
    Citation[] copyFrom = null;
    switch(key) {
        case "ISO 19115-1":
            {
                title = "Geographic Information — Metadata Part 1: Fundamentals";
                edition = "ISO 19115-1:2014(E)";
                code = "19115-1";
                codeSpace = "ISO";
                version = "2014(E)";
                citedResponsibleParty = "International Organization for Standardization";
                presentationForm = PresentationForm.DOCUMENT_DIGITAL;
                break;
            }
        case "ISO 19115-2":
            {
                title = "Geographic Information — Metadata Part 2: Extensions for imagery and gridded data";
                edition = "ISO 19115-2:2009(E)";
                code = "19115-2";
                codeSpace = "ISO";
                version = "2009(E)";
                copyFrom = new Citation[] { Citations.ISO_19115.get(0) };
                presentationForm = PresentationForm.DOCUMENT_DIGITAL;
                break;
            }
        case "WMS":
            {
                // OGC title
                title = "Web Map Server";
                // ISO title
                alternateTitle = "Geographic Information — Web map server interface";
                alternateIdentifiers = new Identifier[] { new ImmutableIdentifier(null, "OGC", "06-042", null, null), new ImmutableIdentifier(null, "ISO", "19128", "2005", null) };
                edition = "1.3";
                code = "WMS";
                codeSpace = "OGC";
                copyFrom = new Citation[] { Citations.OGC, Citations.ISO_19115.get(0) };
                presentationForm = PresentationForm.DOCUMENT_DIGITAL;
                break;
            }
        case Constants.OGC:
            {
                title = "Identifiers in OGC namespace";
                code = Constants.OGC;
                citedResponsibleParty = "Open Geospatial Consortium";
                presentationForm = PresentationForm.DOCUMENT_DIGITAL;
                break;
            }
        case Constants.IOGP:
            {
                // Not in public API (see Citations.IOGP javadoc)
                // Geomatics Guidance Note number 7, part 1
                title = "Using the EPSG Geodetic Parameter Dataset";
                code = Constants.IOGP;
                copyFrom = new Citation[] { Citations.EPSG };
                presentationForm = PresentationForm.DOCUMENT_DIGITAL;
                break;
            }
        case Constants.EPSG:
            {
                title = "EPSG Geodetic Parameter Dataset";
                code = Constants.EPSG;
                codeSpace = Constants.IOGP;
                citedResponsibleParty = "International Association of Oil & Gas producers";
                presentationForm = PresentationForm.TABLE_DIGITAL;
                /*
                 * More complete information is provided as an ISO 19115 structure
                 * in EPSG Surveying and Positioning Guidance Note Number 7, part 1.
                 * EPSGDataAccess.getAuthority() also add more information.
                 * After we moved the content of this citation in a database,
                 * EPSGDataAccess.getAuthority() should use this citation as a template.
                 */
                break;
            }
        case Constants.SIS:
            {
                title = "Apache Spatial Information System";
                code = key;
                break;
            }
        case "ISBN":
            {
                title = "International Standard Book Number";
                alternateTitle = key;
                break;
            }
        case "ISSN":
            {
                title = "International Standard Serial Number";
                alternateTitle = key;
                break;
            }
        case Constants.PROJ4:
            {
                title = "Proj.4";
                break;
            }
        case "S57":
            {
                title = "S-57";
                break;
            }
        default:
            return null;
    }
    /*
         * Do not use the 'c.getFoo().add(foo)' pattern below. Use the 'c.setFoo(singleton(foo))' pattern instead.
         * This is because this method may be invoked during XML serialization, in which case some getter methods
         * may return null (for preventing JAXB to marshal some empty elements).
         */
    final DefaultCitation c = new DefaultCitation(title);
    if (alternateTitle != null)
        c.setAlternateTitles(singleton(Types.toInternationalString(alternateTitle)));
    if (edition != null)
        c.setEdition(Types.toInternationalString(edition));
    if (code != null)
        c.setIdentifiers(singleton(new ImmutableIdentifier(null, codeSpace, code, version, null)));
    if (presentationForm != null)
        c.setPresentationForms(singleton(presentationForm));
    if (citedResponsibleParty != null) {
        final DefaultResponsibleParty r = new DefaultResponsibleParty(Role.PRINCIPAL_INVESTIGATOR);
        r.setParties(singleton(new DefaultOrganisation(citedResponsibleParty, null, null, null)));
        c.setCitedResponsibleParties(singleton(r));
    }
    if (copyFrom != null) {
        for (final Citation other : copyFrom) {
            final Collection<? extends ResponsibleParty> parties = other.getCitedResponsibleParties();
            final Collection<ResponsibleParty> current = c.getCitedResponsibleParties();
            if (current != null) {
                current.addAll(parties);
            } else {
                c.setCitedResponsibleParties(parties);
            }
        }
    }
    if (alternateIdentifiers != null) {
        // getIdentifiers() should not return null at this point.
        c.getIdentifiers().addAll(Arrays.asList(alternateIdentifiers));
    }
    c.freeze();
    return c;
}
Also used : DefaultOrganisation(org.apache.sis.metadata.iso.citation.DefaultOrganisation) DefaultResponsibleParty(org.apache.sis.metadata.iso.citation.DefaultResponsibleParty) DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) ResponsibleParty(org.opengis.metadata.citation.ResponsibleParty) DefaultResponsibleParty(org.apache.sis.metadata.iso.citation.DefaultResponsibleParty) ImmutableIdentifier(org.apache.sis.metadata.iso.ImmutableIdentifier) Identifier(org.opengis.metadata.Identifier) PresentationForm(org.opengis.metadata.citation.PresentationForm) Citation(org.opengis.metadata.citation.Citation) DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) ImmutableIdentifier(org.apache.sis.metadata.iso.ImmutableIdentifier)

Aggregations

ResponsibleParty (org.opengis.metadata.citation.ResponsibleParty)11 Test (org.junit.Test)5 Citation (org.opengis.metadata.citation.Citation)3 Extent (org.opengis.metadata.extent.Extent)3 ArrayList (java.util.ArrayList)2 Locale (java.util.Locale)2 CheckedArrayList (org.apache.sis.internal.util.CheckedArrayList)2 ImmutableIdentifier (org.apache.sis.metadata.iso.ImmutableIdentifier)2 DefaultCitation (org.apache.sis.metadata.iso.citation.DefaultCitation)2 DefaultResponsibleParty (org.apache.sis.metadata.iso.citation.DefaultResponsibleParty)2 DefaultDataIdentification (org.apache.sis.metadata.iso.identification.DefaultDataIdentification)2 Identifier (org.opengis.metadata.Identifier)2 CitationDate (org.opengis.metadata.citation.CitationDate)2 OnlineResource (org.opengis.metadata.citation.OnlineResource)2 Format (org.opengis.metadata.distribution.Format)2 GeographicExtent (org.opengis.metadata.extent.GeographicExtent)2 Identification (org.opengis.metadata.identification.Identification)2 InternationalString (org.opengis.util.InternationalString)2 HashMap (java.util.HashMap)1 Marshaller (javax.xml.bind.Marshaller)1