ArrayList<OnlineResource> onlineResourceList= (ArrayList<OnlineResource>) d.getOnLines(); for(OnlineResource or:onlineResourceList){ if(or.getLinkage()!=null) metadata.add("TransferOptionsOnlineLinkage ",or.getLinkage().toString()); if(or.getProtocol()!=null) metadata.add("TransferOptionsOnlineProtocol ",or.getProtocol()); if(or.getApplicationProfile()!=null) metadata.add("TransferOptionsOnlineProfile ",or.getApplicationProfile()); if(or.getName()!=null) metadata.add("TransferOptionsOnlineName ",or.getName()); if(or.getDescription()!=null) metadata.add("TransferOptionsOnlineDescription ",or.getDescription().toString()); if(or.getFunction()!=null) metadata.add("TransferOptionsOnlineFunction ",or.getFunction().name());
/** * Copies properties from the given ISO 19115 metadata. */ private Link(final OnlineResource r, final Locale locale) { uri = r.getLinkage(); text = r.getName(); }
/** * Validates the given online resource. * * @param object the object to validate, or {@code null}. * * @since 3.1 */ public void validate(final OnlineResource object) { if (object == null) { return; } mandatory("OnlineResource: shall have a linkage.", object.getLinkage()); validateOptional(object.getDescription()); } }
/** * 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()); }
/** * 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()); } }
/** * Returns {@code true} if the given URL is null, or if the given resource contains that URL. * * @param resource the value stored in the metadata object. * @param url the value parsed from the netCDF file. */ private static boolean canShare(final OnlineResource resource, final String url) { return (url == null) || (resource != null && canShare(resource.getLinkage().toString(), url)); }
final OnLineFunction f = OnLineFunction.valueOf(CONNECTION); for (final OnlineResource res : ((DefaultCitation) authority).getOnlineResources()) { if (f.equals(res.getFunction())) { final InternationalString i18n = res.getDescription(); if (i18n != null) return i18n.toString(locale);
assertEquals("http://www.epsg.org", resource.getLinkage().toString()); assertEquals(OnLineFunction.INFORMATION, resource.getFunction());
/** * Returns {@code true} if the given URL is null, or if the given resource contains that URL. * * @param resource the value stored in the metadata object. * @param url the value parsed from the netCDF file. */ private static boolean canShare(final OnlineResource resource, final String url) { return (url == null) || (resource != null && canShare(resource.getLinkage().toString(), url)); }
final OnLineFunction f = OnLineFunction.valueOf(CONNECTION); for (final OnlineResource res : ((DefaultCitation) authority).getOnlineResources()) { if (f.equals(res.getFunction())) { final InternationalString i18n = res.getDescription(); if (i18n != null) return i18n.toString(locale);
/** * 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(OnlineResource) */ public DefaultOnlineResource(final OnlineResource object) { super(object); if (object != null) { linkage = object.getLinkage(); protocol = object.getProtocol(); applicationProfile = object.getApplicationProfile(); name = object.getName(); description = object.getDescription(); function = object.getFunction(); if (object instanceof DefaultOnlineResource) { protocolRequest = ((DefaultOnlineResource) object).getProtocolRequest(); } } }
assertNotNull("onlineResource", onlineResource); assertEquals("organisationName", "Apache SIS", contact.getOrganisationName().toString()); assertEquals("linkage", URI.create("http://sis.apache.org"), onlineResource.getLinkage()); assertEquals("function", OnLineFunction.INFORMATION, onlineResource.getFunction()); assertEquals("role", Role.PRINCIPAL_INVESTIGATOR, contact.getRole());
/** * Returns a URI from the given {@code <cit:OnlineResource>} element. */ @Override public URI unmarshal(final CI_OnlineResource value) throws URISyntaxException { if (value != null) { final OnlineResource res = ADAPTER.unmarshal(value); if (res != null) { return res.getLinkage(); } } return 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(OnlineResource) */ public DefaultOnlineResource(final OnlineResource object) { super(object); if (object != null) { linkage = object.getLinkage(); protocol = object.getProtocol(); applicationProfile = object.getApplicationProfile(); name = object.getName(); description = object.getDescription(); function = object.getFunction(); if (object instanceof DefaultOnlineResource) { protocolRequest = ((DefaultOnlineResource) object).getProtocolRequest(); } } }
if (onlineResources != null) { for (final OnlineResource link : onlineResources) { final URI uri = link.getLinkage(); if (uri != null) { if (linkage == null) {
ArrayList<OnlineResource> onlineResourceList= (ArrayList<OnlineResource>) d.getOnLines(); for(OnlineResource or:onlineResourceList){ if(or.getLinkage()!=null) metadata.add("TransferOptionsOnlineLinkage ",or.getLinkage().toString()); if(or.getProtocol()!=null) metadata.add("TransferOptionsOnlineProtocol ",or.getProtocol()); if(or.getApplicationProfile()!=null) metadata.add("TransferOptionsOnlineProfile ",or.getApplicationProfile()); if(or.getName()!=null) metadata.add("TransferOptionsOnlineName ",or.getName()); if(or.getDescription()!=null) metadata.add("TransferOptionsOnlineDescription ",or.getDescription().toString()); if(or.getFunction()!=null) metadata.add("TransferOptionsOnlineFunction ",or.getFunction().name());
if (onlineResources != null) { for (final OnlineResource link : onlineResources) { final URI uri = link.getLinkage(); if (uri != null) { if (linkage == null) {
ArrayList<OnlineResource> onlineResourceList= (ArrayList<OnlineResource>) d.getOnLines(); for(OnlineResource or:onlineResourceList){ if(or.getLinkage()!=null) metadata.add("TransferOptionsOnlineLinkage ",or.getLinkage().toString()); if(or.getProtocol()!=null) metadata.add("TransferOptionsOnlineProtocol ",or.getProtocol()); if(or.getApplicationProfile()!=null) metadata.add("TransferOptionsOnlineProfile ",or.getApplicationProfile()); if(or.getName()!=null) metadata.add("TransferOptionsOnlineName ",or.getName()); if(or.getDescription()!=null) metadata.add("TransferOptionsOnlineDescription ",or.getDescription().toString()); if(or.getFunction()!=null) metadata.add("TransferOptionsOnlineFunction ",or.getFunction().name());
/** * Copies properties from the given ISO 19115 metadata. */ private Copyright(final LegalConstraints c, final Locale locale) { if (!(c instanceof DefaultConstraints)) { return; } resp: for (final DefaultResponsibility r : ((DefaultConstraints) c).getResponsibleParties()) { for (final AbstractParty p : r.getParties()) { author = Types.toString(p.getName(), locale); if (author != null) break resp; } } for (final Citation ci : ((DefaultConstraints) c).getReferences()) { for (final CitationDate d : ci.getDates()) { final Date date = d.getDate(); if (date != null) { year = date.getYear() + 1900; break; } } if (!(ci instanceof DefaultCitation)) continue; for (final OnlineResource r : ((DefaultCitation) ci).getOnlineResources()) { license = r.getLinkage(); if (license != null) break; } } }
for (final OnlineResource resource : contact.getOnlineResources()) { if (resource == null) continue; // Paranoiac safety. final URI uri = resource.getLinkage(); if (uri != null) { linkage = uri.toString();