Search in sources :

Example 1 with DefaultIdentifier

use of org.apache.sis.metadata.iso.DefaultIdentifier in project sis by apache.

the class DefaultDataIdentificationTest method create.

/**
 * Creates the instance to test.
 */
private static DefaultDataIdentification create() {
    /*
         * Citation
         *   ├─Title……………………………………………………………………………… Sea Surface Temperature Analysis Model
         *   ├─Date
         *   │   ├─Date……………………………………………………………………… Sep 22, 2005 00:00:00 AM
         *   │   └─Date type………………………………………………………… Creation
         *   └─Identifier
         *       └─Code……………………………………………………………………… NCEP/SST/Global_5x2p5deg/SST_Global_5x2p5deg_20050922_0000.nc
         */
    final DefaultCitation citation = new DefaultCitation("Sea Surface Temperature Analysis Model");
    citation.setDates(singleton(new DefaultCitationDate(TestUtilities.date("2005-09-22 00:00:00"), DateType.CREATION)));
    citation.setIdentifiers(singleton(new DefaultIdentifier("SST_Global.nc")));
    /*
         * Descriptive keywords
         *   ├─Keyword………………………………………………………………………… EARTH SCIENCE > Oceans > Ocean Temperature > Sea Surface Temperature
         *   ├─Type………………………………………………………………………………… Theme
         *   └─Thesaurus name
         *       └─Title…………………………………………………………………… GCMD Science Keywords
         */
    final DefaultKeywords keywords = new DefaultKeywords("EARTH SCIENCE > Oceans > Ocean Temperature > Sea Surface Temperature");
    keywords.setType(KeywordType.THEME);
    keywords.setThesaurusName(new DefaultCitation("GCMD Science Keywords"));
    /*
         * Identification info
         *  ├─(above objects)
         *  ├─Abstract………………………………………………………………………………… NCEP SST Global 5.0 x 2.5 degree model data
         *  ├─Descriptive keywords
         *  │   ├─Keyword………………………………………………………………………… EARTH SCIENCE > Oceans > Ocean Temperature > Sea Surface Temperature
         *  │   ├─Type………………………………………………………………………………… Theme
         *  │   └─Thesaurus name
         *  │       └─Title…………………………………………………………………… GCMD Science Keywords
         *  ├─Resource constraints
         *  │   └─Use limitation……………………………………………………… Freely available
         *  ├─Spatial representation type……………………………… Grid
         *  ├─Language (1 of 2)………………………………………………………… en_US
         *  ├─Language (2 of 2)………………………………………………………… en
         *  ├─Character set…………………………………………………………………… US-ASCII
         *  └─Extent
         *      └─Geographic element
         *          ├─West bound longitude…………………………… 180°W
         *          ├─East bound longitude…………………………… 180°E
         *          ├─South bound latitude…………………………… 90°S
         *          ├─North bound latitude…………………………… 90°N
         *          └─Extent type code……………………………………… true
         */
    final DefaultDataIdentification info = new DefaultDataIdentification(citation, "NCEP SST Global 5.0 x 2.5 degree model data", null, null);
    info.setSpatialRepresentationTypes(singleton(SpatialRepresentationType.GRID));
    info.setDescriptiveKeywords(singleton(keywords));
    info.setResourceConstraints(singleton(new DefaultConstraints("Freely available")));
    info.setExtents(singleton(Extents.WORLD));
    info.setLanguages(asList(LOCALES));
    info.setCharacterSets(singleton(CharacterSet.US_ASCII));
    return info;
}
Also used : DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) DefaultIdentifier(org.apache.sis.metadata.iso.DefaultIdentifier) DefaultConstraints(org.apache.sis.metadata.iso.constraint.DefaultConstraints) DefaultCitationDate(org.apache.sis.metadata.iso.citation.DefaultCitationDate)

Example 2 with DefaultIdentifier

use of org.apache.sis.metadata.iso.DefaultIdentifier in project sis by apache.

the class DefaultLineageTest method create.

/**
 * Create a lineage to marshal. If {@code extension} is {@code false}, then this method uses
 * only properties defined in ISO 19115-1. If {@code extension} is {@code true}, then this
 * method adds an ISO 19115-2 property.
 */
private static DefaultLineage create(final boolean extension) {
    final DefaultLineage lineage = new DefaultLineage();
    final DefaultSource source = new DefaultSource();
    source.setDescription(new SimpleInternationalString("Description of source data level."));
    lineage.getSources().add(source);
    if (extension) {
        source.setProcessedLevel(new DefaultIdentifier("DummyLevel"));
    }
    return lineage;
}
Also used : SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) DefaultIdentifier(org.apache.sis.metadata.iso.DefaultIdentifier)

Example 3 with DefaultIdentifier

use of org.apache.sis.metadata.iso.DefaultIdentifier in project sis by apache.

the class CharSequenceSubstitutionTest method testAnchorForString.

/**
 * Tests unmarshalling of anchor in an identifier element. The {@code xlink:href} attribute
 * is lost because the Java type of the {@code gmd:code} attribute is {@link String}.
 *
 * @throws JAXBException if the unmarshalling failed.
 */
@Test
@DependsOnMethod("testAnchor")
public void testAnchorForString() throws JAXBException {
    final String expected = "<mdb:MD_Identifier xmlns:mdb=\"" + Namespaces.MDB + '"' + " xmlns:gcx=\"" + Namespaces.GCX + '"' + " xmlns:gco=\"" + Namespaces.GCO + '"' + " xmlns:xlink=\"" + Namespaces.XLINK + "\">\n" + "  <mdb:code>\n" + "    <gcx:Anchor xlink:href=\"SDN:L101:2:4326\">EPSG:4326</gcx:Anchor>\n" + "  </mdb:code>\n" + "  <mdb:codeSpace>\n" + "    <gco:CharacterString>L101</gco:CharacterString>\n" + "  </mdb:codeSpace>\n" + "</mdb:MD_Identifier>";
    final DefaultIdentifier id = unmarshal(DefaultIdentifier.class, expected);
    assertEquals("codespace", "L101", id.getCodeSpace());
    assertEquals("code", "EPSG:4326", id.getCode());
}
Also used : DefaultIdentifier(org.apache.sis.metadata.iso.DefaultIdentifier) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 4 with DefaultIdentifier

use of org.apache.sis.metadata.iso.DefaultIdentifier in project sis by apache.

the class IdentifierCommand method run.

/**
 * Prints identifier information.
 *
 * @return 0 on success, or an exit code if the command failed for a reason other than an uncaught Java exception.
 */
@Override
public int run() throws Exception {
    /*
         * Read metadata from the data storage only after we verified that the arguments are valid.
         * The input can be a file given on the command line, or the standard input stream.
         */
    Object metadata = readMetadataOrCRS();
    if (hasUnexpectedFileCount) {
        return Command.INVALID_ARGUMENT_EXIT_CODE;
    }
    if (metadata != null) {
        final List<Row> rows;
        if (metadata instanceof DefaultMetadata) {
            rows = new ArrayList<>();
            final Identifier id = ((DefaultMetadata) metadata).getMetadataIdentifier();
            if (id instanceof DefaultIdentifier) {
                CharSequence desc = ((DefaultIdentifier) id).getDescription();
                if (desc != null && !files.isEmpty())
                    desc = files.get(0);
                rows.add(new Row(State.VALID, IdentifiedObjects.toString(id), desc));
            }
            for (final ReferenceSystem rs : ((Metadata) metadata).getReferenceSystemInfo()) {
                rows.add(create(rs));
            }
        } else {
            rows = Collections.singletonList(create((ReferenceSystem) metadata));
        }
        print(rows);
    }
    return 0;
}
Also used : Identifier(org.opengis.metadata.Identifier) DefaultIdentifier(org.apache.sis.metadata.iso.DefaultIdentifier) DefaultMetadata(org.apache.sis.metadata.iso.DefaultMetadata) DefaultMetadata(org.apache.sis.metadata.iso.DefaultMetadata) Metadata(org.opengis.metadata.Metadata) DefaultIdentifier(org.apache.sis.metadata.iso.DefaultIdentifier) ReferenceSystem(org.opengis.referencing.ReferenceSystem)

Example 5 with DefaultIdentifier

use of org.apache.sis.metadata.iso.DefaultIdentifier in project sis by apache.

the class DefaultCitationTest method testIdentifierMap.

/**
 * Tests the identifier map, which handles ISBN and ISSN codes in a special way.
 */
@Test
public void testIdentifierMap() {
    final DefaultCitation citation = new DefaultCitation();
    final Collection<Identifier> identifiers = citation.getIdentifiers();
    final IdentifierMap identifierMap = citation.getIdentifierMap();
    assertTrue("Expected an initially empty set of identifiers.", identifiers.isEmpty());
    /*
         * Set the ISBN code, and ensure that the the ISBN is reflected in the identifier map.
         */
    citation.setISBN("MyISBN");
    assertEquals("MyISBN", citation.getISBN());
    assertEquals("ISBN code shall be included in the set of identifiers.", 1, identifiers.size());
    assertEquals("{ISBN=“MyISBN”}", identifierMap.toString());
    /*
         * Set the identifiers with a list containing ISBN and ISSN codes.
         * The ISBN code shall be ignored because and ISBN property was already set.
         * The ISSN code shall be retained because it is a new code.
         */
    assertNull("ISSN shall be initially null.", citation.getISSN());
    citation.setIdentifiers(Arrays.asList(new DefaultIdentifier(Citations.NETCDF, "MyNetCDF"), new DefaultIdentifier(Citations.EPSG, "MyEPSG"), new DefaultIdentifier(Citations.ISBN, "NewISBN"), new DefaultIdentifier(Citations.ISSN, "MyISSN")));
    assertEquals("The ISBN value shall have been overwritten.", "NewISBN", citation.getISBN());
    assertEquals("The ISSN value shall have been added, because new.", "MyISSN", citation.getISSN());
    assertEquals("{NetCDF=“MyNetCDF”, EPSG=“MyEPSG”, ISBN=“NewISBN”, ISSN=“MyISSN”}", identifierMap.toString());
}
Also used : DefaultIdentifier(org.apache.sis.metadata.iso.DefaultIdentifier) Identifier(org.opengis.metadata.Identifier) IdentifierMap(org.apache.sis.xml.IdentifierMap) DefaultIdentifier(org.apache.sis.metadata.iso.DefaultIdentifier) Test(org.junit.Test)

Aggregations

DefaultIdentifier (org.apache.sis.metadata.iso.DefaultIdentifier)8 DefaultMetadata (org.apache.sis.metadata.iso.DefaultMetadata)3 DefaultCitation (org.apache.sis.metadata.iso.citation.DefaultCitation)3 DefaultFeatureCatalogueDescription (org.apache.sis.metadata.iso.content.DefaultFeatureCatalogueDescription)2 DefaultImageDescription (org.apache.sis.metadata.iso.content.DefaultImageDescription)2 SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)2 Test (org.junit.Test)2 Identifier (org.opengis.metadata.Identifier)2 DefaultCitationDate (org.apache.sis.metadata.iso.citation.DefaultCitationDate)1 DefaultConstraints (org.apache.sis.metadata.iso.constraint.DefaultConstraints)1 DefaultCoverageDescription (org.apache.sis.metadata.iso.content.DefaultCoverageDescription)1 DependsOnMethod (org.apache.sis.test.DependsOnMethod)1 IdentifierMap (org.apache.sis.xml.IdentifierMap)1 Metadata (org.opengis.metadata.Metadata)1 ReferenceSystem (org.opengis.referencing.ReferenceSystem)1