Search in sources :

Example 46 with DefaultCitation

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

the class MetadataSourceTest method testSearch.

/**
 * Tests {@link MetadataSource#search(Object)}
 *
 * @param  source  the instance to test.
 * @throws MetadataStoreException if an error occurred while querying the database.
 */
@TestStep
public static void testSearch(final MetadataSource source) throws MetadataStoreException {
    final DefaultCitation specification = new DefaultCitation("PNG (Portable Network Graphics) Specification");
    specification.setAlternateTitles(Collections.singleton(new SimpleInternationalString("PNG")));
    final DefaultFormat format = new DefaultFormat();
    format.setFormatSpecificationCitation(specification);
    assertEquals("PNG", source.search(format));
    specification.setTitle(null);
    assertNull(source.search(format));
}
Also used : DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) DefaultFormat(org.apache.sis.metadata.iso.distribution.DefaultFormat) TestStep(org.apache.sis.test.TestStep)

Example 47 with DefaultCitation

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

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

the class CustomMetadataTest method testProxy.

/**
 * Tests the marshalling of a metadata implemented by {@link Proxy}.
 *
 * @throws JAXBException if an error occurred during (un)marshalling.
 */
@Test
public void testProxy() throws JAXBException {
    /*
         * A trivial metadata implementation which return the method name
         * for every attribute of type InternationalString.
         */
    final InvocationHandler handler = (Object proxy, Method method, Object[] args) -> {
        if (method.getReturnType() == InternationalString.class) {
            return new SimpleInternationalString(method.getName());
        }
        return null;
    };
    Citation data = (Citation) Proxy.newProxyInstance(getClass().getClassLoader(), new Class<?>[] { Citation.class }, handler);
    /*
         * Wrap the metadata in a DefaultMetadata, and ensure
         * we can marshall it without an exception being throw.
         */
    data = new DefaultCitation(data);
    final String xml = XML.marshal(data);
    /*
         * A few simple checks.
         */
    assertTrue(xml.contains("title"));
    assertTrue(xml.contains("edition"));
}
Also used : InternationalString(org.opengis.util.InternationalString) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) Method(java.lang.reflect.Method) Citation(org.opengis.metadata.citation.Citation) DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) InternationalString(org.opengis.util.InternationalString) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) InvocationHandler(java.lang.reflect.InvocationHandler) Test(org.junit.Test)

Example 49 with DefaultCitation

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

the class DefaultMetadataTest method testParentIdentifier.

/**
 * Tests {@link DefaultMetadata#getParentIdentifier()} and {@link DefaultMetadata#setParentIdentifier(String)}
 * methods.
 */
@Test
@SuppressWarnings("deprecation")
public void testParentIdentifier() {
    final DefaultMetadata metadata = new DefaultMetadata();
    assertNull("parentIdentifier", metadata.getParentIdentifier());
    metadata.setParentIdentifier("ParentID");
    assertEquals("parentIdentifier", "ParentID", metadata.getParentIdentifier());
    DefaultCitation c = (DefaultCitation) metadata.getParentMetadata();
    assertTitleEquals("parentMetadata", "ParentID", c);
    c.setTitle(new SimpleInternationalString("New parent"));
    assertEquals("parentIdentifier", "New parent", metadata.getParentIdentifier());
}
Also used : DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) Test(org.junit.Test)

Example 50 with DefaultCitation

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

the class ImmutableIdentifierTest method testMarshal.

/**
 * Test XML marshalling.
 *
 * @throws JAXBException if an error occurred during (un)marshalling.
 */
@Test
public void testMarshal() throws JAXBException {
    final ImmutableIdentifier identifier = new ImmutableIdentifier(new DefaultCitation("EPSG"), null, "4326");
    assertXmlEquals("<gmd:RS_Identifier xmlns:gmd=\"" + LegacyNamespaces.GMD + "\" " + "xmlns:gco=\"" + LegacyNamespaces.GCO + "\">\n" + "  <gmd:authority>\n" + "    <gmd:CI_Citation>\n" + "      <gmd:title>\n" + "        <gco:CharacterString>EPSG</gco:CharacterString>\n" + "      </gmd:title>\n" + "    </gmd:CI_Citation>\n" + "  </gmd:authority>\n" + "  <gmd:code>\n" + "    <gco:CharacterString>4326</gco:CharacterString>\n" + "  </gmd:code>\n" + "</gmd:RS_Identifier>", marshal(identifier, VERSION_2007), "xmlns:*");
}
Also used : DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) Test(org.junit.Test)

Aggregations

DefaultCitation (org.apache.sis.metadata.iso.citation.DefaultCitation)65 Test (org.junit.Test)35 SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)32 DependsOnMethod (org.apache.sis.test.DependsOnMethod)21 InternationalString (org.opengis.util.InternationalString)14 Citation (org.opengis.metadata.citation.Citation)10 IdentifiedObject (org.opengis.referencing.IdentifiedObject)9 ImmutableIdentifier (org.apache.sis.metadata.iso.ImmutableIdentifier)5 DefaultResponsibleParty (org.apache.sis.metadata.iso.citation.DefaultResponsibleParty)5 URI (java.net.URI)3 DefaultIdentifier (org.apache.sis.metadata.iso.DefaultIdentifier)3 DefaultMetadata (org.apache.sis.metadata.iso.DefaultMetadata)3 DefaultCitationTest (org.apache.sis.metadata.iso.citation.DefaultCitationTest)3 DefaultOnlineResource (org.apache.sis.metadata.iso.citation.DefaultOnlineResource)3 ArrayList (java.util.ArrayList)2 CI_Citation (org.apache.sis.internal.jaxb.metadata.CI_Citation)2 SimpleIdentifiedObject (org.apache.sis.internal.simple.SimpleIdentifiedObject)2 SimpleIdentifier (org.apache.sis.internal.simple.SimpleIdentifier)2 DefaultCitationDate (org.apache.sis.metadata.iso.citation.DefaultCitationDate)2 DefaultIndividual (org.apache.sis.metadata.iso.citation.DefaultIndividual)2