Search in sources :

Example 1 with DefaultResponsibleParty

use of org.apache.sis.metadata.iso.citation.DefaultResponsibleParty in project sis by apache.

the class TreeNodeTest method metadataWithHierarchy.

/**
 * Creates a metadata hierarchy to be used for the tests.
 * This method creates the following metadata:
 *
 * {@preformat text
 *   Citation
 *     ├─Title…………………………………………………………………………………………… Some title
 *     ├─Alternate title (1 of 2)………………………………………… First alternate title
 *     ├─Alternate title (2 of 2)………………………………………… Second alternate title
 *     ├─Edition……………………………………………………………………………………… Some edition
 *     ├─Cited responsible party (1 of 2)
 *     │   └─Organisation
 *     │      ├─Name…………………………………………………………………………… Some organisation
 *     │      └─Role…………………………………………………………………………… Distributor
 *     ├─Cited responsible party (2 of 2)
 *     │   └─Individual
 *     │      ├─Name…………………………………………………………………………… Some person of contact
 *     │      ├─Contact info
 *     │      │   └─Address
 *     │      │       └─Electronic mail address…… Some email
 *     │      └─Role…………………………………………………………………………… Point of contact
 *     ├─Presentation form (1 of 2)…………………………………… Map digital
 *     ├─Presentation form (2 of 2)…………………………………… map hardcopy
 *     └─Other citation details……………………………………………… Some other details
 * }
 */
static DefaultCitation metadataWithHierarchy() {
    final DefaultCitation citation = TreeNodeChildrenTest.metadataWithMultiOccurrences();
    AbstractParty party = new DefaultOrganisation("Some organisation", null, null, null);
    DefaultResponsibleParty responsibility = new DefaultResponsibleParty(Role.DISTRIBUTOR);
    responsibility.setParties(singleton(party));
    assertTrue(citation.getCitedResponsibleParties().add(responsibility));
    // Add a second responsible party with deeper hierarchy.
    final DefaultContact contact = new DefaultContact();
    final DefaultAddress address = new DefaultAddress();
    address.setElectronicMailAddresses(singleton("Some email"));
    contact.setAddresses(singleton(address));
    party = new DefaultIndividual("Some person of contact", null, contact);
    responsibility = new DefaultResponsibleParty(Role.POINT_OF_CONTACT);
    responsibility.setParties(singleton(party));
    assertTrue(citation.getCitedResponsibleParties().add(responsibility));
    return citation;
}
Also used : AbstractParty(org.apache.sis.metadata.iso.citation.AbstractParty) DefaultAddress(org.apache.sis.metadata.iso.citation.DefaultAddress) DefaultOrganisation(org.apache.sis.metadata.iso.citation.DefaultOrganisation) DefaultResponsibleParty(org.apache.sis.metadata.iso.citation.DefaultResponsibleParty) DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) DefaultContact(org.apache.sis.metadata.iso.citation.DefaultContact) DefaultIndividual(org.apache.sis.metadata.iso.citation.DefaultIndividual)

Example 2 with DefaultResponsibleParty

use of org.apache.sis.metadata.iso.citation.DefaultResponsibleParty in project sis by apache.

the class TreeTableFormatTest method testProcessing.

/**
 * Tests the formatting of a {@link DefaultProcessing} object.
 */
@Test
public void testProcessing() {
    final DefaultCitation titled = new DefaultCitation("Some specification");
    final DefaultCitation coded = new DefaultCitation();
    final DefaultCitation untitled = new DefaultCitation();
    titled.setPresentationForms(singleton(PresentationForm.DOCUMENT_HARDCOPY));
    coded.setPresentationForms(singleton(PresentationForm.IMAGE_HARDCOPY));
    untitled.setCitedResponsibleParties(singleton(new DefaultResponsibleParty(Role.AUTHOR)));
    final DefaultProcessing processing = new DefaultProcessing();
    processing.setDocumentations(asList(titled, coded, untitled));
    final String text = format.format(processing.asTreeTable());
    assertMultilinesEquals("Processing\n" + "  ├─Documentation (1 of 3)…………… Some specification\n" + "  │   └─Presentation form……………… Document hardcopy\n" + "  ├─Documentation (2 of 3)\n" + "  │   └─Presentation form……………… Image hardcopy\n" + "  └─Documentation (3 of 3)\n" + "      └─Cited responsible party\n" + "          └─Role……………………………………… Author\n", text);
}
Also used : DefaultResponsibleParty(org.apache.sis.metadata.iso.citation.DefaultResponsibleParty) DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) DefaultProcessing(org.apache.sis.metadata.iso.lineage.DefaultProcessing) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) Test(org.junit.Test) DefaultCitationTest(org.apache.sis.metadata.iso.citation.DefaultCitationTest)

Example 3 with DefaultResponsibleParty

use of org.apache.sis.metadata.iso.citation.DefaultResponsibleParty in project sis by apache.

the class ValueMapTest method createCitation.

/**
 * Creates the metadata instance to be used for testing purpose.
 * This method creates the following metadata
 * (ignoring identifiers, which will be inferred from the ISBN value):
 *
 * {@preformat text
 *     Citation
 *       ├─Title…………………………………………………… Undercurrent
 *       ├─Edition……………………………………………… <nil:unknown>
 *       ├─Cited Responsible Parties
 *       │   └─Individual Name……………… Testsuya Toyoda
 *       └─ISBN……………………………………………………… 9782505004509
 * }
 *
 * The citation instance is stored in the {@link #citation} field.
 * The title and author instances are stored in the {@link #title} and {@link #author} fields.
 *
 * @return the map view of the citation create by this method.
 */
private Map<String, Object> createCitation() {
    title = new SimpleInternationalString("Undercurrent");
    author = new DefaultResponsibleParty();
    citation = new DefaultCitation(title);
    author.setParties(singleton(new DefaultIndividual("Testsuya Toyoda", null, null)));
    citation.setCitedResponsibleParties(singleton(author));
    citation.setISBN("9782505004509");
    citation.setEdition(NilReason.UNKNOWN.createNilObject(InternationalString.class));
    return MetadataStandard.ISO_19115.asValueMap(citation, null, KeyNamePolicy.JAVABEANS_PROPERTY, ValueExistencePolicy.NON_EMPTY);
}
Also used : DefaultResponsibleParty(org.apache.sis.metadata.iso.citation.DefaultResponsibleParty) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) InternationalString(org.opengis.util.InternationalString) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) DefaultIndividual(org.apache.sis.metadata.iso.citation.DefaultIndividual)

Example 4 with DefaultResponsibleParty

use of org.apache.sis.metadata.iso.citation.DefaultResponsibleParty in project sis by apache.

the class MetadataBuilder method addCitedResponsibleParty.

/**
 * Adds role, name, contact and position information for an individual or organization that is responsible
 * for the resource. This method can be used as an alternative to {@link #addAuthor(CharSequence)} when the
 * caller needs to create the responsibly party itself.
 *
 * <p>If the given {@code role} is non-null, then this method will ensure that the added party has the given
 * role. A copy of the given party will be created if needed (the given party will never be modified).</p>
 *
 * Storage locations are:
 *
 * <ul>
 *   <li>{@code metadata/identificationInfo/citation/citedResponsibleParty}</li>
 *   <li>{@code metadata/identificationInfo/citation/citedResponsibleParty/role}</li>
 * </ul>
 *
 * @param  party  the individual or organization that is responsible, or {@code null} for no-operation.
 * @param  role   the role to set, or {@code null} for leaving it unchanged.
 */
public final void addCitedResponsibleParty(ResponsibleParty party, final Role role) {
    if (party != null) {
        if (role != null && !role.equals(party.getRole())) {
            party = new DefaultResponsibleParty(party);
            ((DefaultResponsibility) party).setRole(role);
        }
        addIfNotPresent(citation().getCitedResponsibleParties(), party);
    }
}
Also used : DefaultResponsibility(org.apache.sis.metadata.iso.citation.DefaultResponsibility) DefaultResponsibleParty(org.apache.sis.metadata.iso.citation.DefaultResponsibleParty)

Example 5 with DefaultResponsibleParty

use of org.apache.sis.metadata.iso.citation.DefaultResponsibleParty 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

DefaultResponsibleParty (org.apache.sis.metadata.iso.citation.DefaultResponsibleParty)6 DefaultCitation (org.apache.sis.metadata.iso.citation.DefaultCitation)5 ImmutableIdentifier (org.apache.sis.metadata.iso.ImmutableIdentifier)2 DefaultIndividual (org.apache.sis.metadata.iso.citation.DefaultIndividual)2 DefaultOrganisation (org.apache.sis.metadata.iso.citation.DefaultOrganisation)2 SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)2 ResponsibleParty (org.opengis.metadata.citation.ResponsibleParty)2 DefaultMetadata (org.apache.sis.metadata.iso.DefaultMetadata)1 AbstractParty (org.apache.sis.metadata.iso.citation.AbstractParty)1 DefaultAddress (org.apache.sis.metadata.iso.citation.DefaultAddress)1 DefaultCitationTest (org.apache.sis.metadata.iso.citation.DefaultCitationTest)1 DefaultContact (org.apache.sis.metadata.iso.citation.DefaultContact)1 DefaultResponsibility (org.apache.sis.metadata.iso.citation.DefaultResponsibility)1 DefaultProcessing (org.apache.sis.metadata.iso.lineage.DefaultProcessing)1 Test (org.junit.Test)1 Identifier (org.opengis.metadata.Identifier)1 Citation (org.opengis.metadata.citation.Citation)1 PresentationForm (org.opengis.metadata.citation.PresentationForm)1 InternationalString (org.opengis.util.InternationalString)1