private void getMetaDataDateInfo(Metadata metadata, DefaultMetadata defaultMetaData){ ArrayList<CitationDate> citationDateList= (ArrayList<CitationDate>) defaultMetaData.getDateInfo(); for(CitationDate c:citationDateList){ if(c.getDateType()!=null) { String date = DateUtils.formatDate(c.getDate()); metadata.add("DateInfo ",c.getDateType().name()+" "+date); } } }
/** * Constructs a metadata entity initialized with the values from the specified metadata. * * @param source * @since 2.4 */ public DefaultCitationDate(final CitationDate source) { super(source); if (source != null) { // Be careful to not overwrite date value (GEOTK-170). if (date == 0 && source.getDate() == null) { date = Long.MIN_VALUE; } } }
/** * Constructs a new instance initialized with the values from the specified metadata object. * This is a <cite>shallow</cite> copy constructor, since the other metadata contained in the * given object are not recursively copied. * * @param object the metadata to copy values from, or {@code null} if none. * * @see #castOrCopy(CitationDate) */ public DefaultCitationDate(final CitationDate object) { super(object); if (object != null) { date = toMilliseconds(object.getDate()); dateType = object.getDateType(); } }
/** * Copies properties from the given ISO 19115 metadata. */ private Copyright(final LegalConstraints c, final Locale locale) { if (!(c instanceof DefaultConstraints)) { return; } resp: for (final DefaultResponsibility r : ((DefaultConstraints) c).getResponsibleParties()) { for (final AbstractParty p : r.getParties()) { author = Types.toString(p.getName(), locale); if (author != null) break resp; } } for (final Citation ci : ((DefaultConstraints) c).getReferences()) { for (final CitationDate d : ci.getDates()) { final Date date = d.getDate(); if (date != null) { year = date.getYear() + 1900; break; } } if (!(ci instanceof DefaultCitation)) continue; for (final OnlineResource r : ((DefaultCitation) ci).getOnlineResources()) { license = r.getLinkage(); if (license != null) break; } } }
/** * Constructs a new instance initialized with the values from the specified metadata object. * This is a <cite>shallow</cite> copy constructor, since the other metadata contained in the * given object are not recursively copied. * * @param object the metadata to copy values from, or {@code null} if none. * * @see #castOrCopy(CitationDate) */ public DefaultCitationDate(final CitationDate object) { super(object); if (object != null) { date = toMilliseconds(object.getDate()); dateType = object.getDateType(); } }
time = d.getDate(); if (time != null) break;
for (CitationDate d:dateArrayList) { if (d.getDateType()!=null) { String date = DateUtils.formatDate(d.getDate()); metadata.add("CitationDate ",d.getDateType().name()+"-->"+date); for (CitationDate cd:citationDates) { if (cd.getDateType()!=null) { String date = DateUtils.formatDate(cd.getDate()); metadata.add("ThesaurusNameDate ",cd.getDateType().name() +"-->" + date); if (cd.getDateType()!=null && cd.getDate()!=null) { String date = DateUtils.formatDate(cd.getDate()); metadata.add("GeographicIdentifierAuthorityDate ",cd.getDateType().name()+" "+date);
/** * Verifies the metadata that contains the result of parsing a copyright statement. * Should contains the "John Smith" name and 1992 year. * * @param notice the copyright statement to parse. */ private static void verifyCopyrightParsing(final String notice) { final MetadataBuilder builder = new MetadataBuilder(); builder.parseLegalNotice(notice); final DefaultLegalConstraints constraints = (DefaultLegalConstraints) getSingleton(getSingleton( builder.build(false).getIdentificationInfo()).getResourceConstraints()); assertEquals("useConstraints", Restriction.COPYRIGHT, getSingleton(constraints.getUseConstraints())); final Citation ref = getSingleton(constraints.getReferences()); assertTitleEquals("reference.title", notice, ref); assertPartyNameEquals("reference.citedResponsibleParty", "John Smith", (DefaultCitation) ref); assertEquals("date", date("1992-01-01 00:00:00"), getSingleton(ref.getDates()).getDate()); } }
private void getMetaDataDateInfo(Metadata metadata, DefaultMetadata defaultMetaData){ ArrayList<CitationDate> citationDateList= (ArrayList<CitationDate>) defaultMetaData.getDateInfo(); for(CitationDate c:citationDateList){ if(c.getDateType()!=null) metadata.add("DateInfo ",c.getDateType().name()+" "+c.getDate()); } }
private void getMetaDataDateInfo(Metadata metadata, DefaultMetadata defaultMetaData){ ArrayList<CitationDate> citationDateList= (ArrayList<CitationDate>) defaultMetaData.getDateInfo(); for(CitationDate c:citationDateList){ if(c.getDateType()!=null) metadata.add("DateInfo ",c.getDateType().name()+" "+c.getDate()); } }
/** * Adds a date in the given collection, making sure that there is no two dates of the same type. * If two dates are of the same type, retains the latest one if the type name starts with {@code "LATE_"} * or retains the earliest date otherwise. */ private static void addEarliest(final Collection<CitationDate> dates, final CitationDate cd, final DateType type) { for (final Iterator<CitationDate> it = dates.iterator(); it.hasNext();) { final CitationDate co = it.next(); if (type.equals(co.getDateType())) { final Date oldDate = co.getDate(); final Date newDate = cd.getDate(); if (type.name().startsWith("LATE_") ? oldDate.before(newDate) : oldDate.after(newDate)) { it.remove(); break; } return; } } dates.add(cd); }
/** * Adds a date in the given collection, making sure that there is no two dates of the same type. * If two dates are of the same type, retains the latest one if the type name starts with {@code "LATE_"} * or retains the earliest date otherwise. */ private static void addEarliest(final Collection<CitationDate> dates, final CitationDate cd, final DateType type) { for (final Iterator<CitationDate> it = dates.iterator(); it.hasNext();) { final CitationDate co = it.next(); if (type.equals(co.getDateType())) { final Date oldDate = co.getDate(); final Date newDate = cd.getDate(); if (type.name().startsWith("LATE_") ? oldDate.before(newDate) : oldDate.after(newDate)) { it.remove(); break; } return; } } dates.add(cd); }
/** * Returns the date that the metadata was created. * * @return date that the metadata was created, or {@code null}. * * @deprecated As of ISO 19115:2014, replaced by {@link #getDateInfo()}. */ @Override @Deprecated @XmlElement(name = "dateStamp", required = true) @Dependencies("getDateInfo") public Date getDateStamp() { final Collection<CitationDate> dates = getDateInfo(); if (dates != null) { for (final CitationDate date : dates) { if (DateType.CREATION.equals(date.getDateType())) { return date.getDate(); } } } return null; }
/** * Returns the scheduled revision date for resource. * This method fetches the value from the {@linkplain #getMaintenanceDates() maintenance dates}. * * @return scheduled revision date, or {@code null}. * * @deprecated As of ISO 19115:2014, replaced by {@link #getMaintenanceDates()} in order to enable inclusion * of a {@link DateType} to describe the type of the date. The associated date type is * {@code DateType.valueOf("NEXT_UPDATE")}. */ @Override @Deprecated @XmlElement(name = "dateOfNextUpdate") @Dependencies("getMaintenanceDates") public Date getDateOfNextUpdate() { final Collection<CitationDate> dates = getMaintenanceDates(); if (dates != null) { // May be null on XML marshalling. for (final CitationDate date : dates) { if (NEXT_UPDATE.equals(date.getDateType())) { return date.getDate(); } } } return null; }
/** * Returns the date that the metadata was created. * * @return date that the metadata was created, or {@code null}. * * @deprecated As of ISO 19115:2014, replaced by {@link #getDateInfo()}. */ @Override @Deprecated @Dependencies("getDateInfo") @XmlElement(name = "dateStamp", namespace = LegacyNamespaces.GMD) public Date getDateStamp() { if (FilterByVersion.LEGACY_METADATA.accept()) { final Collection<CitationDate> dates = getDateInfo(); if (dates != null) { for (final CitationDate date : dates) { if (DateType.CREATION.equals(date.getDateType())) { return date.getDate(); } } } } return null; }
/** * Returns the scheduled revision date for resource. * This method fetches the value from the {@linkplain #getMaintenanceDates() maintenance dates}. * * @return scheduled revision date, or {@code null}. * * @deprecated As of ISO 19115:2014, replaced by {@link #getMaintenanceDates()} in order to enable inclusion * of a {@link DateType} to describe the type of the date. The associated date type is * {@code DateType.valueOf("NEXT_UPDATE")}. */ @Override @Deprecated @Dependencies("getMaintenanceDates") @XmlElement(name = "dateOfNextUpdate", namespace = LegacyNamespaces.GMD) public Date getDateOfNextUpdate() { if (FilterByVersion.LEGACY_METADATA.accept()) { final Collection<CitationDate> dates = getMaintenanceDates(); if (dates != null) { // May be null on XML marshalling. for (final CitationDate date : dates) { if (NEXT_UPDATE.equals(date.getDateType())) { return date.getDate(); } } } } return null; }
if (date != null) { final DateType type = date.getDateType(); final Date time = date.getDate(); mandatory("CitationDate: shall have a date type.", type); mandatory("CitationDate: shall have a timestamp.", time);
/** * Tests XML unmarshalling for a metadata version. * The version is not specified since it should be detected automatically. * * @param file file containing the metadata to unmarshal. */ private void testUnmarshalling(final String file) throws JAXBException { final DefaultCitation c = unmarshalFile(DefaultCitation.class, file); assertTitleEquals("title", "Fight against poverty", c); final CitationDate date = getSingleton(c.getDates()); assertEquals("date", date.getDate(), TestUtilities.date("2015-10-17 00:00:00")); assertEquals("dateType", DateType.valueOf("adopted"), date.getDateType()); assertEquals("presentationForm", PresentationForm.valueOf("physicalObject"), getSingleton(c.getPresentationForms())); final Iterator<ResponsibleParty> it = c.getCitedResponsibleParties().iterator(); final Contact contact = assertResponsibilityEquals(Role.ORIGINATOR, "Maid Marian", it.next()); assertEquals("Contact instruction", "Send carrier pigeon.", String.valueOf(contact.getContactInstructions())); final OnlineResource resource = contact.getOnlineResource(); assertEquals("Resource name", "IP over Avian Carriers", String.valueOf(resource.getName())); assertEquals("Resource description", "High delay, low throughput, and low altitude service.", String.valueOf(resource.getDescription())); assertEquals("Resource linkage", "https://tools.ietf.org/html/rfc1149", String.valueOf(resource.getLinkage())); assertEquals("Resource function", OnLineFunction.OFFLINE_ACCESS, resource.getFunction()); // Thanks to xlink:href, the Contact shall be the same instance as above. assertSame("contact", contact, assertResponsibilityEquals(Role.valueOf("funder"), "Robin Hood", it.next())); assertFalse(it.hasNext()); }
for (CitationDate d:dateArrayList){ if(d.getDateType()!=null) metadata.add("CitationDate ",d.getDateType().name()+"-->"+d.getDate()); for(CitationDate cd:citationDates) { if(cd.getDateType()!=null) metadata.add("ThesaurusNameDate ",cd.getDateType().name() +"-->" + cd.getDate()); if(cd.getDateType()!=null && cd.getDate()!=null) metadata.add("GeographicIdentifierAuthorityDate ",cd.getDateType().name()+" "+cd.getDate().toString());
for (final CitationDate date : dates) { if (DateType.CREATION.equals(date.getDateType())) { creationDate = date.getDate(); if (creationDate != null) break;