use of org.apache.sis.metadata.iso.citation.DefaultCitationDate 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.citation.DefaultCitationDate in project sis by apache.
the class TreeNodeChildrenTest method metadataSimplifiable.
/**
* Creates a metadata object with a property than can be simplified.
* Strictly speaking, the metadata is:
*
* {@preformat text
* DefaultCitation
* └─Date
* ├─Date………………… 2012-01-01
* └─Date type…… Creation
* }
*
* However the tree view should simplify as:
*
* {@preformat text
* DefaultCitation
* └─Date………………………… 2012-01-01
* └─Date type…… Creation
* }
*
* @see <a href="https://issues.apache.org/jira/browse/SIS-298">SIS-298</a>
*/
static DefaultCitation metadataSimplifiable() {
final DefaultCitation citation = new DefaultCitation();
final DefaultCitationDate date = new DefaultCitationDate(TestUtilities.date("2012-01-01 00:00:00"), DateType.CREATION);
assertTrue(citation.getDates().add(date));
return citation;
}
use of org.apache.sis.metadata.iso.citation.DefaultCitationDate in project sis by apache.
the class DefaultMetadataTest method testDateStamp.
/**
* Tests {@link DefaultMetadata#getDateStamp()} and {@link DefaultMetadata#setDateStamp(Date)} methods.
*/
@Test
@SuppressWarnings("deprecation")
public void testDateStamp() {
final DefaultMetadata metadata = new DefaultMetadata();
assertNull("dateStamp", metadata.getDateStamp());
/*
* Verifies that the deprecated method get its value from the CitationDate objects.
*/
Date creation = date("2014-10-07 00:00:00");
final DefaultCitationDate[] dates = new DefaultCitationDate[] { new DefaultCitationDate(date("2014-10-09 00:00:00"), DateType.valueOf("LAST_UPDATE")), new DefaultCitationDate(creation, DateType.CREATION) };
metadata.setDateInfo(Arrays.asList(dates));
assertEquals("dateStamp", creation, metadata.getDateStamp());
/*
* Invoking the deprecated setters shall modify the CitationDate object
* associated to DateType.CREATION.
*/
creation = date("2014-10-06 00:00:00");
metadata.setDateStamp(creation);
assertEquals("citationDates[1].date", creation, dates[1].getDate());
assertArrayEquals("dates", dates, metadata.getDateInfo().toArray());
}
use of org.apache.sis.metadata.iso.citation.DefaultCitationDate in project sis by apache.
the class DefaultMetadata method setDateStamp.
/**
* Sets the date that the metadata was created.
*
* @param newValue the new date stamp.
*
* @deprecated As of ISO 19115:2014, replaced by {@link #setDateInfo(Collection)}.
*/
@Deprecated
public void setDateStamp(final Date newValue) {
checkWritePermission();
// See "Note about deprecated methods implementation"
Collection<CitationDate> newValues = dateInfo;
if (newValues == null) {
if (newValue == null) {
return;
}
newValues = new ArrayList<>(1);
} else {
final Iterator<CitationDate> it = newValues.iterator();
while (it.hasNext()) {
final CitationDate date = it.next();
if (DateType.CREATION.equals(date.getDateType())) {
if (newValue == null) {
it.remove();
return;
}
if (date instanceof DefaultCitationDate) {
((DefaultCitationDate) date).setDate(newValue);
return;
}
it.remove();
break;
}
}
}
newValues.add(new DefaultCitationDate(newValue, DateType.CREATION));
setDateInfo(newValues);
}
use of org.apache.sis.metadata.iso.citation.DefaultCitationDate in project sis by apache.
the class DefaultMaintenanceInformation method setDateOfNextUpdate.
/**
* Sets the scheduled revision date for resource.
* This method stores the value in the {@linkplain #getMaintenanceDates() maintenance dates}.
*
* @param newValue the new date of next update.
*/
@Deprecated
public void setDateOfNextUpdate(final Date newValue) {
checkWritePermission();
Collection<CitationDate> dates = maintenanceDates;
if (dates != null) {
final Iterator<CitationDate> it = dates.iterator();
while (it.hasNext()) {
final CitationDate date = it.next();
if (NEXT_UPDATE.equals(date.getDateType())) {
if (newValue == null) {
it.remove();
return;
} else if (date instanceof DefaultCitationDate) {
((DefaultCitationDate) date).setDate(newValue);
return;
}
}
}
}
if (newValue != null) {
final CitationDate date = new DefaultCitationDate(newValue, NEXT_UPDATE);
if (dates != null) {
dates.add(date);
} else {
dates = Collections.singleton(date);
}
setMaintenanceDates(dates);
}
}
Aggregations