/** * Creates the responsibility object if it does not already exists, then returns it. * * @return the responsibility party (never {@code null}). */ private DefaultResponsibleParty responsibility() { if (responsibility == null) { responsibility = new DefaultResponsibleParty(); } return responsibility; }
/** * set the role or position of the responsible person Only one of * {@link #getIndividualName() individualName}, {@link #getOrganisationName() organisationName} * and {@code positionName} shall be provided. * * <p>This implementation sets the position name of the first {@code 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) { if (!setName(DefaultIndividual.class, true, newValue)) { getParties().add(new DefaultIndividual(null, newValue, 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. * * @see #castOrCopy(ResponsibleParty) */ public DefaultResponsibleParty(final ResponsibleParty object) { super(object); if (object != null && !(object instanceof DefaultResponsibility)) { setIndividualName(object.getIndividualName()); setOrganisationName(object.getOrganisationName()); } }
/** * Returns the name or the position of the first individual. If no individual is found in the list of parties, * then this method will search in the list of organization members. The later structure is used by our netCDF * reader. * * @param position {@code true} for returning the position name instead than individual name. * @return the name or position of the first individual, or {@code null}. * * @see #getIndividualName() * @see #getPositionName() */ private InternationalString getIndividual(final boolean position) { final Collection<AbstractParty> parties = getParties(); InternationalString name = getName(parties, DefaultIndividual.class, position); if (name == null && parties != null) { for (final AbstractParty party : parties) { if (party instanceof DefaultOrganisation) { name = getName(((DefaultOrganisation) party).getIndividual(), DefaultIndividual.class, position); if (name != null) { break; } } } } return name; }
final DefaultResponsibleParty r = new DefaultResponsibleParty(Role.OWNER); r.setParties(Collections.singleton(party)); c.setCitedResponsibleParties(Collections.singleton(r));
/** * Creates a citation with an arbitrary title, presentation form and other properties. * * @return an arbitrary citation. * * @since 0.7 */ public static DefaultCitation create() { final DefaultCitation citation = new DefaultCitation(); final DefaultInternationalString title = new DefaultInternationalString(); title.add(Locale.JAPANESE, "アンダーカレント"); title.add(Locale.ENGLISH, "Undercurrent"); citation.setTitle(title); citation.setISBN("9782505004509"); citation.setPresentationForms(Arrays.asList( PresentationForm.DOCUMENT_HARDCOPY, PresentationForm.DOCUMENT_DIGITAL)); citation.setAlternateTitles(Collections.singleton( new SimpleInternationalString("Andākarento"))); // Actually a different script of the Japanese title. final DefaultResponsibleParty author = new DefaultResponsibleParty(Role.AUTHOR); author.setParties(Collections.singleton(new DefaultIndividual("Testsuya Toyoda", null, null))); final DefaultResponsibleParty editor = new DefaultResponsibleParty(Role.valueOf("EDITOR")); editor.setParties(Collections.singleton(new DefaultOrganisation("Kōdansha", null, null, null))); editor.setExtents(Collections.singleton(Extents.WORLD)); citation.setCitedResponsibleParties(Arrays.asList(author, editor)); return citation; }
DefaultResponsibleParty producer = new DefaultResponsibleParty(); producer.setIndividualName("John Q.Public"); producer.setOrganisationName(new SimpleInternationalString("US National Geospatial-Intelligence Agency (NGA)")); DefaultContact contact = new DefaultContact(); DefaultTelephone phone = new DefaultTelephone(); address.setElectronicMailAddresses(ema); contact.setAddress(address); producer.setContactInfo(contact); producer.setRole(Role.POINT_OF_CONTACT); source.setEdition(new SimpleInternationalString("Fifth")); List<ResponsibleParty> rps = new ArrayList<>(); DefaultResponsibleParty rp = new DefaultResponsibleParty(); rp.setOrganisationName(new SimpleInternationalString("International Hydrographic Bureau")); rp.setRole(Role.PUBLISHER); rps.add(rp); source.setCitedResponsibleParties(rps);
final DefaultResponsibleParty author = new DefaultResponsibleParty(Role.AUTHOR); final Anchor country = new Anchor(URI.create("SDN:C320:2:FR"), "France"); // Non-public SIS class. address.setElectronicMailAddresses(singleton("xx@xx.fr")); contact.setAddresses(singleton(address)); author.setParties(singleton(new DefaultOrganisation("Marine institutes", null, null, contact))); metadata.setContacts(singleton(author)); final DefaultResponsibleParty originator = new DefaultResponsibleParty(Role.ORIGINATOR); final DefaultOnlineResource online = new DefaultOnlineResource(URI.create("http://www.com.univ-mrs.fr/LOB/")); online.setProtocol("http"); address.setCountry(country); contact.setAddresses(singleton(address)); originator.setParties(singleton(new DefaultOrganisation("Oceanology laboratory", null, null, contact))); citation.setCitedResponsibleParties(singleton(originator)); final DefaultResponsibleParty custodian = new DefaultResponsibleParty((DefaultResponsibility) author); custodian.setRole(Role.CUSTODIAN); identification.setPointOfContacts(singleton(custodian)); final DefaultResponsibleParty distributor = new DefaultResponsibleParty((DefaultResponsibility) author); final DefaultDistribution distributionInfo = new DefaultDistribution(); distributor.setRole(Role.DISTRIBUTOR); distributionInfo.setDistributors(singleton(new DefaultDistributor(distributor)));
/** * Tests hash code computation of an object containing another metadata object. */ @Test @DependsOnMethod("testSimple") public void testNested() { final InternationalString title = new SimpleInternationalString("Some title"); final InternationalString person = new SimpleInternationalString("Illustre inconnu"); final DefaultIndividual party = new DefaultIndividual(person, null, null); final DefaultResponsibleParty resp = new DefaultResponsibleParty(Role.AUTHOR); final DefaultCitation instance = new DefaultCitation(title); resp.getParties().add(party); instance.getCitedResponsibleParties().add(resp); /* * Individual hash code is the sum of all its properties, none of them being a collection. */ int expected = DefaultIndividual.class.hashCode() + person.hashCode(); assertEquals("Individual", Integer.valueOf(expected), hash(party)); /* * The +31 below come from java.util.List contract, since above Individual is a list member. */ expected += ResponsibleParty.class.hashCode() + Role.AUTHOR.hashCode() + 31; assertEquals("Responsibility", Integer.valueOf(expected), hash(resp)); /* * The +31 below come from java.util.List contract, since above Responsibility is a list member. */ expected += Citation.class.hashCode() + title.hashCode() + 31; assertEquals("Citation", Integer.valueOf(expected), hash(instance)); }
/** * 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(); 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 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") @Dependencies("getParties") public Contact getContactInfo() { 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; }
final DefaultResponsibleParty r = new DefaultResponsibleParty(Role.OWNER); r.setParties(Collections.singleton(party)); c.setCitedResponsibleParties(Collections.singleton(r));
/** * Returns the name or the position of the first individual. If no individual is found in the list of parties, * then this method will search in the list of organization members. The later structure is used by our netCDF * reader. * * @param position {@code true} for returning the position name instead than individual name. * @return the name or position of the first individual, or {@code null}. * * @see #getIndividualName() * @see #getPositionName() */ private InternationalString getIndividual(final boolean position) { final Collection<AbstractParty> parties = getParties(); InternationalString name = getName(parties, DefaultIndividual.class, position); if (name == null && parties != null) { for (final AbstractParty party : parties) { if (party instanceof DefaultOrganisation) { name = getName(((DefaultOrganisation) party).getIndividual(), DefaultIndividual.class, position); if (name != null) { break; } } } } return name; }
/** * 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 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") @Dependencies("getParties") public Contact getContactInfo() { 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; }
if (presentationForm != null) c.setPresentationForms(singleton(presentationForm)); if (citedResponsibleParty != null) { final DefaultResponsibleParty r = new DefaultResponsibleParty(Role.PRINCIPAL_INVESTIGATOR); r.setParties(singleton(new DefaultOrganisation(citedResponsibleParty, null, null, null))); c.setCitedResponsibleParties(singleton(r));
/** * Creates the responsibility object if it does not already exists, then returns it. * * @return the responsibility party (never {@code null}). */ private DefaultResponsibleParty responsibility() { if (responsibility == null) { responsibility = new DefaultResponsibleParty(); } return responsibility; }
/** * set the role or position of the responsible person Only one of * {@link #getIndividualName() individualName}, {@link #getOrganisationName() organisationName} * and {@code positionName} shall be provided. * * <p>This implementation sets the position name of the first {@code 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) { if (!setName(DefaultIndividual.class, true, newValue)) { getParties().add(new DefaultIndividual(null, newValue, null)); } }
/** * Returns the name of the responsible organization. Only one of * {@link #getIndividualName() individualName}, {@code organisationName} * and {@link #getPositionName() positionName} shall be provided. * * <p>This implementation returns the name of the first {@code Organisation} * found 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") @Dependencies("getParties") public InternationalString getOrganisationName() { return getName(getParties(), DefaultOrganisation.class, false); }
/** * 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(valueIfDefined(super.getParties())); 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)); } }