/** * 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(Contact) */ public DefaultContact(final Contact object) { super(object); if (object != null) { 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); } } }
/** * Tests {@link Store#getMetadata()}. * * @throws DataStoreException if en error occurred while reading the XML. */ @Test public void testMetadata() throws DataStoreException { final Metadata metadata; try (Store store = new Store(null, new StorageConnector(new StringReader(XML)))) { metadata = store.getMetadata(); assertSame("Expected cached value.", metadata, store.getMetadata()); } final ResponsibleParty resp = getSingleton(metadata.getContacts()); final Contact contact = resp.getContactInfo(); final OnlineResource resource = contact.getOnlineResource(); assertEquals(Locale.ENGLISH, metadata.getLanguage()); if (!REGRESSION) assertEquals(CharacterSet.UTF_8, metadata.getCharacterSet()); assertEquals(Role.PRINCIPAL_INVESTIGATOR, resp.getRole()); assertEquals("Apache SIS", String.valueOf(resp.getOrganisationName())); assertEquals("http://sis.apache.org", String.valueOf(resource.getLinkage())); assertEquals(OnLineFunction.INFORMATION, resource.getFunction()); } }
/** * 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(Contact) */ public DefaultContact(final Contact object) { super(object); if (object != null) { 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); } } }
/** * 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()); }
if (contact != null) { address = contact.getAddress(); resource = contact.getOnlineResource();
if (contact != null) { address = contact.getAddress(); resource = contact.getOnlineResource();
OnlineResource resource = responsible.getContactInfo().getOnlineResource(); assertEquals("http://www.epsg.org", resource.getLinkage().toString()); assertEquals(OnLineFunction.INFORMATION, resource.getFunction());
final OnlineResource onlineResource = contact.getContactInfo().getOnlineResource(); assertNotNull("onlineResource", onlineResource); assertEquals("organisationName", "Apache SIS", contact.getOrganisationName().toString());