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); } } }
if (d.getDateType()!=null) { String date = DateUtils.formatDate(d.getDate()); metadata.add("CitationDate ",d.getDateType().name()+"-->"+date); 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);
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); }
/** * 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(); } }
/** * 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(); } }
while (it.hasNext()) { final CitationDate date = it.next(); if (DateType.CREATION.equals(date.getDateType())) { if (newValue == null) { it.remove();
while (it.hasNext()) { final CitationDate date = it.next(); if (NEXT_UPDATE.equals(date.getDateType())) { if (newValue == null) { it.remove();
/** * 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; }
while (it.hasNext()) { final CitationDate date = it.next(); if (DateType.CREATION.equals(date.getDateType())) { if (newValue == null) { it.remove();
/** * 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; }
while (it.hasNext()) { final CitationDate date = it.next(); if (NEXT_UPDATE.equals(date.getDateType())) { if (newValue == null) { it.remove();
/** * 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; }
for (final CitationDate date : dates) { if (date != null) { final DateType type = date.getDateType(); final Date time = date.getDate(); mandatory("CitationDate: shall have a date type.", type);
/** * Implementation of {@link #testLocalization()} and {@link #testLocalizationLegacyXML()}. */ private void testLocalization(final boolean legacy) throws JAXBException { final MarshallerPool pool = getMarshallerPool(); final Marshaller marshaller = pool.acquireMarshaller(); if (legacy) { marshaller.setProperty(XML.METADATA_VERSION, VERSION_2007); } /* * First, test using the French locale. */ marshaller.setProperty(XML.LOCALE, Locale.FRENCH); String expected = getCitationXML("fra", "Création", legacy); CitationDate ci = unmarshal(CitationDate.class, expected); assertEquals(DateType.CREATION, ci.getDateType()); String actual = marshal(marshaller, ci); assertXmlEquals(expected, actual, "xmlns:*"); /* * Tests again using the English locale. */ marshaller.setProperty(XML.LOCALE, Locale.ENGLISH); expected = getCitationXML("eng", "Creation", legacy); ci = unmarshal(CitationDate.class, expected); assertEquals(DateType.CREATION, ci.getDateType()); actual = marshal(marshaller, ci); assertXmlEquals(expected, actual, "xmlns:*"); pool.recycle(marshaller); }
/** * 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()); }
Date creationDate = null; for (final CitationDate date : dates) { if (DateType.CREATION.equals(date.getDateType())) { creationDate = date.getDate(); if (creationDate != null) break;