You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2014/09/19 23:46:44 UTC
svn commit: r1626345 [3/14] - in /sis/trunk: ./
core/sis-feature/src/main/java/org/apache/sis/feature/
core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/
core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/gml/
core/sis-metadat...
Copied: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/AbstractParty.java (from r1625241, sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/AbstractParty.java)
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/AbstractParty.java?p2=sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/AbstractParty.java&p1=sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/AbstractParty.java&r1=1625241&r2=1626345&rev=1626345&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/AbstractParty.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/AbstractParty.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -22,16 +22,27 @@ import javax.xml.bind.annotation.XmlRoot
import javax.xml.bind.annotation.XmlType;
import org.opengis.util.InternationalString;
import org.opengis.metadata.citation.Contact;
-import org.opengis.metadata.citation.Individual;
-import org.opengis.metadata.citation.Organisation;
-import org.opengis.metadata.citation.Party;
import org.apache.sis.metadata.iso.ISOMetadata;
import org.apache.sis.util.iso.Types;
+// Branch-specific imports
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Obligation.CONDITIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
+
/**
* Information about the individual and / or organization of the party.
*
+ * <div class="warning"><b>Note on International Standard versions</b><br>
+ * This class is derived from a new type defined in the ISO 19115 international standard published in 2014,
+ * while GeoAPI 3.0 is based on the version published in 2003. Consequently this implementation class does
+ * not yet implement a GeoAPI interface, but is expected to do so after the next GeoAPI releases.
+ * When the interface will become available, all references to this implementation class in Apache SIS will
+ * be replaced be references to the corresponding interface.
+ * </div>
+ *
* <p><b>Limitations:</b></p>
* <ul>
* <li>Instances of this class are not synchronized for multi-threading.
@@ -52,7 +63,8 @@ import org.apache.sis.util.iso.Types;
"contactInfo"
})
@XmlRootElement(name = "CI_Party")
-public class AbstractParty extends ISOMetadata implements Party {
+@UML(identifier="CI_Party", specification=ISO_19115)
+public class AbstractParty extends ISOMetadata {
/**
* Serial number for compatibility with different versions.
*/
@@ -91,10 +103,8 @@ public class AbstractParty extends ISOMe
* given object are not recursively copied.
*
* @param object The metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(Party)
*/
- public AbstractParty(final Party object) {
+ public AbstractParty(final AbstractParty object) {
super(object);
if (object != null) {
name = object.getName();
@@ -103,47 +113,12 @@ public class AbstractParty extends ISOMe
}
/**
- * Returns a SIS metadata implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is an instance of {@link Individual} or {@link Organisation},
- * then this method delegates to the {@code castOrCopy(…)} method of the corresponding SIS subclass.
- * Note that if the given object implements more than one of the above-cited interfaces,
- * then the {@code castOrCopy(…)} method to be used is unspecified.</li>
- * <li>Otherwise if the given object is already an instance of
- * {@code AbstractParty}, then it is returned unchanged.</li>
- * <li>Otherwise a new {@code AbstractParty} instance is created using the
- * {@linkplain #AbstractParty(Party) copy constructor} and returned.
- * Note that this is a <cite>shallow</cite> copy operation, since the other
- * metadata contained in the given object are not recursively copied.</li>
- * </ul>
- *
- * @param object The object to get as a SIS implementation, or {@code null} if none.
- * @return A SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static AbstractParty castOrCopy(final Party object) {
- if (object instanceof Individual) {
- return DefaultIndividual.castOrCopy((Individual) object);
- }
- if (object instanceof Organisation) {
- return DefaultOrganisation.castOrCopy((Organisation) object);
- }
- if (object == null || object instanceof AbstractParty) {
- return (AbstractParty) object;
- }
- return new AbstractParty(object);
- }
-
- /**
* Return the name of the party.
*
* @return Name of the party.
*/
- @Override
@XmlElement(name = "name")
+ @UML(identifier="name", obligation=CONDITIONAL, specification=ISO_19115)
public InternationalString getName() {
return name;
}
@@ -163,8 +138,8 @@ public class AbstractParty extends ISOMe
*
* @return Contact information for the party.
*/
- @Override
@XmlElement(name = "contactInfo")
+ @UML(identifier="contactInfo", obligation=OPTIONAL, specification=ISO_19115)
public Collection<Contact> getContactInfo() {
return contactInfo = nonNullCollection(contactInfo, Contact.class);
}
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultAddress.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultAddress.java?rev=1626345&r1=1626344&r2=1626345&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultAddress.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultAddress.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -28,6 +28,15 @@ import org.apache.sis.metadata.iso.ISOMe
/**
* Location of the responsible individual or organization.
*
+ * <p><b>Limitations:</b></p>
+ * <ul>
+ * <li>Instances of this class are not synchronized for multi-threading.
+ * Synchronization, if needed, is caller's responsibility.</li>
+ * <li>Serialized objects of this class are not guaranteed to be compatible with future Apache SIS releases.
+ * Serialization support is appropriate for short term storage or RMI between applications running the
+ * same version of Apache SIS. For long term storage, use {@link org.apache.sis.xml.XML} instead.</li>
+ * </ul>
+ *
* @author Martin Desruisseaux (IRD, Geomatys)
* @author Touraïvane (IRD)
* @author Cédric Briançon (Geomatys)
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultCitation.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultCitation.java?rev=1626345&r1=1626344&r2=1626345&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultCitation.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultCitation.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -24,9 +24,11 @@ import javax.xml.bind.annotation.XmlRoot
import org.opengis.metadata.Identifier;
import org.opengis.metadata.citation.Citation;
import org.opengis.metadata.citation.CitationDate;
+import org.opengis.metadata.citation.OnlineResource;
import org.opengis.metadata.citation.PresentationForm;
import org.opengis.metadata.citation.ResponsibleParty;
import org.opengis.metadata.citation.Series;
+import org.opengis.metadata.identification.BrowseGraphic;
import org.opengis.util.InternationalString;
import org.apache.sis.util.iso.Types;
import org.apache.sis.util.iso.SimpleInternationalString;
@@ -49,10 +51,20 @@ import static org.apache.sis.internal.me
* other identifiers. Consequently the ISBN and ISSN codes are included in the collection
* returned by {@link #getIdentifiers()}, except at XML marshalling time (for ISO 19139 compliance).
*
+ * {@section Limitations}
+ * <ul>
+ * <li>Instances of this class are not synchronized for multi-threading.
+ * Synchronization, if needed, is caller's responsibility.</li>
+ * <li>Serialized objects of this class are not guaranteed to be compatible with future Apache SIS releases.
+ * Serialization support is appropriate for short term storage or RMI between applications running the
+ * same version of Apache SIS. For long term storage, use {@link org.apache.sis.xml.XML} instead.</li>
+ * </ul>
+ *
* @author Martin Desruisseaux (IRD, Geomatys)
* @author Cédric Briançon (Geomatys)
+ * @author Rémi Maréchal (Geomatys)
* @since 0.3 (derived from geotk-2.1)
- * @version 0.3
+ * @version 0.5
* @module
*/
@XmlType(name = "CI_Citation_Type", propOrder = {
@@ -125,7 +137,7 @@ public class DefaultCitation extends ISO
private long editionDate = Long.MIN_VALUE;
/**
- * Name and position information for an individual or organization that is responsible
+ * Roles, Name, contact, and position information for an individual or organization that is responsible
* for the resource. Returns an empty collection if there is none.
*/
private Collection<ResponsibleParty> citedResponsibleParties;
@@ -151,10 +163,23 @@ public class DefaultCitation extends ISO
* Common title with holdings note. Note: title identifies elements of a series
* collectively, combined with information about what volumes are available at the
* source cited. May be {@code null} if there is no title.
+ *
+ * @deprecated Removed as of ISO 19115:2014.
*/
+ @Deprecated
private InternationalString collectiveTitle;
/**
+ * Online references to the cited resource.
+ */
+ private Collection<OnlineResource> onlineResources;
+
+ /**
+ * Citation graphic or logo for cited party.
+ */
+ private Collection<BrowseGraphic> graphics;
+
+ /**
* Constructs an initially empty citation.
*/
public DefaultCitation() {
@@ -174,13 +199,16 @@ public class DefaultCitation extends ISO
* Constructs a citation with the specified responsible party.
* This convenience constructor initializes the citation title
* to the first non-null of the following properties:
- * {@linkplain DefaultResponsibleParty#getOrganisationName() organisation name},
+ * {@linkplain DefaultResponsibleParty#getOrganisationName() organization name},
* {@linkplain DefaultResponsibleParty#getPositionName() position name} or
* {@linkplain DefaultResponsibleParty#getIndividualName() individual name}.
*
* @param party The name and position information for an individual or organization that is
* responsible for the resource, or {@code null} if none.
+ *
+ * @deprecated As of ISO 19115:2014, {@link ResponsibleParty} has been replaced by {@code Responsibility}.
*/
+ @Deprecated
public DefaultCitation(final ResponsibleParty party) {
if (party != null) {
citedResponsibleParties = singleton(party, ResponsibleParty.class);
@@ -220,6 +248,11 @@ public class DefaultCitation extends ISO
series = object.getSeries();
otherCitationDetails = object.getOtherCitationDetails();
collectiveTitle = object.getCollectiveTitle();
+ if (object instanceof DefaultCitation) {
+ final DefaultCitation c = (DefaultCitation) object;
+ onlineResources = copyCollection(c.getOnlineResources(), OnlineResource.class);
+ graphics = copyCollection(c.getGraphics(), BrowseGraphic.class);
+ }
final String id1 = object.getISBN();
final String id2 = object.getISSN();
if (id1 != null || id2 != null) {
@@ -277,8 +310,9 @@ public class DefaultCitation extends ISO
}
/**
- * Returns the short name or other language name by which the cited information is known.
- * Example: "DCW" as an alternative title for "<cite>Digital Chart of the World</cite>".
+ * Returns short name or other language name by which the cited information is known.
+ *
+ * <div class="note"><b>Example:</b> "DCW" as an alternative title for "Digital Chart of the World".</div>
*
* @return Other names for the resource, or an empty collection if none.
*/
@@ -361,7 +395,8 @@ public class DefaultCitation extends ISO
/**
* Returns the unique identifier for the resource.
- * Example: Universal Product Code (UPC), National Stock Number (NSN).
+ *
+ * <div class="note"><b>Example:</b> Universal Product Code (UPC), National Stock Number (NSN).</div>
*
* {@section Unified identifiers view}
* In this SIS implementation, the collection returned by this method includes the XML identifiers
@@ -408,8 +443,13 @@ public class DefaultCitation extends ISO
}
/**
- * Returns the name and position information for an individual or organization that is
- * responsible for the resource.
+ * Returns the role, name, contact and position information for an individual or organization
+ * that is responsible for the resource.
+ *
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * As of ISO 19115:2014, {@code ResponsibleParty} is replaced by the {@link Responsibility} parent interface.
+ * This change may be applied in GeoAPI 4.0.
+ * </div>
*
* @return The individual or organization that is responsible, or an empty collection if none.
*/
@@ -420,8 +460,13 @@ public class DefaultCitation extends ISO
}
/**
- * Sets the name and position information for an individual or organization that is responsible
- * for the resource.
+ * Sets the role, name, contact and position information for an individual or organization
+ * that is responsible for the resource.
+ *
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * As of ISO 19115:2014, {@code ResponsibleParty} is replaced by the {@link Responsibility} parent interface.
+ * This change may be applied in GeoAPI 4.0.
+ * </div>
*
* @param newValues The new cited responsible parties, or {@code null} if none.
*/
@@ -473,6 +518,11 @@ public class DefaultCitation extends ISO
/**
* Returns other information required to complete the citation that is not recorded elsewhere.
*
+ * <div class="warning"><b>Upcoming API change — multiplicity</b><br>
+ * As of ISO 19115:2014, this singleton has been replaced by a collection.
+ * This change may be applied in GeoAPI 4.0.
+ * </div>
+ *
* @return Other details, or {@code null} if none.
*/
@Override
@@ -484,6 +534,11 @@ public class DefaultCitation extends ISO
/**
* Sets other information required to complete the citation that is not recorded elsewhere.
*
+ * <div class="warning"><b>Upcoming API change — multiplicity</b><br>
+ * As of ISO 19115:2014, this singleton has been replaced by a collection.
+ * This change may be applied in GeoAPI 4.0.
+ * </div>
+ *
* @param newValue Other citations details, or {@code null} if none.
*/
public void setOtherCitationDetails(final InternationalString newValue) {
@@ -492,12 +547,14 @@ public class DefaultCitation extends ISO
}
/**
- * Returns the common title with holdings note. Note: title identifies elements of a series collectively,
- * combined with information about what volumes are available at the source cited.
+ * Returns the common title with holdings note.
*
* @return The common title, or {@code null} if none.
+ *
+ * @deprecated Removed as of ISO 19115:2014.
*/
@Override
+ @Deprecated
@XmlElement(name = "collectiveTitle")
public InternationalString getCollectiveTitle() {
return collectiveTitle;
@@ -508,7 +565,10 @@ public class DefaultCitation extends ISO
* combined with information about what volumes are available at the source cited.
*
* @param newValue The new collective title, or {@code null} if none.
+ *
+ * @deprecated Removed as of ISO 19115:2014.
*/
+ @Deprecated
public void setCollectiveTitle(final InternationalString newValue) {
checkWritePermission();
collectiveTitle = newValue;
@@ -591,4 +651,50 @@ public class DefaultCitation extends ISO
getIdentifierMap().putSpecialized(ISSN, newValue);
}
}
+
+ /**
+ * Returns online references to the cited resource.
+ *
+ * @return Online references to the cited resource, or an empty collection if there is none.
+ *
+ * @since 0.5
+ */
+/// @XmlElement(name = "onlineResource")
+ public Collection<OnlineResource> getOnlineResources() {
+ return onlineResources = nonNullCollection(onlineResources, OnlineResource.class);
+ }
+
+ /**
+ * Sets online references to the cited resource.
+ *
+ * @param newValues The new online references to the cited resource.
+ *
+ * @since 0.5
+ */
+ public void setOnlineResources(final Collection<? extends OnlineResource> newValues) {
+ onlineResources = writeCollection(newValues, onlineResources, OnlineResource.class);
+ }
+
+ /**
+ * Returns citation graphics or logo for cited party.
+ *
+ * @return Graphics or logo for cited party, or an empty collection if there is none.
+ *
+ * @since 0.5
+ */
+/// @XmlElement(name = "graphic")
+ public Collection<BrowseGraphic> getGraphics() {
+ return graphics = nonNullCollection(graphics, BrowseGraphic.class);
+ }
+
+ /**
+ * Sets citation graphics or logo for cited party.
+ *
+ * @param newValues The new citation graphics or logo for cited party.
+ *
+ * @since 0.5
+ */
+ public void setGraphics(final Collection<? extends BrowseGraphic> newValues) {
+ graphics = writeCollection(newValues, graphics, BrowseGraphic.class);
+ }
}
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultCitationDate.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultCitationDate.java?rev=1626345&r1=1626344&r2=1626345&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultCitationDate.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultCitationDate.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -31,6 +31,15 @@ import static org.apache.sis.internal.me
/**
* Reference date and event used to describe it.
*
+ * <p><b>Limitations:</b></p>
+ * <ul>
+ * <li>Instances of this class are not synchronized for multi-threading.
+ * Synchronization, if needed, is caller's responsibility.</li>
+ * <li>Serialized objects of this class are not guaranteed to be compatible with future Apache SIS releases.
+ * Serialization support is appropriate for short term storage or RMI between applications running the
+ * same version of Apache SIS. For long term storage, use {@link org.apache.sis.xml.XML} instead.</li>
+ * </ul>
+ *
* @author Martin Desruisseaux (IRD, Geomatys)
* @author Cédric Briançon (Geomatys)
* @since 0.3 (derived from geotk-2.1)
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultContact.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultContact.java?rev=1626345&r1=1626344&r2=1626345&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultContact.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultContact.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -16,6 +16,9 @@
*/
package org.apache.sis.metadata.iso.citation;
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.Collection;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
@@ -25,16 +28,29 @@ import org.opengis.metadata.citation.Con
import org.opengis.metadata.citation.Telephone;
import org.opengis.metadata.citation.OnlineResource;
import org.apache.sis.metadata.iso.ISOMetadata;
+import org.apache.sis.util.resources.Messages;
+import org.apache.sis.internal.jaxb.Context;
+import org.apache.sis.internal.metadata.LegacyPropertyAdapter;
/**
* Information required to enable contact with the responsible person and/or organization.
*
+ * <p><b>Limitations:</b></p>
+ * <ul>
+ * <li>Instances of this class are not synchronized for multi-threading.
+ * Synchronization, if needed, is caller's responsibility.</li>
+ * <li>Serialized objects of this class are not guaranteed to be compatible with future Apache SIS releases.
+ * Serialization support is appropriate for short term storage or RMI between applications running the
+ * same version of Apache SIS. For long term storage, use {@link org.apache.sis.xml.XML} instead.</li>
+ * </ul>
+ *
* @author Martin Desruisseaux (IRD, Geomatys)
* @author Touraïvane (IRD)
* @author Cédric Briançon (Geomatys)
+ * @author Rémi Maréchal (Geomatys)
* @since 0.3 (derived from geotk-2.1)
- * @version 0.3
+ * @version 0.5
* @module
*/
@XmlType(name = "CI_Contact_Type", propOrder = {
@@ -49,22 +65,22 @@ public class DefaultContact extends ISOM
/**
* Serial number for inter-operability with different versions.
*/
- private static final long serialVersionUID = 3844283689911660546L;
+ private static final long serialVersionUID = -969735574940462381L;
/**
* Telephone numbers at which the organization or individual may be contacted.
*/
- private Telephone phone;
+ private Collection<Telephone> phones;
/**
- * Physical and email address at which the organization or individual may be contacted.
+ * Physical and email addresses at which the organization or individual may be contacted.
*/
- private Address address;
+ private Collection<Address> addresses;
/**
* On-line information that can be used to contact the individual or organization.
*/
- private OnlineResource onlineResource;
+ private Collection<OnlineResource> onlineResources;
/**
* Time period (including time zone) when individuals can contact the organization or individual.
@@ -77,6 +93,11 @@ public class DefaultContact extends ISOM
private InternationalString contactInstructions;
/**
+ * Type of the contact.
+ */
+ private InternationalString contactType;
+
+ /**
* Constructs an initially empty contact.
*/
public DefaultContact() {
@@ -89,7 +110,7 @@ public class DefaultContact extends ISOM
* organization, or {@code null} if none.
*/
public DefaultContact(final OnlineResource resource) {
- this.onlineResource = resource;
+ this.onlineResources = singleton(resource, OnlineResource.class);
}
/**
@@ -104,11 +125,19 @@ public class DefaultContact extends ISOM
public DefaultContact(final Contact object) {
super(object);
if (object != null) {
- phone = object.getPhone();
- address = object.getAddress();
- onlineResource = object.getOnlineResource();
hoursOfService = object.getHoursOfService();
contactInstructions = object.getContactInstructions();
+ if (object instanceof DefaultContact) {
+ final DefaultContact c = (DefaultContact) object;
+ phones = copyCollection(c.getPhones(), Telephone.class);
+ addresses = copyCollection(c.getAddresses(), Address.class);
+ onlineResources = copyCollection(c.getOnlineResources(), OnlineResource.class);
+ contactType = c.getContactType();
+ } else {
+ phones = singleton(object.getPhone(), Telephone.class);
+ addresses = singleton(object.getAddress(), Address.class);
+ onlineResources = singleton(object.getOnlineResource(), OnlineResource.class);
+ }
}
}
@@ -140,64 +169,207 @@ public class DefaultContact extends ISOM
/**
* Returns telephone numbers at which the organization or individual may be contacted.
*
+ * @return Telephone numbers at which the organization or individual may be contacted.
+ *
+ * @since 0.5
+ */
+ public Collection<Telephone> getPhones() {
+ return phones = nonNullCollection(phones, Telephone.class);
+ }
+
+ /**
+ * Sets telephone numbers at which the organization or individual may be contacted.
+ *
+ * @param newValues The new telephones.
+ *
+ * @since 0.5
+ */
+ public void setPhones(Collection<? extends Telephone> newValues) {
+ phones = writeCollection(newValues, phones, Telephone.class);
+ /*
+ * Code below this point will be deleted after we removed the deprecated methods in DefaultTelephone.
+ * This code notifies all DefaultTelephone instances about the the list of phones in order to allow
+ * the deprecated Telephone.getVoices() and Telephone.getFacsimiles() methods to fetches information
+ * from the phones list.
+ */
+ if (phones != null) {
+ boolean modified = false;
+ final Telephone[] p = phones.toArray(new Telephone[newValues.size()]);
+ for (int i=0; i<p.length; i++) {
+ final Telephone phone = p[i];
+ if (phone instanceof DefaultTelephone) {
+ p[i] = ((DefaultTelephone) phone).setOwner(phones);
+ modified |= (p[i] != phone);
+ }
+ }
+ if (modified) {
+ phones.clear();
+ phones.addAll(Arrays.asList(p));
+ }
+ }
+ }
+
+ /**
+ * Returns telephone numbers at which the organization or individual may be contacted.
+ * This method returns the first telephone number associated to {@link TelephoneType#VOICE}
+ * or {@link TelephoneType#FACSIMILE FACSIMILE}.
+ *
* @return Telephone numbers at which the organization or individual may be contacted, or {@code null}.
+ *
+ * @deprecated As of ISO 19115:2014, replaced by {@link #getPhones()}.
*/
@Override
+ @Deprecated
@XmlElement(name = "phone")
- public Telephone getPhone() {
+ public final Telephone getPhone() {
+ Telephone phone = null;
+ if (phones != null) {
+ TelephoneType ignored = null;
+ for (final Telephone c : phones) {
+ if (c instanceof DefaultTelephone) {
+ final TelephoneType type = ((DefaultTelephone) c).numberType;
+ if (TelephoneType.VOICE.equals(type) || TelephoneType.FACSIMILE.equals(type)) {
+ if (phone == null) {
+ phone = c;
+ }
+ } else if (ignored == null) {
+ ignored = type;
+ }
+ }
+ }
+ if (ignored != null) {
+ Context.warningOccured(Context.current(), DefaultContact.class, "getPhone",
+ Messages.class, Messages.Keys.IgnoredPropertyAssociatedTo_1, ignored.toString());
+ }
+ }
return phone;
}
/**
* Sets telephone numbers at which the organization or individual may be contacted.
+ * This method delegates to {@link #setPhones(Collection)}.
*
* @param newValue The new telephone, or {@code null} if none.
+ *
+ * @deprecated As of ISO 19115:2014, replaced by {@link #setPhones(Collection)}.
*/
- public void setPhone(final Telephone newValue) {
- checkWritePermission();
- phone = newValue;
+ @Deprecated
+ public final void setPhone(Telephone newValue) {
+ Collection<Telephone> newValues = null;
+ if (newValue != null) {
+ if (newValue instanceof DefaultTelephone) {
+ newValues = ((DefaultTelephone) newValue).getOwner();
+ } else {
+ newValues = new ArrayList<Telephone>(4);
+ for (String number : newValue.getVoices()) {
+ newValues.add(new DefaultTelephone(number, TelephoneType.VOICE));
+ }
+ for (String number : newValue.getFacsimiles()) {
+ newValues.add(new DefaultTelephone(number, TelephoneType.FACSIMILE));
+ }
+ }
+ }
+ setPhones(newValues);
+ }
+
+ /**
+ * Returns the physical and email addresses at which the organization or individual may be contacted.
+ *
+ * @return Physical and email addresses at which the organization or individual may be contacted, or {@code null}.
+ *
+ * @since 0.5
+ */
+ public Collection<Address> getAddresses() {
+ return addresses = nonNullCollection(addresses, Address.class);
+ }
+
+ /**
+ * Sets the physical and email addresses at which the organization or individual may be contacted.
+ *
+ * @param newValues The new addresses.
+ *
+ * @since 0.5
+ */
+ public void setAddresses(final Collection<? extends Address> newValues) {
+ addresses = writeCollection(newValues, addresses, Address.class);
}
/**
* Returns the physical and email address at which the organization or individual may be contacted.
+ * This method returns the first {@link #getAddresses() adress} element, or null if none.
*
* @return Physical and email address at which the organization or individual may be contacted, or {@code null}.
+ *
+ * @deprecated As of ISO 19115:2014, replaced by {@link #getAddresses()}.
*/
@Override
+ @Deprecated
@XmlElement(name = "address")
- public Address getAddress() {
- return address;
+ public final Address getAddress() {
+ return LegacyPropertyAdapter.getSingleton(addresses, Address.class, null, DefaultContact.class, "getAddress");
}
/**
* Sets the physical and email address at which the organization or individual may be contacted.
+ * This method delegates to {@link #setAddresses(Collection)}.
*
* @param newValue The new address, or {@code null} if none.
+ *
+ * @deprecated As of ISO 19115:2014, replaced by {@link #setAddresses(Collection)}.
*/
- public void setAddress(final Address newValue) {
- checkWritePermission();
- address = newValue;
+ @Deprecated
+ public final void setAddress(final Address newValue) {
+ setAddresses(LegacyPropertyAdapter.asCollection(newValue));
+ }
+
+ /**
+ * Returns on-line information that can be used to contact the individual or organization.
+ *
+ * @return On-line information that can be used to contact the individual or organization.
+ *
+ * @since 0.5
+ */
+ public Collection<OnlineResource> getOnlineResources() {
+ return onlineResources = nonNullCollection(onlineResources, OnlineResource.class);
+ }
+
+ /**
+ * Sets on-line information that can be used to contact the individual or organization.
+ *
+ * @param newValues The new online resources.
+ *
+ * @since 0.5
+ */
+ public void setOnlineResources(final Collection<? extends OnlineResource> newValues) {
+ onlineResources = writeCollection(newValues, onlineResources, OnlineResource.class);
}
/**
- * Return on-line information that can be used to contact the individual or organization.
+ * Returns on-line information that can be used to contact the individual or organization.
+ * This method returns the first {@link #getOnlineResources() online resource} element, or null if none.
*
* @return On-line information that can be used to contact the individual or organization, or {@code null}.
+ *
+ * @deprecated As of ISO 19115:2014, replaced by {@link #getOnlineResources()}.
*/
@Override
+ @Deprecated
@XmlElement(name = "onlineResource")
public OnlineResource getOnlineResource() {
- return onlineResource;
+ return LegacyPropertyAdapter.getSingleton(onlineResources, OnlineResource.class, null, DefaultContact.class, "getOnlineResource");
}
/**
* Sets on-line information that can be used to contact the individual or organization.
+ * This method delegates to {@link #setOnlineResources(Collection)}.
*
* @param newValue The new online resource, or {@code null} if none.
+ *
+ * @deprecated As of ISO 19115:2014, replaced by {@link #setOnlineResources(Collection)}.
*/
+ @Deprecated
public void setOnlineResource(final OnlineResource newValue) {
- checkWritePermission();
- onlineResource = newValue;
+ setOnlineResources(LegacyPropertyAdapter.asCollection(newValue));
}
/**
@@ -241,4 +413,29 @@ public class DefaultContact extends ISOM
checkWritePermission();
contactInstructions = newValue;
}
+
+ /**
+ * Type of the contact.
+ * Returns {@code null} if none.
+ *
+ * @return Type of the contact, or {@code null} if none.
+ *
+ * @since 0.5
+ */
+/// @XmlElement(name = "contactType")
+ public InternationalString getContactType() {
+ return contactType;
+ }
+
+ /**
+ * Sets new type of the contact.
+ *
+ * @param newValue The new type of the contact.
+ *
+ * @since 0.5
+ */
+ public void setContactType(final InternationalString newValue) {
+ checkWritePermission();
+ contactType = newValue;
+ }
}
Copied: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultIndividual.java (from r1625241, sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultIndividual.java)
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultIndividual.java?p2=sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultIndividual.java&p1=sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultIndividual.java&r1=1625241&r2=1626345&rev=1626345&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultIndividual.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultIndividual.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -20,14 +20,26 @@ import javax.xml.bind.annotation.XmlType
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.opengis.metadata.citation.Contact;
-import org.opengis.metadata.citation.Individual;
import org.opengis.util.InternationalString;
import org.apache.sis.util.iso.Types;
+// Branch-specific imports
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.CONDITIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
+
/**
* Information about the party if the party is an individual.
*
+ * <div class="warning"><b>Note on International Standard versions</b><br>
+ * This class is derived from a new type defined in the ISO 19115 international standard published in 2014,
+ * while GeoAPI 3.0 is based on the version published in 2003. Consequently this implementation class does
+ * not yet implement a GeoAPI interface, but is expected to do so after the next GeoAPI releases.
+ * When the interface will become available, all references to this implementation class in Apache SIS will
+ * be replaced be references to the corresponding interface.
+ * </div>
+ *
* <p><b>Limitations:</b></p>
* <ul>
* <li>Instances of this class are not synchronized for multi-threading.
@@ -47,7 +59,8 @@ import org.apache.sis.util.iso.Types;
"positionName"
})
@XmlRootElement(name = "CI_Individual")
-public class DefaultIndividual extends AbstractParty implements Individual {
+@UML(identifier="CI_Individual", specification=ISO_19115)
+public class DefaultIndividual extends AbstractParty {
/**
* Serial number for inter-operability with different versions.
*/
@@ -85,10 +98,8 @@ public class DefaultIndividual extends A
* given object are not recursively copied.
*
* @param object The metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(Individual)
*/
- public DefaultIndividual(final Individual object) {
+ public DefaultIndividual(final DefaultIndividual object) {
super(object);
if (object != null) {
positionName = object.getPositionName();
@@ -96,37 +107,12 @@ public class DefaultIndividual extends A
}
/**
- * Returns a SIS metadata implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is already an instance of
- * {@code DefaultIndividual}, then it is returned unchanged.</li>
- * <li>Otherwise a new {@code DefaultIndividual} instance is created using the
- * {@linkplain #DefaultIndividual(Individual) copy constructor}
- * and returned. Note that this is a <cite>shallow</cite> copy operation, since the other
- * metadata contained in the given object are not recursively copied.</li>
- * </ul>
- *
- * @param object The object to get as a SIS implementation, or {@code null} if none.
- * @return A SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static DefaultIndividual castOrCopy(final Individual object) {
- if (object == null || object instanceof DefaultIndividual) {
- return (DefaultIndividual) object;
- }
- return new DefaultIndividual(object);
- }
-
- /**
* Returns position of the individual in an organization, or {@code null} if none.
*
* @return Position of the individual in an organization, or {@code null} if none.
*/
- @Override
@XmlElement(name = "positionName")
+ @UML(identifier="positionName", obligation=CONDITIONAL, specification=ISO_19115)
public InternationalString getPositionName() {
return positionName;
}
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultOnlineResource.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultOnlineResource.java?rev=1626345&r1=1626344&r2=1626345&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultOnlineResource.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultOnlineResource.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -30,11 +30,20 @@ import org.apache.sis.metadata.iso.ISOMe
* Information about on-line sources from which the dataset, specification, or
* community profile name and extended metadata elements can be obtained.
*
+ * <p><b>Limitations:</b></p>
+ * <ul>
+ * <li>Instances of this class are not synchronized for multi-threading.
+ * Synchronization, if needed, is caller's responsibility.</li>
+ * <li>Serialized objects of this class are not guaranteed to be compatible with future Apache SIS releases.
+ * Serialization support is appropriate for short term storage or RMI between applications running the
+ * same version of Apache SIS. For long term storage, use {@link org.apache.sis.xml.XML} instead.</li>
+ * </ul>
+ *
* @author Martin Desruisseaux (IRD, Geomatys)
* @author Touraïvane (IRD)
* @author Cédric Briançon (Geomatys)
* @since 0.3 (derived from geotk-2.1)
- * @version 0.3
+ * @version 0.5
* @module
*/
@XmlType(name = "CI_OnlineResource_Type", propOrder = {
@@ -84,6 +93,12 @@ public class DefaultOnlineResource exten
private OnLineFunction function;
/**
+ * Request used to access the resource depending on the protocol.
+ * This is used mainly for POST requests.
+ */
+ private String protocolRequest;
+
+ /**
* Creates an initially empty on line resource.
*/
public DefaultOnlineResource() {
@@ -117,6 +132,9 @@ public class DefaultOnlineResource exten
name = object.getName();
description = object.getDescription();
function = object.getFunction();
+ if (object instanceof DefaultOnlineResource) {
+ protocolRequest = ((DefaultOnlineResource) object).getProtocolRequest();
+ }
}
}
@@ -232,7 +250,7 @@ public class DefaultOnlineResource exten
/**
* Returns the location (address) for on-line access using a Uniform Resource Locator address or
- * similar addressing scheme such as "{@code http://www.statkart.no/isotc211}".
+ * similar addressing scheme.
*
* @return Location for on-line access using a Uniform Resource Locator address or similar scheme, or {@code null}.
*/
@@ -256,6 +274,10 @@ public class DefaultOnlineResource exten
/**
* Returns the connection protocol to be used.
*
+ * <div class="note"><b>Example:</b>
+ * ftp, http get KVP, http POST, <i>etc</i>.
+ * </div>
+ *
* @return Connection protocol to be used, or {@code null}.
*/
@Override
@@ -265,7 +287,7 @@ public class DefaultOnlineResource exten
}
/**
- * Returns the connection protocol to be used.
+ * Sets the connection protocol to be used.
*
* @param newValue The new protocol, or {@code null} if none.
*/
@@ -273,4 +295,38 @@ public class DefaultOnlineResource exten
checkWritePermission();
protocol = newValue;
}
+
+ /**
+ * Returns the request used to access the resource depending on the protocol.
+ * This is used mainly for POST requests.
+ *
+ * <div class="note"><b>Example:</b>
+ * {@preformat xml
+ * <GetFeature service="WFS" version="2.0.0"
+ * outputFormat="application/gml+xml;verson=3.2"
+ * xmlns="(…snip…)">
+ * <Query typeNames="Roads"/>
+ * </GetFeature>
+ * }
+ * </div>
+ *
+ * @return Request used to access the resource.
+ *
+ * @since 0.5
+ */
+ public String getProtocolRequest() {
+ return protocolRequest;
+ }
+
+ /**
+ * Sets the request to be used.
+ *
+ * @param newValue The new request, or {@code null} if none.
+ *
+ * @since 0.5
+ */
+ public void setProtocolRequest(final String newValue) {
+ checkWritePermission();
+ protocolRequest = newValue;
+ }
}
Copied: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultOrganisation.java (from r1625241, sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultOrganisation.java)
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultOrganisation.java?p2=sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultOrganisation.java&p1=sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultOrganisation.java&r1=1625241&r2=1626345&rev=1626345&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultOrganisation.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultOrganisation.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -21,14 +21,26 @@ import javax.xml.bind.annotation.XmlType
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import org.opengis.metadata.citation.Contact;
-import org.opengis.metadata.citation.Individual;
-import org.opengis.metadata.citation.Organisation;
import org.opengis.metadata.identification.BrowseGraphic;
+// Branch-specific imports
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Obligation.CONDITIONAL;
+import static org.opengis.annotation.Specification.ISO_19115;
+
/**
* Information about the party if the party is an organization.
*
+ * <div class="warning"><b>Note on International Standard versions</b><br>
+ * This class is derived from a new type defined in the ISO 19115 international standard published in 2014,
+ * while GeoAPI 3.0 is based on the version published in 2003. Consequently this implementation class does
+ * not yet implement a GeoAPI interface, but is expected to do so after the next GeoAPI releases.
+ * When the interface will become available, all references to this implementation class in Apache SIS will
+ * be replaced be references to the corresponding interface.
+ * </div>
+ *
* <p><b>Limitations:</b></p>
* <ul>
* <li>Instances of this class are not synchronized for multi-threading.
@@ -49,7 +61,8 @@ import org.opengis.metadata.identificati
"individual"
})
@XmlRootElement(name = "CI_Organisation")
-public class DefaultOrganisation extends AbstractParty implements Organisation {
+@UML(identifier="CI_Organisation", specification=ISO_19115)
+public class DefaultOrganisation extends AbstractParty {
/**
* Serial number for inter-operability with different versions.
*/
@@ -63,7 +76,7 @@ public class DefaultOrganisation extends
/**
* Individuals in the named organization.
*/
- private Collection<Individual> individual;
+ private Collection<DefaultIndividual> individual;
/**
* Constructs an initially empty organization.
@@ -81,12 +94,12 @@ public class DefaultOrganisation extends
*/
public DefaultOrganisation(final CharSequence name,
final BrowseGraphic logo,
- final Individual individual,
+ final DefaultIndividual individual,
final Contact contactInfo)
{
super(name, contactInfo);
this.logo = singleton(logo, BrowseGraphic.class);
- this.individual = singleton(individual, Individual.class);
+ this.individual = singleton(individual, DefaultIndividual.class);
}
/**
@@ -95,40 +108,13 @@ public class DefaultOrganisation extends
* given object are not recursively copied.
*
* @param object The metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(Organisation)
*/
- public DefaultOrganisation(final Organisation object) {
+ public DefaultOrganisation(final DefaultOrganisation object) {
super(object);
if (object != null) {
logo = copyCollection(object.getLogo(), BrowseGraphic.class);
- individual = copyCollection(object.getIndividual(), Individual.class);
- }
- }
-
- /**
- * Returns a SIS metadata implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is already an instance of
- * {@code DefaultOrganisation}, then it is returned unchanged.</li>
- * <li>Otherwise a new {@code DefaultOrganisation} instance is created using the
- * {@linkplain #DefaultOrganisation(Organisation) copy constructor}
- * and returned. Note that this is a <cite>shallow</cite> copy operation, since the other
- * metadata contained in the given object are not recursively copied.</li>
- * </ul>
- *
- * @param object The object to get as a SIS implementation, or {@code null} if none.
- * @return A SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static DefaultOrganisation castOrCopy(final Organisation object) {
- if (object == null || object instanceof DefaultOrganisation) {
- return (DefaultOrganisation) object;
+ individual = copyCollection(object.getIndividual(), DefaultIndividual.class);
}
- return new DefaultOrganisation(object);
}
/**
@@ -136,8 +122,8 @@ public class DefaultOrganisation extends
*
* @return Graphics identifying organization, or an empty collection if there is none.
*/
- @Override
@XmlElement(name = "logo")
+ @UML(identifier="logo", obligation=CONDITIONAL, specification=ISO_19115)
public Collection<BrowseGraphic> getLogo() {
return logo = nonNullCollection(logo, BrowseGraphic.class);
}
@@ -154,20 +140,30 @@ public class DefaultOrganisation extends
/**
* Returns the individuals in the named organization.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The element type will be changed to the {@code Individual} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @return Individuals in the named organization, or an empty collection.
*/
- @Override
@XmlElement(name = "individual")
- public Collection<Individual> getIndividual() {
- return individual = nonNullCollection(individual, Individual.class);
+ @UML(identifier="individual", obligation=OPTIONAL, specification=ISO_19115)
+ public Collection<DefaultIndividual> getIndividual() {
+ return individual = nonNullCollection(individual, DefaultIndividual.class);
}
/**
* Sets the individuals in the named organization.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The element type will be changed to the {@code Individual} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @param newValues The new individuals in the named organization.
*/
- public void setIndividual(final Collection<? extends Individual> newValues) {
- individual = writeCollection(newValues, individual, Individual.class);
+ public void setIndividual(final Collection<? extends DefaultIndividual> newValues) {
+ individual = writeCollection(newValues, individual, DefaultIndividual.class);
}
}
Copied: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultResponsibility.java (from r1625241, sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultResponsibility.java)
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultResponsibility.java?p2=sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultResponsibility.java&p1=sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultResponsibility.java&r1=1625241&r2=1626345&rev=1626345&view=diff
==============================================================================
--- sis/branches/JDK6/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultResponsibility.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultResponsibility.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -20,16 +20,29 @@ import java.util.Collection;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
-import org.opengis.metadata.citation.Party;
-import org.opengis.metadata.citation.Responsibility;
import org.opengis.metadata.citation.Role;
import org.opengis.metadata.extent.Extent;
+import org.opengis.metadata.citation.ResponsibleParty;
import org.apache.sis.metadata.iso.ISOMetadata;
+// Branch-specific imports
+import org.opengis.annotation.UML;
+import static org.opengis.annotation.Obligation.OPTIONAL;
+import static org.opengis.annotation.Obligation.MANDATORY;
+import static org.opengis.annotation.Specification.ISO_19115;
+
/**
* Information about the party and their role.
*
+ * <div class="warning"><b>Note on International Standard versions</b><br>
+ * This class is derived from a new type defined in the ISO 19115 international standard published in 2014,
+ * while GeoAPI 3.0 is based on the version published in 2003. Consequently this implementation class does
+ * not yet implement a GeoAPI interface, but is expected to do so after the next GeoAPI releases.
+ * When the interface will become available, all references to this implementation class in Apache SIS will
+ * be replaced be references to the corresponding interface.
+ * </div>
+ *
* <p><b>Limitations:</b></p>
* <ul>
* <li>Instances of this class are not synchronized for multi-threading.
@@ -51,7 +64,8 @@ import org.apache.sis.metadata.iso.ISOMe
/// "parties"
})
@XmlRootElement(name = "CI_Responsibility")
-public class DefaultResponsibility extends ISOMetadata implements Responsibility {
+@UML(identifier="CI_Responsibility", specification=ISO_19115)
+public class DefaultResponsibility extends ISOMetadata {
/**
* Serial number for inter-operability with different versions.
*/
@@ -70,7 +84,7 @@ public class DefaultResponsibility exten
/**
* Information about the parties.
*/
- private Collection<Party> parties;
+ private Collection<AbstractParty> parties;
/**
* Constructs an initially empty responsible party.
@@ -85,10 +99,10 @@ public class DefaultResponsibility exten
* @param extent Spatial or temporal extent of the role, or {@code null}.
* @param party Information about the party, or {@code null}.
*/
- public DefaultResponsibility(final Role role, final Extent extent, final Party party) {
+ public DefaultResponsibility(final Role role, final Extent extent, final AbstractParty party) {
this.role = role;
this.extents = singleton(extent, Extent.class);
- this.parties = singleton(party, Party.class);
+ this.parties = singleton(party, AbstractParty.class);
}
/**
@@ -97,40 +111,29 @@ public class DefaultResponsibility exten
* given object are not recursively copied.
*
* @param object The metadata to copy values from, or {@code null} if none.
- *
- * @see #castOrCopy(Responsibility)
*/
- public DefaultResponsibility(final Responsibility object) {
+ public DefaultResponsibility(final DefaultResponsibility object) {
+ super(object);
if (object != null) {
this.role = object.getRole();
this.extents = copyCollection(object.getExtents(), Extent.class);
- this.parties = copyCollection(object.getParties(), Party.class);
+ this.parties = copyCollection(object.getParties(), AbstractParty.class);
}
}
/**
- * Returns a SIS metadata implementation with the values of the given arbitrary implementation.
- * This method performs the first applicable action in the following choices:
- *
- * <ul>
- * <li>If the given object is {@code null}, then this method returns {@code null}.</li>
- * <li>Otherwise if the given object is already an instance of
- * {@code DefaultResponsibility}, then it is returned unchanged.</li>
- * <li>Otherwise a new {@code DefaultResponsibility} instance is created using the
- * {@linkplain #DefaultResponsibility(Responsibility) copy constructor}
- * and returned. Note that this is a <cite>shallow</cite> copy operation, since the other
- * Responsibility contained in the given object are not recursively copied.</li>
- * </ul>
- *
- * @param object The object to get as a SIS implementation, or {@code null} if none.
- * @return A SIS implementation containing the values of the given object (may be the
- * given object itself), or {@code null} if the argument was null.
- */
- public static DefaultResponsibility castOrCopy(final Responsibility object) {
- if (object == null || object instanceof DefaultResponsibility) {
- return (DefaultResponsibility) object;
+ * Bridge constructor for {@link DefaultResponsibleParty#DefaultResponsibleParty(ResponsibleParty)}.
+ */
+ DefaultResponsibility(final ResponsibleParty object) {
+ super(object);
+ if (object != null) {
+ this.role = object.getRole();
+ if (object instanceof DefaultResponsibility) {
+ final DefaultResponsibility c = (DefaultResponsibility) object;
+ this.extents = copyCollection(c.getExtents(), Extent.class);
+ this.parties = copyCollection(c.getParties(), AbstractParty.class);
+ }
}
- return new DefaultResponsibility(object);
}
/**
@@ -138,8 +141,8 @@ public class DefaultResponsibility exten
*
* @return Function performed by the responsible party.
*/
- @Override
/// @XmlElement(name = "role", required = true)
+ @UML(identifier="role", obligation=MANDATORY, specification=ISO_19115)
public Role getRole() {
return role;
}
@@ -159,8 +162,8 @@ public class DefaultResponsibility exten
*
* @return The spatial or temporal extents of the role.
*/
- @Override
/// @XmlElement(name = "extent")
+ @UML(identifier="extent", obligation=OPTIONAL, specification=ISO_19115)
public Collection<Extent> getExtents() {
return extents = nonNullCollection(extents, Extent.class);
}
@@ -177,20 +180,30 @@ public class DefaultResponsibility exten
/**
* Returns information about the parties.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The element type will be changed to the {@code Party} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @return Information about the parties.
*/
- @Override
/// @XmlElement(name = "party", required = true)
- public Collection<Party> getParties() {
- return parties = nonNullCollection(parties, Party.class);
+ @UML(identifier="party", obligation=MANDATORY, specification=ISO_19115)
+ public Collection<AbstractParty> getParties() {
+ return parties = nonNullCollection(parties, AbstractParty.class);
}
/**
* Sets information about the parties.
*
+ * <div class="warning"><b>Upcoming API change — generalization</b><br>
+ * The element type will be changed to the {@code Party} interface
+ * when GeoAPI will provide it (tentatively in GeoAPI 3.1).
+ * </div>
+ *
* @param newValues New information about the parties.
*/
- public void setParties(final Collection<? extends Party> newValues) {
- parties = writeCollection(newValues, parties, Party.class);
+ public void setParties(final Collection<? extends AbstractParty> newValues) {
+ parties = writeCollection(newValues, parties, AbstractParty.class);
}
}
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultResponsibleParty.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultResponsibleParty.java?rev=1626345&r1=1626344&r2=1626345&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultResponsibleParty.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultResponsibleParty.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -16,6 +16,9 @@
*/
package org.apache.sis.metadata.iso.citation;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Collections;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@@ -23,18 +26,24 @@ import org.opengis.metadata.citation.Con
import org.opengis.metadata.citation.ResponsibleParty;
import org.opengis.metadata.citation.Role;
import org.opengis.util.InternationalString;
-import org.apache.sis.metadata.iso.ISOMetadata;
+import org.apache.sis.util.iso.Types;
/**
* Identification of, and means of communication with, person(s) and
* organizations associated with the dataset.
*
+ * <div class="warning"><b>Upcoming API change — deprecation</b><br>
+ * As of ISO 19115:2014, the {@code ResponsibleParty} type has been replaced by {@code Responsibility}
+ * to allow more flexible associations of individuals, organisations, and roles.
+ * This {@code ResponsibleParty} interface may be deprecated in GeoAPI 4.0.
+ * </div>
+ *
* @author Martin Desruisseaux (IRD, Geomatys)
* @author Touraïvane (IRD)
* @author Cédric Briançon (Geomatys)
* @since 0.3 (derived from geotk-2.1)
- * @version 0.3
+ * @version 0.5
* @module
*/
@XmlType(name = "CI_ResponsibleParty_Type", propOrder = {
@@ -45,36 +54,11 @@ import org.apache.sis.metadata.iso.ISOMe
"role"
})
@XmlRootElement(name = "CI_ResponsibleParty")
-public class DefaultResponsibleParty extends ISOMetadata implements ResponsibleParty {
+public class DefaultResponsibleParty extends DefaultResponsibility implements ResponsibleParty {
/**
* Serial number for inter-operability with different versions.
*/
- private static final long serialVersionUID = -3429257224445006902L;
-
- /**
- * Name of the responsible person- surname, given name, title separated by a delimiter.
- */
- private String individualName;
-
- /**
- * Name of the responsible organization.
- */
- private InternationalString organisationName;
-
- /**
- * Role or position of the responsible person
- */
- private InternationalString positionName;
-
- /**
- * Address of the responsible party.
- */
- private Contact contactInfo;
-
- /**
- * Function performed by the responsible party.
- */
- private Role role;
+ private static final long serialVersionUID = -1022635486627088812L;
/**
* Constructs an initially empty responsible party.
@@ -88,7 +72,18 @@ public class DefaultResponsibleParty ext
* @param role The function performed by the responsible party, or {@code null}.
*/
public DefaultResponsibleParty(final Role role) {
- this.role = role;
+ super(role, null, null);
+ }
+
+ /**
+ * 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.
+ */
+ public DefaultResponsibleParty(final DefaultResponsibility object) {
+ super(object);
}
/**
@@ -102,12 +97,9 @@ public class DefaultResponsibleParty ext
*/
public DefaultResponsibleParty(final ResponsibleParty object) {
super(object);
- if (object != null) {
- individualName = object.getIndividualName();
- organisationName = object.getOrganisationName();
- positionName = object.getPositionName();
- contactInfo = object.getContactInfo();
- role = object.getRole();
+ if (object != null && !(object instanceof DefaultResponsibility)) {
+ setIndividualName(object.getIndividualName());
+ setOrganisationName(object.getOrganisationName());
}
}
@@ -137,16 +129,71 @@ public class DefaultResponsibleParty ext
}
/**
+ * Returns the name of the first party of the given type, or {@code null} if none.
+ */
+ private InternationalString getName(final Class<? extends AbstractParty> type, final boolean position) {
+ final Collection<AbstractParty> parties = getParties();
+ if (parties != null) { // May be null on marshalling.
+ for (final AbstractParty party : parties) {
+ if (type.isInstance(party)) {
+ final InternationalString name;
+ if (position) {
+ name = ((DefaultIndividual) party).getPositionName();
+ } else {
+ name = party.getName();
+ }
+ if (name != null) {
+ return name;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Sets the name of the first party of the given type.
+ *
+ * @return {@code true} if the name has been set, or {@code false} otherwise.
+ */
+ private boolean setName(final Class<? extends AbstractParty> type, final boolean position, final InternationalString name) {
+ checkWritePermission();
+ final Iterator<AbstractParty> it = getParties().iterator();
+ while (it.hasNext()) {
+ final AbstractParty party = it.next();
+ if (type.isInstance(party)) {
+ if (position) {
+ ((DefaultIndividual) party).setPositionName(name);
+ } else {
+ party.setName(name);
+ }
+ if (party.isEmpty()) {
+ it.remove();
+ }
+ return true;
+ }
+ }
+ return name == null; // If no party and name is null, there is nothing to set.
+ }
+
+ /**
* Returns the name of the responsible person- surname, given name, title separated by a delimiter.
* Only one of {@code individualName}, {@link #getOrganisationName() organisationName}
* and {@link #getPositionName() positionName} shall be provided.
*
+ * <p>This implementation returns the first non-null name of an {@link Individual}
+ * in the collection of {@linkplain #getParties() parties}.</p>
+ *
* @return Name, surname, given name and title of the responsible person, or {@code null}.
+ *
+ * @deprecated As of ISO 19115:2014, replaced by {@code getName()} in {@link DefaultIndividual}.
*/
@Override
+ @Deprecated
@XmlElement(name = "individualName")
public String getIndividualName() {
- return individualName;
+ final InternationalString name = getName(DefaultIndividual.class, false);
+ return (name != null) ? name.toString() : null;
}
/**
@@ -154,11 +201,18 @@ public class DefaultResponsibleParty ext
* Only one of {@code individualName}, {@link #getOrganisationName() organisationName}
* and {@link #getPositionName() positionName} shall be provided.
*
+ * <p>This implementation sets the name of the first {@link Individual} found in the collection of
+ * {@linkplain #getParties() parties}, or create a new individual if no existing instance was found.</p>
+ *
* @param newValue The new individual name, or {@code null} if none.
+ *
+ * @deprecated As of ISO 19115:2014, replaced by {@code setName(InternationalString)} in {@link DefaultIndividual}.
*/
+ @Deprecated
public void setIndividualName(final String newValue) {
- checkWritePermission();
- individualName = newValue;
+ if (!setName(DefaultIndividual.class, false, Types.toInternationalString(newValue))) {
+ getParties().add(new DefaultIndividual(newValue, null, null));
+ }
}
/**
@@ -166,12 +220,18 @@ public class DefaultResponsibleParty ext
* {@link #getIndividualName() individualName}, {@code organisationName}
* and {@link #getPositionName() positionName} shall be provided.
*
+ * <p>This implementation returns the first non-null name of an {@link Organisation}
+ * in the collection of {@linkplain #getParties() parties}.</p>
+ *
* @return Name of the responsible organization, or {@code null}.
+ *
+ * @deprecated As of ISO 19115:2014, replaced by {@code getName()} in {@link DefaultOrganisation}.
*/
@Override
+ @Deprecated
@XmlElement(name = "organisationName")
public InternationalString getOrganisationName() {
- return organisationName;
+ return getName(DefaultOrganisation.class, false);
}
/**
@@ -179,11 +239,18 @@ public class DefaultResponsibleParty ext
* {@link #getIndividualName() individualName}, {@code organisationName}
* and {@link #getPositionName() positionName} shall be provided.
*
+ * <p>This implementation sets the name of the first {@link Organisation} found in the collection of
+ * {@linkplain #getParties() parties}, or create a new organization if no existing instance was found.</p>
+ *
* @param newValue The new organization name, or {@code null} if none.
+ *
+ * @deprecated As of ISO 19115:2014, replaced by {@code setName(InternationalString)} in {@link DefaultOrganisation}.
*/
+ @Deprecated
public void setOrganisationName(final InternationalString newValue) {
- checkWritePermission();
- organisationName = newValue;
+ if (!setName(DefaultOrganisation.class, false, Types.toInternationalString(newValue))) {
+ getParties().add(new DefaultOrganisation(newValue, null, null, null));
+ }
}
/**
@@ -191,12 +258,18 @@ public class DefaultResponsibleParty ext
* {@link #getIndividualName() individualName}, {@link #getOrganisationName() organisationName}
* and {@code positionName} shall be provided.
*
+ * <p>This implementation returns the first non-null position name of an {@link Individual}
+ * in the collection of {@linkplain #getParties() parties}.</p>
+ *
* @return Role or position of the responsible person, or {@code null}
+ *
+ * @deprecated As of ISO 19115:2014, replaced by {@link DefaultIndividual#getPositionName()}.
*/
@Override
+ @Deprecated
@XmlElement(name = "positionName")
public InternationalString getPositionName() {
- return positionName;
+ return getName(DefaultIndividual.class, true);
}
/**
@@ -204,52 +277,99 @@ public class DefaultResponsibleParty ext
* {@link #getIndividualName() individualName}, {@link #getOrganisationName() organisationName}
* and {@code positionName} shall be provided.
*
+ * <p>This implementation sets the position name of the first {@link Individual} found in the collection of
+ * {@linkplain #getParties() parties}, or create a new individual if no existing instance was found.</p>
+ *
* @param newValue The new position name, or {@code null} if none.
+ *
+ * @deprecated As of ISO 19115:2014, replaced by {@link DefaultIndividual#setPositionName(InternationalString)}.
*/
+ @Deprecated
public void setPositionName(final InternationalString newValue) {
- checkWritePermission();
- positionName = newValue;
+ if (!setName(DefaultIndividual.class, true, newValue)) {
+ getParties().add(new DefaultIndividual(null, newValue, null));
+ }
}
/**
* Returns the address of the responsible party.
*
+ * <p>This implementation returns the first non-null contact found in the collection of
+ * {@linkplain #getParties() parties}.</p>
+ *
* @return Address of the responsible party, or {@code null}.
+ *
+ * @deprecated As of ISO 19115:2014, replaced by {@link AbstractParty#getContactInfo()}.
*/
@Override
+ @Deprecated
@XmlElement(name = "contactInfo")
public Contact getContactInfo() {
- return contactInfo;
+ final Collection<AbstractParty> parties = getParties();
+ if (parties != null) { // May be null on marshalling.
+ for (final AbstractParty party : parties) {
+ final Collection<? extends Contact> contacts = party.getContactInfo();
+ if (contacts != null) { // May be null on marshalling.
+ for (final Contact contact : contacts) {
+ if (contact != null) { // Paranoiac check.
+ return contact;
+ }
+ }
+ }
+ }
+ }
+ return null;
}
/**
* Sets the address of the responsible party.
*
+ * <p>This implementation sets the contact info in the first party found in the collection of
+ * {@linkplain #getParties() parties}.</p>
+ *
* @param newValue The new contact info, or {@code null} if none.
+ *
+ * @deprecated As of ISO 19115:2014, replaced by {@link AbstractParty#setContactInfo(Collection)}.
*/
+ @Deprecated
public void setContactInfo(final Contact newValue) {
checkWritePermission();
- contactInfo = newValue;
+ final Iterator<AbstractParty> it = getParties().iterator();
+ while (it.hasNext()) {
+ final AbstractParty party = it.next();
+ party.setContactInfo(newValue != null ? Collections.singleton(newValue) : null);
+ if (party.isEmpty()) {
+ it.remove();
+ }
+ return;
+ }
+ /*
+ * If no existing AbstractParty were found, add a new one. However there is no way to know if
+ * it should be an individual or an organization. Arbitrarily choose an individual for now.
+ */
+ if (newValue != null) {
+ getParties().add(new DefaultIndividual(null, null, newValue));
+ }
}
/**
* Returns the function performed by the responsible party.
*
- * @return Function performed by the responsible party, or {@code null}.
- */
+ * @return Function performed by the responsible party.
+ */
@Override
@XmlElement(name = "role", required = true)
public Role getRole() {
- return role;
+ return super.getRole();
}
/**
* Sets the function performed by the responsible party.
*
- * @param newValue The new role, or {@code null} if none.
+ * @param newValue The new role.
*/
+ @Override
public void setRole(final Role newValue) {
- checkWritePermission();
- role = newValue;
+ super.setRole(newValue);
}
}
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultSeries.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultSeries.java?rev=1626345&r1=1626344&r2=1626345&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultSeries.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultSeries.java [UTF-8] Fri Sep 19 21:46:39 2014
@@ -28,6 +28,15 @@ import org.apache.sis.util.iso.Types;
/**
* Information about the series, or aggregate dataset, to which a dataset belongs.
*
+ * <p><b>Limitations:</b></p>
+ * <ul>
+ * <li>Instances of this class are not synchronized for multi-threading.
+ * Synchronization, if needed, is caller's responsibility.</li>
+ * <li>Serialized objects of this class are not guaranteed to be compatible with future Apache SIS releases.
+ * Serialization support is appropriate for short term storage or RMI between applications running the
+ * same version of Apache SIS. For long term storage, use {@link org.apache.sis.xml.XML} instead.</li>
+ * </ul>
+ *
* @author Martin Desruisseaux (IRD, Geomatys)
* @author Cédric Briançon (Geomatys)
* @since 0.3 (derived from geotk-2.1)