Search in sources :

Example 1 with ResponsibleParty

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

the class GeographicInformationParser method extractContent.

private void extractContent(XHTMLContentHandler xhtmlContentHandler, DefaultMetadata defaultMetadata) throws SAXException {
    xhtmlContentHandler.startDocument();
    xhtmlContentHandler.newline();
    xhtmlContentHandler.newline();
    ArrayList<Identification> identifications = (ArrayList<Identification>) defaultMetadata.getIdentificationInfo();
    for (Identification i : identifications) {
        xhtmlContentHandler.startElement("h1");
        xhtmlContentHandler.characters(i.getCitation().getTitle().toString());
        xhtmlContentHandler.endElement("h1");
        xhtmlContentHandler.newline();
        ArrayList<ResponsibleParty> responsiblePartyArrayList = (ArrayList<ResponsibleParty>) i.getCitation().getCitedResponsibleParties();
        for (ResponsibleParty r : responsiblePartyArrayList) {
            xhtmlContentHandler.startElement("h3");
            xhtmlContentHandler.newline();
            xhtmlContentHandler.characters("CitedResponsiblePartyRole " + r.getRole().toString());
            xhtmlContentHandler.characters("CitedResponsiblePartyName " + r.getIndividualName().toString());
            xhtmlContentHandler.endElement("h3");
            xhtmlContentHandler.newline();
        }
        xhtmlContentHandler.startElement("p");
        xhtmlContentHandler.newline();
        xhtmlContentHandler.characters("IdentificationInfoAbstract " + i.getAbstract().toString());
        xhtmlContentHandler.endElement("p");
        xhtmlContentHandler.newline();
        Collection<Extent> extentList = ((DefaultDataIdentification) i).getExtents();
        for (Extent e : extentList) {
            ArrayList<GeographicExtent> geoElements = (ArrayList<GeographicExtent>) e.getGeographicElements();
            for (GeographicExtent g : geoElements) {
                if (g instanceof DefaultGeographicBoundingBox) {
                    xhtmlContentHandler.startElement("tr");
                    xhtmlContentHandler.startElement("td");
                    xhtmlContentHandler.characters("GeographicElementWestBoundLatitude");
                    xhtmlContentHandler.endElement("td");
                    xhtmlContentHandler.startElement("td");
                    xhtmlContentHandler.characters(String.valueOf(((DefaultGeographicBoundingBox) g).getWestBoundLongitude()));
                    xhtmlContentHandler.endElement("td");
                    xhtmlContentHandler.endElement("tr");
                    xhtmlContentHandler.startElement("tr");
                    xhtmlContentHandler.startElement("td");
                    xhtmlContentHandler.characters("GeographicElementEastBoundLatitude");
                    xhtmlContentHandler.endElement("td");
                    xhtmlContentHandler.startElement("td");
                    xhtmlContentHandler.characters(String.valueOf(((DefaultGeographicBoundingBox) g).getEastBoundLongitude()));
                    xhtmlContentHandler.endElement("td");
                    xhtmlContentHandler.endElement("tr");
                    xhtmlContentHandler.startElement("tr");
                    xhtmlContentHandler.startElement("td");
                    xhtmlContentHandler.characters("GeographicElementNorthBoundLatitude");
                    xhtmlContentHandler.endElement("td");
                    xhtmlContentHandler.startElement("td");
                    xhtmlContentHandler.characters(String.valueOf(((DefaultGeographicBoundingBox) g).getNorthBoundLatitude()));
                    xhtmlContentHandler.endElement("td");
                    xhtmlContentHandler.endElement("tr");
                    xhtmlContentHandler.startElement("tr");
                    xhtmlContentHandler.startElement("td");
                    xhtmlContentHandler.characters("GeographicElementSouthBoundLatitude");
                    xhtmlContentHandler.endElement("td");
                    xhtmlContentHandler.startElement("td");
                    xhtmlContentHandler.characters(String.valueOf(((DefaultGeographicBoundingBox) g).getSouthBoundLatitude()));
                    xhtmlContentHandler.endElement("td");
                    xhtmlContentHandler.endElement("tr");
                }
            }
        }
    }
    xhtmlContentHandler.newline();
    xhtmlContentHandler.endDocument();
}
Also used : DefaultGeographicBoundingBox(org.apache.sis.metadata.iso.extent.DefaultGeographicBoundingBox) 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) DefaultDataIdentification(org.apache.sis.metadata.iso.identification.DefaultDataIdentification) Identification(org.opengis.metadata.identification.Identification) ResponsibleParty(org.opengis.metadata.citation.ResponsibleParty) GeographicExtent(org.opengis.metadata.extent.GeographicExtent)

Example 2 with ResponsibleParty

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

the class CustomMetadataTest method testSubtypeAttributes.

/**
 * Tests that the attributes defined in subtypes are also marshalled.
 *
 * @throws JAXBException if an error occurred during (un)marshalling.
 *
 * @see <a href="http://jira.geotoolkit.org/browse/GEOTK-108">GEOTK-108</a>
 */
@Test
public void testSubtypeAttributes() throws JAXBException {
    final NameFactory factory = DefaultFactories.forBuildin(NameFactory.class);
    final DataIdentification identification = new DataIdentification() {

        @Override
        public InternationalString getAbstract() {
            Map<Locale, String> names = new HashMap<>();
            names.put(Locale.ENGLISH, "Description");
            return factory.createInternationalString(names);
        }

        @Override
        public InternationalString getEnvironmentDescription() {
            Map<Locale, String> names = new HashMap<>();
            names.put(Locale.ENGLISH, "Environment");
            return factory.createInternationalString(names);
        }

        @Override
        public InternationalString getSupplementalInformation() {
            return null;
        }

        @Override
        public Citation getCitation() {
            return null;
        }

        @Override
        public InternationalString getPurpose() {
            return null;
        }

        @Override
        public Collection<SpatialRepresentationType> getSpatialRepresentationTypes() {
            return null;
        }

        @Override
        public Collection<Resolution> getSpatialResolutions() {
            return null;
        }

        @Override
        public Collection<Locale> getLanguages() {
            return null;
        }

        @Override
        public Collection<CharacterSet> getCharacterSets() {
            return null;
        }

        @Override
        public Collection<TopicCategory> getTopicCategories() {
            return null;
        }

        @Override
        public Collection<Extent> getExtents() {
            return null;
        }

        @Override
        public Collection<String> getCredits() {
            return null;
        }

        @Override
        public Collection<Progress> getStatus() {
            return null;
        }

        @Override
        public Collection<ResponsibleParty> getPointOfContacts() {
            return null;
        }

        @Override
        public Collection<MaintenanceInformation> getResourceMaintenances() {
            return null;
        }

        @Override
        public Collection<BrowseGraphic> getGraphicOverviews() {
            return null;
        }

        @Override
        public Collection<Format> getResourceFormats() {
            return null;
        }

        @Override
        public Collection<Keywords> getDescriptiveKeywords() {
            return null;
        }

        @Override
        public Collection<Usage> getResourceSpecificUsages() {
            return null;
        }

        @Override
        public Collection<Constraints> getResourceConstraints() {
            return null;
        }

        @Deprecated
        @Override
        public Collection<AggregateInformation> getAggregationInfo() {
            return null;
        }
    };
    final DefaultMetadata data = new DefaultMetadata();
    data.setIdentificationInfo(singleton(identification));
    final String xml = XML.marshal(data);
    /*
         * A few simple checks.
         */
    assertTrue("Missing Identification attribute.", xml.contains("Description"));
    assertTrue("Missing DataIdentification attribute.", xml.contains("Environment"));
}
Also used : Locale(java.util.Locale) HashMap(java.util.HashMap) Extent(org.opengis.metadata.extent.Extent) InternationalString(org.opengis.util.InternationalString) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) ResponsibleParty(org.opengis.metadata.citation.ResponsibleParty) Format(org.opengis.metadata.distribution.Format) Constraints(org.opengis.metadata.constraint.Constraints) MaintenanceInformation(org.opengis.metadata.maintenance.MaintenanceInformation) NameFactory(org.opengis.util.NameFactory) SpatialRepresentationType(org.opengis.metadata.spatial.SpatialRepresentationType) Test(org.junit.Test)

Example 3 with ResponsibleParty

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

the class MetadataWriterTest method read.

/**
 * Reads known entries in the database.
 * Expected entry is:
 *
 * {@preformat text
 *   Citation
 *     ├─Title………………………………………………………… EPSG Geodetic Parameter Dataset
 *     ├─Identifier
 *     │   └─Code………………………………………………… EPSG
 *     ├─Cited responsible party
 *     │   ├─Party
 *     │   │   ├─Name……………………………………… International Association of Oil & Gas Producers
 *     │   │   └─Contact info
 *     │   │       └─Online resource
 *     │   │           ├─Linkage………… http://www.epsg.org
 *     │   │           └─Function……… Information
 *     │   └─Role………………………………………………… Principal investigator
 *     └─Presentation form………………………… Table digital
 * }
 *
 * @throws MetadataStoreException if an error occurred while reading the database.
 */
private void read() throws MetadataStoreException {
    final Citation c = source.lookup(Citation.class, "EPSG");
    assertEquals("EPSG Geodetic Parameter Dataset", c.getTitle().toString());
    assertEquals(PresentationForm.TABLE_DIGITAL, TestUtilities.getSingleton(c.getPresentationForms()));
    /*
         * Ask for dependencies that are known to exist.
         */
    final ResponsibleParty responsible = TestUtilities.getSingleton(c.getCitedResponsibleParties());
    assertEquals(Role.PRINCIPAL_INVESTIGATOR, responsible.getRole());
    assertEquals("International Association of Oil & Gas Producers", responsible.getOrganisationName().toString());
    OnlineResource resource = responsible.getContactInfo().getOnlineResource();
    assertEquals("http://www.epsg.org", resource.getLinkage().toString());
    assertEquals(OnLineFunction.INFORMATION, resource.getFunction());
    /*
         * Ask columns that are known to not exist.
         */
    assertNull(c.getEditionDate());
    assertTrue(c.getDates().isEmpty());
    assertEquals(0, c.getAlternateTitles().size());
    /*
         * Test the cache.
         */
    assertSame(c, source.lookup(Citation.class, "EPSG"));
    assertNotSame(c, source.lookup(Citation.class, "SIS"));
    /*
         * Should return the identifier with no search. Actually the real test is the call to "proxy",
         * since there is no way to ensure that the call to "search" tooks the short path (except by
         * looking at the debugger). But if "proxy" succeed, then "search" should be okay.
         */
    assertEquals("EPSG", source.proxy(c));
    assertEquals("EPSG", source.search(c));
}
Also used : OnlineResource(org.opengis.metadata.citation.OnlineResource) Citation(org.opengis.metadata.citation.Citation) ResponsibleParty(org.opengis.metadata.citation.ResponsibleParty)

Example 4 with ResponsibleParty

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

the class DefaultCitationTest method testFreeze.

/**
 * Tests {@link DefaultCitation#freeze()}, which is needed for the constants defined in {@link Citations}.
 */
@Test
public void testFreeze() {
    final DefaultCitation original = create();
    // This will invoke 'freeze()'.
    final DefaultCitation clone = (DefaultCitation) original.unmodifiable();
    assertNotSame(original, clone);
    assertTrue("original.isModifiable", original.isModifiable());
    assertFalse("clone.isModifiable", clone.isModifiable());
    assertSame("original.unmodifiable", clone, original.unmodifiable());
    assertSame("clone.unmodifiable", clone, clone.unmodifiable());
    assertSame("ISBN", original.getISBN(), clone.getISBN());
    assertSame("title", original.getTitle(), clone.getTitle());
    assertSame("alternateTitle", getSingleton(original.getAlternateTitles()), getSingleton(clone.getAlternateTitles()));
    assertCopy(original.getIdentifiers(), clone.getIdentifiers());
    assertCopy(original.getCitedResponsibleParties(), clone.getCitedResponsibleParties());
    assertCopy(original.getPresentationForms(), clone.getPresentationForms());
    /*
         * Verify the unique identifier, which is the ISBN code. ISBN and ISSN codes are handled
         * in a special way by DefaultCitation (they are instances of SpecializedIdentifier), but
         * the should nevertheless be cloned.
         */
    final Identifier ide = getSingleton(original.getIdentifiers());
    final Identifier ida = getSingleton(clone.getIdentifiers());
    assertNotSame("identifier", ide, ida);
    assertSame("code", ide.getCode(), ida.getCode());
    assertSame("authority", ide.getAuthority(), ida.getAuthority());
    /*
         * Verify the author metadata.
         */
    final ResponsibleParty re = CollectionsExt.first(original.getCitedResponsibleParties());
    final ResponsibleParty ra = CollectionsExt.first(clone.getCitedResponsibleParties());
    assertNotSame("citedResponsibleParty", re, ra);
    assertSame("role", re.getRole(), ra.getRole());
    assertSame("name", re.getIndividualName(), ra.getIndividualName());
}
Also used : DefaultIdentifier(org.apache.sis.metadata.iso.DefaultIdentifier) Identifier(org.opengis.metadata.Identifier) ResponsibleParty(org.opengis.metadata.citation.ResponsibleParty) Test(org.junit.Test)

Example 5 with ResponsibleParty

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

the class CodeListMarshallingTest method testDefaultURL.

/**
 * Tests marshaling using the default URL.
 *
 * @throws JAXBException if an error occurred while marshaling the XML.
 */
@Test
public void testDefaultURL() throws JAXBException {
    final String expected = getResponsiblePartyXML(Schemas.METADATA_ROOT_LEGACY);
    final ResponsibleParty rp = unmarshal(ResponsibleParty.class, expected);
    assertEquals(Role.PRINCIPAL_INVESTIGATOR, rp.getRole());
    /*
         * Use the convenience method in order to avoid the effort of creating
         * our own MarshallerPool.
         */
    final String actual = marshal(rp, VERSION_2007);
    assertXmlEquals(expected, actual, "xmlns:*");
}
Also used : ResponsibleParty(org.opengis.metadata.citation.ResponsibleParty) Test(org.junit.Test)

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