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;
}
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;
}
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());
}
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;
}
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());
}
Aggregations