final T previous = map.putSpecialized(authority, value); if (previous != null && !previous.equals(value)) { Context.warningOccured(context, IdentifierMap.class, "putSpecialized", Errors.class, Errors.Keys.InconsistentAttribute_2, authority.getName(), value); map.putSpecialized(authority, previous);
final T previous = map.putSpecialized(authority, value); if (previous != null && !previous.equals(value)) { Context.warningOccured(context, IdentifierMap.class, "putSpecialized", Errors.class, Errors.Keys.InconsistentAttribute_2, authority.getName(), value); map.putSpecialized(authority, previous);
/** * Sets the International Standard Serial Number. * In this SIS implementation, invoking this method is equivalent to: * * {@preformat java * getIdentifierMap().putSpecialized(Citations.ISSN, newValue); * } * * @param newValue the new ISSN. * * @see #setIdentifiers(Collection) * @see Citations#ISSN */ public void setISSN(final String newValue) { checkWritePermission(); if (newValue != null || !isNullOrEmpty(identifiers)) { getIdentifierMap().putSpecialized(Citations.ISSN, newValue); } }
/** * Invoked by {@code setID(String)} method implementations for assigning an identifier to an object * at unmarshalling time. * * @param object the object for which to assign an identifier. * @param id the {@code gco:id} or {@code gml:id} value. * * @since 0.7 */ public static void setObjectID(final IdentifiedObject object, String id) { id = CharSequences.trimWhitespaces(id); if (id != null && !id.isEmpty()) { object.getIdentifierMap().putSpecialized(IdentifierSpace.ID, id); final Context context = Context.current(); if (!Context.setObjectForID(context, object, id)) { Context.warningOccured(context, object.getClass(), "setID", Errors.class, Errors.Keys.DuplicatedIdentifier_1, id); } } } }
/** * Sets the International Standard Book Number. * In this SIS implementation, invoking this method is equivalent to: * * {@preformat java * getIdentifierMap().putSpecialized(Citations.ISBN, newValue); * } * * @param newValue the new ISBN, or {@code null} if none. * * @see #setIdentifiers(Collection) * @see Citations#ISBN */ public void setISBN(final String newValue) { checkWritePermission(); if (newValue != null || !isNullOrEmpty(identifiers)) { getIdentifierMap().putSpecialized(Citations.ISBN, newValue); } }
/** * Invoked by {@code setID(String)} method implementations for assigning an identifier to an object * at unmarshalling time. * * @param object the object for which to assign an identifier. * @param id the {@code gco:id} or {@code gml:id} value. * * @since 0.7 */ public static void setObjectID(final IdentifiedObject object, String id) { id = CharSequences.trimWhitespaces(id); if (id != null && !id.isEmpty()) { object.getIdentifierMap().putSpecialized(IdentifierSpace.ID, id); final Context context = Context.current(); if (!Context.setObjectForID(context, object, id)) { Context.warningOccured(context, object.getClass(), "setID", Errors.class, Errors.Keys.DuplicatedIdentifier_1, id); } } } }
/** * Tests with UUIDs. */ @Test public void testUUIDs() { final List<Identifier> identifiers = new ArrayList<>(); final IdentifierMap map = new ModifiableIdentifierMap(identifiers); final java.util.UUID id1 = fromString("434f3107-c6d2-4c8c-bb25-553f68641c5c"); final java.util.UUID id2 = fromString("42924124-032a-4dfe-b06e-113e3cb81cf0"); // Add first UUID. assertNull(map.putSpecialized(UUID, id1)); // Replace UUID by a new one. assertSame(id1, map.putSpecialized(UUID, id2)); } }
/** * Sets the International Standard Serial Number. * In this SIS implementation, invoking this method is equivalent to: * * {@preformat java * getIdentifierMap().putSpecialized(Citations.ISSN, newValue); * } * * @param newValue the new ISSN. * * @see #setIdentifiers(Collection) * @see Citations#ISSN */ public void setISSN(final String newValue) { checkWritePermission(getIdentifier(Citations.ISSN)); if (newValue != null || !isNullOrEmpty(identifiers)) { getIdentifierMap().putSpecialized(Citations.ISSN, newValue); } }
/** * Sets the International Standard Book Number. * In this SIS implementation, invoking this method is equivalent to: * * {@preformat java * getIdentifierMap().putSpecialized(Citations.ISBN, newValue); * } * * @param newValue the new ISBN, or {@code null} if none. * * @see #setIdentifiers(Collection) * @see Citations#ISBN */ public void setISBN(final String newValue) { checkWritePermission(getIdentifier(Citations.ISBN)); if (newValue != null || !isNullOrEmpty(identifiers)) { getIdentifierMap().putSpecialized(Citations.ISBN, newValue); } }
/** * Tests XML marshalling using ISO 19115-3 schema. * This XML fragment contains an identifier. * * @throws JAXBException if an error occurred during marshalling. */ @Test public void testMarshalling() throws JAXBException { final DefaultRepresentativeFraction fraction = new DefaultRepresentativeFraction(8); fraction.getIdentifierMap().putSpecialized(IdentifierSpace.ID, "scale"); roundtrip(fraction, "<mri:MD_RepresentativeFraction xmlns:mri=\"" + Namespaces.MRI + '"' + " xmlns:gco=\"" + Namespaces.GCO + '"' + " id=\"scale\">\n" + " <mri:denominator>\n" + " <gco:Integer>8</gco:Integer>\n" + " </mri:denominator>\n" + "</mri:MD_RepresentativeFraction>"); }
metadata.getIdentifierMap().putSpecialized(IdentifierSpace.UUID, uuid); if (useReferenceResolverMock) { context = ReferenceResolverMock.begin(true);
/** * Tests write operations on an {@link IdentifierMap} using specific API. */ @Test public void testPutSpecialized() { final List<Identifier> identifiers = new ArrayList<>(); final IdentifierMap map = new ModifiableIdentifierMap(identifiers); final String myID = "myID"; final java.util.UUID myUUID = fromString("a1eb6e53-93db-4942-84a6-d9e7fb9db2c7"); final URI myURI = URI.create("http://mylink"); assertNull(map.putSpecialized(ID, myID)); assertNull(map.putSpecialized(UUID, myUUID)); assertNull(map.putSpecialized(HREF, myURI)); assertMapEquals("{gml:id=“myID”," + " gco:uuid=“a1eb6e53-93db-4942-84a6-d9e7fb9db2c7”," + " xlink:href=“http://mylink”}", map); assertSame(myID, map.getSpecialized(ID)); assertSame(myUUID, map.getSpecialized(UUID)); assertSame(myURI, map.getSpecialized(HREF)); assertEquals("myID", map.get(ID)); assertEquals("a1eb6e53-93db-4942-84a6-d9e7fb9db2c7", map.get(UUID)); assertEquals("http://mylink", map.get(HREF)); }
/** * Tests (un)marshalling of an object with a {@code xlink:href} attribute without element definition. * The XML fragment is: * * {@preformat xml * <mdb:MD_Metadata> * <mdb:identificationInfo xlink:href="http://test.net"/> * </mdb:MD_Metadata> * } * * @throws JAXBException if an error occurred during (un)marshalling. * @throws URISyntaxException if the URI used in this test is malformed. */ @Test public void testLinkOnly() throws JAXBException, URISyntaxException { final XLink xlink = new XLink(); xlink.setHRef(new URI("http://test.net")); final DefaultDataIdentification identification = new DefaultDataIdentification(); identification.getIdentifierMap().putSpecialized(IdentifierSpace.XLINK, xlink); final DefaultMetadata metadata = new DefaultMetadata(); metadata.setIdentificationInfo(Collections.singleton(identification)); assertXmlEquals(LINK_ONLY_XML, marshal(metadata), "xmlns:*"); verify(true, unmarshal(DefaultMetadata.class, LINK_ONLY_XML)); }
if (id1 != null || id2 != null) { final IdentifierMap map = super.getIdentifierMap(); if (id1 != null) map.putSpecialized(Citations.ISBN, id1); if (id2 != null) map.putSpecialized(Citations.ISSN, id2);
if (id1 != null || id2 != null) { final IdentifierMap map = super.getIdentifierMap(); if (id1 != null) map.putSpecialized(Citations.ISBN, id1); if (id2 != null) map.putSpecialized(Citations.ISSN, id2);
/** * Tests XML marshalling for the given metadata version. * * @param file file containing the expected metadata. * @param version the metadata version to marshal. */ private void testMarshalling(final String file, final Version version) throws JAXBException { final DefaultOnlineResource rs = new DefaultOnlineResource(URI.create("https://tools.ietf.org/html/rfc1149")); rs.setName("IP over Avian Carriers"); rs.setDescription(new SimpleInternationalString("High delay, low throughput, and low altitude service.")); rs.setFunction(OnLineFunction.OFFLINE_ACCESS); final DefaultContact contact = new DefaultContact(rs); contact.setContactInstructions(new SimpleInternationalString("Send carrier pigeon.")); contact.getIdentifierMap().putSpecialized(IdentifierSpace.ID, "ip-protocol"); final DefaultCitation c = new DefaultCitation("Fight against poverty"); final DefaultResponsibleParty r1 = new DefaultResponsibleParty(Role.ORIGINATOR); final DefaultResponsibleParty r2 = new DefaultResponsibleParty(Role.valueOf("funder")); r1.setParties(Collections.singleton(new DefaultIndividual("Maid Marian", null, contact))); r2.setParties(Collections.singleton(new DefaultIndividual("Robin Hood", null, contact))); c.setCitedResponsibleParties(Arrays.asList(r1, r2)); c.getDates().add(new DefaultCitationDate(TestUtilities.date("2015-10-17 00:00:00"), DateType.valueOf("adopted"))); c.getPresentationForms().add(PresentationForm.valueOf("physicalObject")); /* * Check that XML file built by the marshaller is the same as the example file. */ assertMarshalEqualsFile(file, c, version, "xmlns:*", "xsi:schemaLocation"); }
xlink.setHRef(new URI("http://test.net")); final DefaultDataIdentification identification = new DefaultDataIdentification(); identification.getIdentifierMap().putSpecialized(IdentifierSpace.XLINK, xlink); identification.setAbstract(new SimpleInternationalString("This is a test.")); final DefaultMetadata metadata = new DefaultMetadata();
online.setProtocol("http"); final DefaultContact contact = new DefaultContact(online); contact.getIdentifierMap().putSpecialized(IdentifierSpace.ID, "IFREMER"); contact.setPhones(Arrays.asList( telephone("+33 (0)2 xx.xx.xx.x6", "VOICE"),
link.setActuate(XLink.Actuate.ON_LOAD); link.setTitle(new SimpleInternationalString("myLinkTitle")); metadata.getIdentifierMap().putSpecialized(IdentifierSpace.XLINK, link); if (useReferenceResolverMock) { context = ReferenceResolverMock.begin(true);