org.opengis.metadata.citation.Citation Java Examples
The following examples show how to use
org.opengis.metadata.citation.Citation.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IdentifierMapAdapterTest.java From sis with Apache License 2.0 | 6 votes |
/** * Tests serialization. */ @Test public void testSerialization() { assertSame(ID, assertSerializedEquals(ID)); assertSame(UUID, assertSerializedEquals(UUID)); assertSame(HREF, assertSerializedEquals(HREF)); final List<Identifier> identifiers = new ArrayList<>(); final Map<Citation,String> map = new IdentifierMapAdapter(identifiers); assertTrue(identifiers.add(new IdentifierMapEntry(ID, "myID"))); assertTrue(identifiers.add(new IdentifierMapEntry(UUID, "myUUID"))); final Map<Citation,String> copy = assertSerializedEquals(map); assertNotSame(map, copy); assertEquals(2, copy.size()); }
Example #2
Source File: PropertyAccessorTest.java From sis with Apache License 2.0 | 6 votes |
/** * Tests the constructor with the {@link DefaultCitation} implementation. * The order of properties shall be the order declared in the {@code XmlType.propOrder} annotation. * This test may need to be updated if a future GeoAPI release modifies the {@link Citation} interface. * Other tests that depends on {@link Citation} property order are {@link NameMapTest#testEntrySet()}, * {@link TypeMapTest#testEntrySet()} and most tests in {@link ValueMapTest}. * * @see NameMapTest#testEntrySet() * @see TypeMapTest#testEntrySet() * @see ValueMapTest */ @Test public void testConstructor() { assertMappingEquals(createPropertyAccessor(), //……Declaring type………Method………………………………………………………………JavaBeans………………………………………………UML identifier……………………………Sentence………………………………………………………Type……………………………………………………………… Citation.class, "getTitle", "title", "title", "Title", InternationalString.class, Citation.class, "getAlternateTitles", "alternateTitles", "alternateTitle", "Alternate titles", InternationalString[].class, Citation.class, "getDates", "dates", "date", "Dates", CitationDate[].class, Citation.class, "getEdition", "edition", "edition", "Edition", InternationalString.class, Citation.class, "getEditionDate", "editionDate", "editionDate", "Edition date", Date.class, Citation.class, "getIdentifiers", "identifiers", "identifier", "Identifiers", Identifier[].class, Citation.class, "getCitedResponsibleParties", "citedResponsibleParties", "citedResponsibleParty", "Cited responsible parties", ResponsibleParty[].class, Citation.class, "getPresentationForms", "presentationForms", "presentationForm", "Presentation forms", PresentationForm[].class, Citation.class, "getSeries", "series", "series", "Series", Series.class, Citation.class, "getOtherCitationDetails", "otherCitationDetails", "otherCitationDetails", "Other citation details", InternationalString.class, // Citation.class, "getCollectiveTitle", "collectiveTitle", "collectiveTitle", "Collective title", InternationalString.class, -- deprecated as of ISO 19115:2014 Citation.class, "getISBN", "ISBN", "ISBN", "ISBN", String.class, Citation.class, "getISSN", "ISSN", "ISSN", "ISSN", String.class, DefaultCitation.class, "getOnlineResources", "onlineResources", "onlineResource", "Online resources", OnlineResource[].class, DefaultCitation.class, "getGraphics", "graphics", "graphic", "Graphics", BrowseGraphic[].class); }
Example #3
Source File: DefaultProcessStep.java From sis with Apache License 2.0 | 6 votes |
/** * 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(ProcessStep) */ public DefaultProcessStep(final ProcessStep object) { super(object); if (object != null) { description = object.getDescription(); rationale = object.getRationale(); stepDateTime = TemporalUtilities.createInstant(object.getDate()); processors = copyCollection(object.getProcessors(), ResponsibleParty.class); sources = copyCollection(object.getSources(), Source.class); outputs = copyCollection(object.getOutputs(), Source.class); processingInformation = object.getProcessingInformation(); reports = copyCollection(object.getReports(), ProcessStepReport.class); if (object instanceof DefaultProcessStep) { references = copyCollection(((DefaultProcessStep) object).getReferences(), Citation.class); scope = ((DefaultProcessStep) object).getScope(); } } }
Example #4
Source File: ReferencingUtilities.java From sis with Apache License 2.0 | 6 votes |
/** * Returns the mapping between parameter identifiers and parameter names as defined by the given authority. * This method assumes that the identifiers of all parameters defined by that authority are numeric. * Examples of authorities defining numeric parameters are EPSG and GeoTIFF. * * <p>The map returned by this method is modifiable. Callers are free to add or remove entries.</p> * * @param parameters the parameters for which to get a mapping from identifiers to names. * @param authority the authority defining the parameters. * @return mapping from parameter identifiers to parameter names defined by the given authority. * @throws NumberFormatException if a parameter identifier of the given authority is not numeric. * @throws IllegalArgumentException if the same identifier is used for two or more parameters. */ public static Map<Integer,String> identifierToName(final ParameterDescriptorGroup parameters, final Citation authority) { final Map<Integer,String> mapping = new HashMap<>(); for (final GeneralParameterDescriptor descriptor : parameters.descriptors()) { final Identifier id = IdentifiedObjects.getIdentifier(descriptor, authority); if (id != null) { String name = IdentifiedObjects.getName(descriptor, authority); if (name == null) { name = IdentifiedObjects.getName(descriptor, null); } if (mapping.put(Integer.valueOf(id.getCode()), name) != null) { throw new IllegalArgumentException(Errors.format(Errors.Keys.DuplicatedIdentifier_1, id)); } } } return mapping; }
Example #5
Source File: Identifiers.java From sis with Apache License 2.0 | 6 votes |
/** * Determines whether a match or mismatch is found between the two given collections of identifiers. * If any of the given collections is {@code null} or empty, then this method returns {@code null}. * * <p>According ISO 19162 (<cite>Well known text representation of coordinate reference systems</cite>), * {@linkplain org.apache.sis.referencing.AbstractIdentifiedObject#getIdentifiers() identifiers} should have precedence over * {@linkplain org.apache.sis.referencing.AbstractIdentifiedObject#getName() name} for identifying {@code IdentifiedObject}s, * at least in the case of {@linkplain org.apache.sis.referencing.operation.DefaultOperationMethod operation methods} and * {@linkplain org.apache.sis.parameter.AbstractParameterDescriptor parameters}.</p> * * @param id1 the first collection of identifiers, or {@code null}. * @param id2 the second collection of identifiers, or {@code null}. * @return {@code TRUE} or {@code FALSE} on match or mismatch respectively, or {@code null} if this method * can not determine if there is a match or mismatch. */ public static Boolean hasCommonIdentifier(final Iterable<? extends ReferenceIdentifier> id1, final Iterable<? extends ReferenceIdentifier> id2) { if (id1 != null && id2 != null) { boolean hasFound = false; for (final ReferenceIdentifier identifier : id1) { final Citation authority = identifier.getAuthority(); final String codeSpace = identifier.getCodeSpace(); for (final Identifier other : id2) { if (authorityMatches(identifier, authority, codeSpace)) { if (CharSequences.equalsFiltered(identifier.getCode(), other.getCode(), Characters.Filter.UNICODE_IDENTIFIER, true)) { return Boolean.TRUE; } hasFound = true; } } } if (hasFound) { return Boolean.FALSE; } } return null; }
Example #6
Source File: MetadataFallback.java From sis with Apache License 2.0 | 6 votes |
/** * Returns a hard-coded metadata filled with the data referenced by the specified identifier. * Alternatively, this method can also return a {@code CodeList} or {@code Enum} element. * * @param <T> the parameterized type of the {@code type} argument. * @param type the interface to implement, or {@code CodeList} or some {@code Enum} types. * @param identifier the identifier of hard-coded values for the metadata entity to be returned. * @return an implementation of the required interface, or the code list element. */ @Override public <T> T lookup(final Class<T> type, final String identifier) { ArgumentChecks.ensureNonNull("type", type); ArgumentChecks.ensureNonEmpty("identifier", identifier); Object value; if (CodeList.class.isAssignableFrom(type)) { value = getCodeList(type, identifier); } else { value = null; if (type == Citation.class) { value = createCitation(identifier); } if (value == null) { return NilReason.MISSING.createNilObject(type); } } return type.cast(value); }
Example #7
Source File: ModifiableIdentifierMapTest.java From sis with Apache License 2.0 | 6 votes |
/** * Tests the handling of duplicated authorities. */ @Test public void testDuplicatedAuthorities() { final List<Identifier> identifiers = new ArrayList<>(); assertTrue(identifiers.add(new IdentifierMapEntry(ID, "myID1"))); assertTrue(identifiers.add(new IdentifierMapEntry(UUID, "myUUID"))); assertTrue(identifiers.add(new IdentifierMapEntry(ID, "myID2"))); final IdentifierMap map = new ModifiableIdentifierMap(identifiers); assertEquals("Duplicated authorities shall be filtered.", 2, map.size()); assertEquals("Duplicated authorities shall still exist.", 3, identifiers.size()); assertEquals("myID1", map.get(ID)); assertEquals("myUUID", map.get(UUID)); final Iterator<Citation> it = map.keySet().iterator(); assertTrue(it.hasNext()); assertSame(ID, it.next()); it.remove(); assertTrue(it.hasNext()); assertSame(UUID, it.next()); assertFalse("Duplicated authority shall have been removed.", it.hasNext()); assertEquals(1, identifiers.size()); assertEquals(1, map.size()); }
Example #8
Source File: FreeTextMarshallingTest.java From sis with Apache License 2.0 | 6 votes |
/** * Tests parsing of a free text in a non-standard variant. * We continue to support this format for compatibility reason, but * also because it is more compact and closer to what we would expect * inside a {@code <textGroup>} node. * * @throws JAXBException if the XML in this test can not be parsed by JAXB. */ @Test public void testNonStandard() throws JAXBException { final String legacy = "<cit:CI_Citation xmlns:lan=\"" + Namespaces.LAN + '"' + " xmlns:cit=\"" + Namespaces.CIT + '"' + " xmlns:gco=\"" + Namespaces.GCO + '"' + " xmlns:xsi=\"" + Namespaces.XSI + "\">\n" + " <cit:title xsi:type=\"lan:PT_FreeText_PropertyType\">\n" + " <gco:CharacterString>OpenSource Project</gco:CharacterString>\n" + " <lan:PT_FreeText>\n" + " <lan:textGroup>\n" + " <lan:LocalisedCharacterString locale=\"#locale-eng\">OpenSource Project</lan:LocalisedCharacterString>\n" + " <lan:LocalisedCharacterString locale=\"#locale-ita\">Progetto OpenSource</lan:LocalisedCharacterString>\n" + " <lan:LocalisedCharacterString locale=\"#locale-fra\">Projet OpenSource</lan:LocalisedCharacterString>\n" + " </lan:textGroup>\n" + " </lan:PT_FreeText>\n" + " </cit:title>\n" + "</cit:CI_Citation>\n"; final Citation citation = unmarshal(Citation.class, legacy); assertEquals(getExpectedI18N(), citation.getTitle()); }
Example #9
Source File: MetadataBuilder.java From sis with Apache License 2.0 | 6 votes |
/** * Returns the metadata (optionally as an unmodifiable object), or {@code null} if none. * If {@code freeze} is {@code true}, then the returned metadata instance can not be modified. * * @param freeze {@code true} if this method should set the returned metadata to * {@link DefaultMetadata.State#FINAL}, or {@code false} for leaving the metadata editable. * @return the metadata, or {@code null} if none. */ public final DefaultMetadata build(final boolean freeze) { newIdentification(); newGridRepresentation(GridType.UNSPECIFIED); newFeatureTypes(); newCoverage(false); newAcquisition(); newDistribution(); newLineage(); final DefaultMetadata md = metadata; metadata = null; if (md != null) { if (standardISO != 0) { List<Citation> c = Citations.ISO_19115; if (standardISO == 1) { c = Collections.singletonList(c.get(0)); } md.setMetadataStandards(c); } if (freeze) { md.transitionTo(DefaultMetadata.State.FINAL); } } return md; }
Example #10
Source File: DefaultLineage.java From sis with Apache License 2.0 | 5 votes |
/** * 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(Lineage) */ public DefaultLineage(final Lineage object) { super(object); if (object != null) { statement = object.getStatement(); processSteps = copyCollection(object.getProcessSteps(), ProcessStep.class); sources = copyCollection(object.getSources(), Source.class); if (object instanceof DefaultLineage) { scope = ((DefaultLineage) object).getScope(); additionalDocumentation = copyCollection(((DefaultLineage) object).getAdditionalDocumentation(), Citation.class); } } }
Example #11
Source File: PropertyInformation.java From sis with Apache License 2.0 | 5 votes |
/** * Creates a new {@code PropertyInformation} instance from the annotations on the given getter method. * * @param standard the international standard that define the property, or {@code null} if none. * @param property the property name as defined by the international {@code standard}. * @param getter the getter method defined in the interface. * @param elementType the value type, either the method return type if not a collection, * or the type of elements in the collection otherwise. * @param range the range of valid values, or {@code null} if none. This information is associated to the * implementation method rather than the interface one, because it is specific to SIS. */ @SuppressWarnings({"unchecked","rawtypes"}) PropertyInformation(final Citation standard, final String property, final Method getter, final Class<E> elementType, final ValueRange range) { super(standard, property, getter.isAnnotationPresent(Deprecated.class)); parent = getter.getDeclaringClass(); this.elementType = elementType; final UML uml = getter.getAnnotation(UML.class); byte minimumOccurs = 0; byte maximumOccurs = 1; if (uml != null) { switch (uml.obligation()) { case MANDATORY: minimumOccurs = 1; break; case FORBIDDEN: maximumOccurs = 0; break; case CONDITIONAL: minimumOccurs = -1; break; } } if (maximumOccurs != 0) { final Class<?> c = getter.getReturnType(); if (c.isArray() || Collection.class.isAssignableFrom(c)) { maximumOccurs = -1; } } this.minimumOccurs = minimumOccurs; this.maximumOccurs = maximumOccurs; this.domainValue = range; }
Example #12
Source File: NilReasonMarshallingTest.java From sis with Apache License 2.0 | 5 votes |
/** * Tests a simple case for a missing data. * * @throws JAXBException if an error occurred during (un)marshalling. */ @Test public void testMissing() throws JAXBException { final String expected = "<cit:CI_Citation xmlns:cit=\"" + Namespaces.CIT + '"' + " xmlns:gco=\"" + Namespaces.GCO + "\">\n" + " <cit:title>\n" + " <gco:CharacterString>A title</gco:CharacterString>\n" + " </cit:title>\n" + " <cit:series gco:nilReason=\"missing\"/>\n" + "</cit:CI_Citation>"; final Citation citation = unmarshal(Citation.class, expected); assertTitleEquals("citation", "A title", citation); final Series series = citation.getSeries(); assertInstanceOf("Should have instantiated a proxy.", NilObject.class, series); final NilReason reason = ((NilObject) series).getNilReason(); assertSame("nilReason", NilReason.MISSING, reason); assertNull("NilReason.explanation", reason.getOtherExplanation()); assertNull("NilReason.URI", reason.getURI()); assertEquals("Series[missing]", series.toString()); assertNull("All attributes are expected to be null.", series.getName()); final String actual = marshal(citation); assertXmlEquals(expected, actual, "xmlns:*"); assertEquals(citation, unmarshal(Citation.class, actual)); }
Example #13
Source File: NilReasonTest.java From sis with Apache License 2.0 | 5 votes |
/** * Tests the comparison of {@link NilObject} instances. */ @Test public void testNilObjectComparison() { final Citation e1 = NilReason.TEMPLATE.createNilObject(Citation.class); final Citation e2 = NilReason.MISSING .createNilObject(Citation.class); final Citation e3 = NilReason.TEMPLATE.createNilObject(Citation.class); assertEquals("NilObject.hashCode()", e1.hashCode(), e3.hashCode()); assertFalse ("NilObject.hashCode()", e1.hashCode() == e2.hashCode()); assertEquals("NilObject.equals(Object)", e1, e3); assertFalse ("NilObject.equals(Object)", e1.equals(e2)); assertInstanceOf("e1", LenientComparable.class, e1); final LenientComparable c = (LenientComparable) e1; assertTrue (c.equals(e3, ComparisonMode.STRICT)); assertFalse(c.equals(e2, ComparisonMode.STRICT)); assertFalse(c.equals(e2, ComparisonMode.BY_CONTRACT)); assertTrue (c.equals(e2, ComparisonMode.IGNORE_METADATA)); assertTrue (c.equals(e2, ComparisonMode.APPROXIMATE)); assertTrue (c.equals(e2, ComparisonMode.DEBUG)); // Following object should alway be different because it does not implement the same interface. final ResponsibleParty r1 = NilReason.TEMPLATE.createNilObject(ResponsibleParty.class); assertFalse(c.equals(r1, ComparisonMode.STRICT)); assertFalse(c.equals(r1, ComparisonMode.BY_CONTRACT)); assertFalse(c.equals(r1, ComparisonMode.IGNORE_METADATA)); assertFalse(c.equals(r1, ComparisonMode.APPROXIMATE)); assertFalse(c.equals(r1, ComparisonMode.DEBUG)); }
Example #14
Source File: DefaultDataIdentificationTest.java From sis with Apache License 2.0 | 5 votes |
/** * Tests {@link DefaultDataIdentification#asMap()}, in particular on the {@code "language"} property. * This property still use the UML identifier of ISO 19115:2003. */ @Test public void testValueMap() { final DefaultDataIdentification info = create(); final Map<String,Object> map = info.asMap(); assertEquals("abstract", "Global 5.0 x 2.5 degree model data", map.get("abstract").toString()); assertTitleEquals("title", "Sea Surface Temperature Analysis Model", (Citation) map.get("citation")); assertEquals("spatialRepresentationType", singleton(SpatialRepresentationType.GRID), map.get("spatialRepresentationType")); final Locale[] locales = {Locale.US, Locale.FRENCH}; assertArrayEquals("language", locales, ((Collection<?>) map.get("language")).toArray()); assertArrayEquals("languages", locales, ((Collection<?>) map.get("languages")).toArray()); assertArrayEquals("getLanguages", locales, ((Collection<?>) map.get("getLanguages")).toArray()); }
Example #15
Source File: CommonAuthorityFactoryTest.java From sis with Apache License 2.0 | 5 votes |
/** * Checks the value returned by {@link CommonAuthorityFactory#getAuthority()}. */ @Test public void testAuthority() { final Citation authority = factory.getAuthority(); assertTrue (Citations.identifierMatches(authority, "WMS")); assertFalse(Citations.identifierMatches(authority, "OGP")); assertFalse(Citations.identifierMatches(authority, "EPSG")); assertEquals(Constants.OGC, Citations.toCodeSpace(authority)); }
Example #16
Source File: MetadataCopierTest.java From sis with Apache License 2.0 | 5 votes |
/** * Tests {@link MetadataCopier#copy(Class, Object)}. */ @Test public void testCopyWithType() { final MetadataCopier copier = new MetadataCopier(MetadataStandard.ISO_19115); final DefaultCitation original = HardCodedCitations.EPSG; final Citation copy = copier.copy(Citation.class, original); assertNotSame(original, copy); assertNotSame(getSingleton(original.getCitedResponsibleParties()), getSingleton(copy.getCitedResponsibleParties())); assertEquals(original, copy); }
Example #17
Source File: DefaultAssociatedResource.java From sis with Apache License 2.0 | 5 votes |
/** * Returns citation information about the associated resource, or {@code null} if none. * * @return Citation information about the associated resource, or {@code null} if none. */ @XmlElement(name = "name") @XmlJavaTypeAdapter(CI_Citation.Since2014.class) @UML(identifier="name", obligation=CONDITIONAL, specification=ISO_19115) public Citation getName() { return name; }
Example #18
Source File: DefaultCoupledResource.java From sis with Apache License 2.0 | 5 votes |
/** * 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 DefaultCoupledResource(final DefaultCoupledResource object) { super(object); if (object != null) { this.scopedName = object.getScopedName(); this.resourceReferences = copyCollection(object.getResourceReferences(), Citation.class); this.resources = copyCollection(object.getResources(), DataIdentification.class); this.operation = object.getOperation(); } }
Example #19
Source File: DefaultServiceIdentificationTest.java From sis with Apache License 2.0 | 5 votes |
/** * Creates the service identification to use for testing purpose. */ private static DefaultServiceIdentification create() { final NameFactory factory = DefaultFactories.forBuildin(NameFactory.class); final DefaultCoupledResource resource = DefaultCoupledResourceTest.create(factory); resource.setResourceReferences(singleton(new DefaultCitation("WMS specification"))); final DefaultServiceIdentification id = new DefaultServiceIdentification( factory.createGenericName(null, "Web Map Server"), // serviceType NilReason.MISSING.createNilObject(Citation.class), // citation "A dummy service for testing purpose."); // abstract id.setServiceTypeVersions(singleton("1.0")); id.setCoupledResources(singleton(resource)); id.setCouplingType(UnsupportedCodeList.valueOf("LOOSE")); id.setContainsOperations(singleton(resource.getOperation())); return id; }
Example #20
Source File: HashCodeTest.java From sis with Apache License 2.0 | 5 votes |
/** * 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)); }
Example #21
Source File: TypeMapTest.java From sis with Apache License 2.0 | 5 votes |
/** * Tests {@link TypeMap#get(Object)} on a well known metadata type for various {@link TypeValuePolicy}. */ @Test public void testGet() { final MetadataStandard standard = MetadataStandard.ISO_19115; final KeyNamePolicy keyPolicy = KeyNamePolicy.JAVABEANS_PROPERTY; Map<String, Class<?>> types; types = standard.asTypeMap(DefaultCitation.class, keyPolicy, TypeValuePolicy.PROPERTY_TYPE); assertEquals(InternationalString.class, types.get("title")); assertEquals(Collection.class, types.get("alternateTitles")); types = standard.asTypeMap(DefaultCitation.class, keyPolicy, TypeValuePolicy.ELEMENT_TYPE); assertEquals(InternationalString.class, types.get("title")); assertEquals(InternationalString.class, types.get("alternateTitles")); types = standard.asTypeMap(DefaultCitation.class, keyPolicy, TypeValuePolicy.DECLARING_INTERFACE); assertEquals(Citation.class, types.get("title")); assertEquals(Citation.class, types.get("alternateTitles")); types = standard.asTypeMap(DefaultCitation.class, keyPolicy, TypeValuePolicy.DECLARING_CLASS); assertEquals(DefaultCitation.class, types.get("title")); assertEquals(DefaultCitation.class, types.get("alternateTitles")); /* * Tests declaring classes/interfaces again, now with metadata having a class hierarchy. */ types = standard.asTypeMap(DefaultGeographicDescription.class, keyPolicy, TypeValuePolicy.DECLARING_INTERFACE); assertEquals(GeographicDescription.class, types.get("geographicIdentifier")); assertEquals(GeographicExtent.class, types.get("inclusion")); types = standard.asTypeMap(DefaultGeographicDescription.class, keyPolicy, TypeValuePolicy.DECLARING_CLASS); assertEquals(DefaultGeographicDescription.class, types.get("geographicIdentifier")); assertEquals(AbstractGeographicExtent.class, types.get("inclusion")); }
Example #22
Source File: CitationsTest.java From sis with Apache License 2.0 | 5 votes |
/** * Tests {@link Citations#fromName(String)}. * * @throws IllegalAccessException should never happen since we asked only for public fields. */ @Test public void testFromName() throws IllegalAccessException { assertSame(SIS, fromName(Constants.SIS)); assertSame(OGC, fromName(Constants.OGC)); // Success of this test is important for remaining of SIS. assertSame(EPSG, fromName(Constants.EPSG)); // Success of this test is important for remaining of SIS. assertSame(IOGP, fromName(Constants.IOGP)); assertSame(IOGP, fromName("OGP")); assertSame(ESRI, fromName("ESRI")); // Handled in a way very similar to "OGC". assertSame(NETCDF, fromName("NetCDF")); assertSame(GEOTIFF, fromName(Constants.GEOTIFF)); assertSame(PROJ4, fromName("Proj.4")); assertSame(PROJ4, fromName("Proj4")); assertSame(MAP_INFO, fromName("MapInfo")); assertSame(S57, fromName("S-57")); assertSame(S57, fromName("S57")); assertSame(ISBN, fromName("ISBN")); assertSame(ISSN, fromName("ISSN")); assertSame(ISO_19115.get(0), fromName("ISO 19115-1")); assertSame(ISO_19115.get(1), fromName("ISO 19115-2")); assertSame(WMS, fromName("WMS")); assertSame(WMS, fromName(Constants.CRS)); /* * Verify again, but using reflection for making sure that the field names * are consistent and that we did not forgot any citation constant. */ for (final Field field : Citations.class.getFields()) { if (Citation.class.isAssignableFrom(field.getType())) { final String name = field.getName(); assertSame(name, field.get(null), Citations.fromName(name)); } } }
Example #23
Source File: DefaultProcessing.java From sis with Apache License 2.0 | 5 votes |
/** * 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(Processing) */ public DefaultProcessing(final Processing object) { super(object); if (object != null) { identifiers = singleton(object.getIdentifier(), Identifier.class); softwareReferences = copyCollection(object.getSoftwareReferences(), Citation.class); procedureDescription = object.getProcedureDescription(); documentations = copyCollection(object.getDocumentations(), Citation.class); runTimeParameters = object.getRunTimeParameters(); algorithms = copyCollection(object.getAlgorithms(), Algorithm.class); } }
Example #24
Source File: TreeNodeTest.java From sis with Apache License 2.0 | 5 votes |
/** * Tests {@link TreeNode#newChild()}. */ @Test @DependsOnMethod("testGetValue") public void testNewChild() { final DefaultCitation citation = metadataWithHierarchy(); final TreeNode node = create(citation, Citation.class); /* * Ensure that we can not overwrite existing nodes. */ TreeTable.Node child = node.newChild(); child.setValue(TableColumn.IDENTIFIER, "title"); try { child.setValue(TableColumn.VALUE, "A new title"); fail("Attemps to overwrite an existing value shall fail."); } catch (IllegalStateException e) { assertTrue(e.getMessage().contains("title")); } /* * Clear the title and try again. This time, it shall work. */ citation.setTitle(null); child = node.newChild(); child.setValue(TableColumn.IDENTIFIER, "title"); child.setValue(TableColumn.VALUE, "A new title"); assertTitleEquals("citation", "A new title", citation); assertSame(citation.getTitle(), child.getValue(TableColumn.VALUE)); /* * Try adding a new element in a collection. * Note that the code below imply a conversion from String to InternationalString. */ child = node.newChild(); child.setValue(TableColumn.IDENTIFIER, "alternateTitle"); child.setValue(TableColumn.VALUE, "Third alternate title"); assertEquals(3, citation.getAlternateTitles().size()); assertEquals("Third alternate title", child.getValue(TableColumn.VALUE).toString()); }
Example #25
Source File: Formatter.java From sis with Apache License 2.0 | 5 votes |
/** * Sets the convention, authority, colors and indentation to use for formatting WKT elements. * This method does not validate the argument — validation must be done by the caller. * * @param convention the convention, or {@code null} for the default value. * @param authority the authority, or {@code null} for inferring it from the convention. * @param colors the syntax coloring, or {@code null} if none. * @param toUpperCase whether keywords shall be converted to upper cases. * @param longKeywords {@code -1} for short keywords, {@code +1} for long keywords or 0 for the default. * @param indentation the amount of spaces to use in indentation for WKT formatting, or {@link WKTFormat#SINGLE_LINE}. * @param listSizeLimit maximum number of elements to show in lists, or {@link Integer#MAX_VALUE} if unlimited. */ final void configure(Convention convention, final Citation authority, final Colors colors, final byte toUpperCase, final byte longKeywords, final byte indentation, final int listSizeLimit) { this.convention = convention; this.authority = (authority != null) ? authority : convention.getNameAuthority(); this.colors = colors; this.toUpperCase = toUpperCase; this.longKeywords = longKeywords; this.indentation = indentation; this.listSizeLimit = listSizeLimit; this.transliterator = (convention == Convention.INTERNAL) ? Transliterator.IDENTITY : Transliterator.DEFAULT; unitFormat.setLocale(convention.usesCommonUnits ? Locale.US : Locale.ROOT); }
Example #26
Source File: DefaultConstraints.java From sis with Apache License 2.0 | 5 votes |
/** * 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(Constraints) */ public DefaultConstraints(final Constraints object) { super(object); if (object != null) { useLimitations = copyCollection(object.getUseLimitations(), InternationalString.class); if (object instanceof DefaultConstraints) { final DefaultConstraints c = (DefaultConstraints) object; constraintApplicationScope = c.getConstraintApplicationScope(); graphics = copyCollection(c.getGraphics(), BrowseGraphic.class); references = copyCollection(c.getReferences(), Citation.class); releasability = c.getReleasability(); responsibleParties = copyCollection(c.getResponsibleParties(), DefaultResponsibility.class); } } }
Example #27
Source File: InformationMapTest.java From sis with Apache License 2.0 | 5 votes |
/** * Tests {@link InformationMap#get(Object)} on a few specific properties of the {@link Citation} type. * This test duplicates {@link PropertyInformationTest}, but is done here again as an integration test. */ @Test public void testGet() { final Map<String,ExtendedElementInformation> map = MetadataStandard.ISO_19115.asInformationMap( Citation.class, KeyNamePolicy.JAVABEANS_PROPERTY); PropertyInformationTest.validateTitle(map.get("title")); PropertyInformationTest.validatePresentationForm(map.get("presentationForms")); assertNull("Shall not exists.", map.get("dummy")); }
Example #28
Source File: DefaultFormat.java From sis with Apache License 2.0 | 5 votes |
/** * Returns the name of the data transfer format(s). * * @return name of the data transfer format(s), or {@code null}. * * @deprecated As of ISO 19115:2014, replaced by * <code>{@linkplain #getFormatSpecificationCitation()}.{@linkplain DefaultCitation#getAlternateTitles() * getAlternateTitles()}</code>. Note that citation alternate titles are often used for abbreviations. */ @Override @Deprecated @Dependencies("getFormatSpecificationCitation") @XmlElement(name = "name", namespace = LegacyNamespaces.GMD) public InternationalString getName() { if (FilterByVersion.LEGACY_METADATA.accept()) { final Citation citation = getFormatSpecificationCitation(); if (citation != null) { return LegacyPropertyAdapter.getSingleton(citation.getAlternateTitles(), InternationalString.class, null, DefaultFormat.class, "getName"); } } return null; }
Example #29
Source File: DefaultFormat.java From sis with Apache License 2.0 | 5 votes |
/** * Returns the name of a subset, profile, or product specification of the format. * * @return name of a subset, profile, or product specification of the format, or {@code null}. * * @deprecated As of ISO 19115:2014, replaced by * <code>{@linkplain #getFormatSpecificationCitation()}.{@linkplain DefaultCitation#getTitle() getTitle()}</code>. */ @Override @Deprecated @Dependencies("getFormatSpecificationCitation") @XmlElement(name = "specification", namespace = LegacyNamespaces.GMD) public InternationalString getSpecification() { if (FilterByVersion.LEGACY_METADATA.accept()) { final Citation citation = getFormatSpecificationCitation(); if (citation != null) { return citation.getTitle(); } } return null; }
Example #30
Source File: SpecializedIdentifier.java From sis with Apache License 2.0 | 5 votes |
/** * Formats the given (authority, code) par value in the given buffer. */ static void format(final StringBuilder buffer, final Citation authority, final String code) { buffer.append(Citations.toCodeSpace(authority)).append('='); final boolean quote = (code != null) && (code.indexOf('[') < 0); if (quote) buffer.append('“'); buffer.append(code); if (quote) buffer.append('”'); }