Search in sources :

Example 1 with Constraints

use of org.opengis.metadata.constraint.Constraints in project sis by apache.

the class CustomMetadataTest method testSubtypeAttributes.

/**
 * Tests that the attributes defined in subtypes are also marshalled.
 *
 * @throws JAXBException if an error occurred during (un)marshalling.
 *
 * @see <a href="http://jira.geotoolkit.org/browse/GEOTK-108">GEOTK-108</a>
 */
@Test
public void testSubtypeAttributes() throws JAXBException {
    final NameFactory factory = DefaultFactories.forBuildin(NameFactory.class);
    final DataIdentification identification = new DataIdentification() {

        @Override
        public InternationalString getAbstract() {
            Map<Locale, String> names = new HashMap<>();
            names.put(Locale.ENGLISH, "Description");
            return factory.createInternationalString(names);
        }

        @Override
        public InternationalString getEnvironmentDescription() {
            Map<Locale, String> names = new HashMap<>();
            names.put(Locale.ENGLISH, "Environment");
            return factory.createInternationalString(names);
        }

        @Override
        public InternationalString getSupplementalInformation() {
            return null;
        }

        @Override
        public Citation getCitation() {
            return null;
        }

        @Override
        public InternationalString getPurpose() {
            return null;
        }

        @Override
        public Collection<SpatialRepresentationType> getSpatialRepresentationTypes() {
            return null;
        }

        @Override
        public Collection<Resolution> getSpatialResolutions() {
            return null;
        }

        @Override
        public Collection<Locale> getLanguages() {
            return null;
        }

        @Override
        public Collection<CharacterSet> getCharacterSets() {
            return null;
        }

        @Override
        public Collection<TopicCategory> getTopicCategories() {
            return null;
        }

        @Override
        public Collection<Extent> getExtents() {
            return null;
        }

        @Override
        public Collection<String> getCredits() {
            return null;
        }

        @Override
        public Collection<Progress> getStatus() {
            return null;
        }

        @Override
        public Collection<ResponsibleParty> getPointOfContacts() {
            return null;
        }

        @Override
        public Collection<MaintenanceInformation> getResourceMaintenances() {
            return null;
        }

        @Override
        public Collection<BrowseGraphic> getGraphicOverviews() {
            return null;
        }

        @Override
        public Collection<Format> getResourceFormats() {
            return null;
        }

        @Override
        public Collection<Keywords> getDescriptiveKeywords() {
            return null;
        }

        @Override
        public Collection<Usage> getResourceSpecificUsages() {
            return null;
        }

        @Override
        public Collection<Constraints> getResourceConstraints() {
            return null;
        }

        @Deprecated
        @Override
        public Collection<AggregateInformation> getAggregationInfo() {
            return null;
        }
    };
    final DefaultMetadata data = new DefaultMetadata();
    data.setIdentificationInfo(singleton(identification));
    final String xml = XML.marshal(data);
    /*
         * A few simple checks.
         */
    assertTrue("Missing Identification attribute.", xml.contains("Description"));
    assertTrue("Missing DataIdentification attribute.", xml.contains("Environment"));
}
Also used : Locale(java.util.Locale) HashMap(java.util.HashMap) Extent(org.opengis.metadata.extent.Extent) InternationalString(org.opengis.util.InternationalString) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) ResponsibleParty(org.opengis.metadata.citation.ResponsibleParty) Format(org.opengis.metadata.distribution.Format) Constraints(org.opengis.metadata.constraint.Constraints) MaintenanceInformation(org.opengis.metadata.maintenance.MaintenanceInformation) NameFactory(org.opengis.util.NameFactory) SpatialRepresentationType(org.opengis.metadata.spatial.SpatialRepresentationType) Test(org.junit.Test)

Example 2 with Constraints

use of org.opengis.metadata.constraint.Constraints in project sis by apache.

the class FrenchProfileTest method testConstraintsToAFNOR.

/**
 * Tests {@link FrenchProfile#toAFNOR(Object)} with {@link Constraints},
 * {@link LegalConstraints} and  {@link SecurityConstraints} objects.
 */
@Test
public void testConstraintsToAFNOR() {
    Constraints std, fra;
    std = new DefaultConstraints("Some constraints.");
    fra = (Constraints) FrenchProfile.toAFNOR(std);
    assertNotSame("Expected a copy.", std, fra);
    assertSame("Already an AFNOR instance.", fra, FrenchProfile.toAFNOR(fra));
    assertEquals("Some constraints.", getSingleton(fra.getUseLimitations()).toString());
    std = new DefaultLegalConstraints("Some legal constraints.");
    fra = (LegalConstraints) FrenchProfile.toAFNOR(std);
    assertNotSame("Expected a copy.", std, fra);
    assertSame("Already an AFNOR instance.", fra, FrenchProfile.toAFNOR(fra));
    assertEquals("Some legal constraints.", getSingleton(fra.getUseLimitations()).toString());
    std = new DefaultSecurityConstraints("Some security constraints.");
    fra = (SecurityConstraints) FrenchProfile.toAFNOR(std);
    assertNotSame("Expected a copy.", std, fra);
    assertSame("Already an AFNOR instance.", fra, FrenchProfile.toAFNOR(fra));
    assertEquals("Some security constraints.", getSingleton(fra.getUseLimitations()).toString());
}
Also used : DefaultSecurityConstraints(org.apache.sis.metadata.iso.constraint.DefaultSecurityConstraints) DefaultConstraints(org.apache.sis.metadata.iso.constraint.DefaultConstraints) SecurityConstraints(org.opengis.metadata.constraint.SecurityConstraints) DefaultLegalConstraints(org.apache.sis.metadata.iso.constraint.DefaultLegalConstraints) LegalConstraints(org.opengis.metadata.constraint.LegalConstraints) Constraints(org.opengis.metadata.constraint.Constraints) DefaultLegalConstraints(org.apache.sis.metadata.iso.constraint.DefaultLegalConstraints) DefaultSecurityConstraints(org.apache.sis.metadata.iso.constraint.DefaultSecurityConstraints) DefaultConstraints(org.apache.sis.metadata.iso.constraint.DefaultConstraints) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 Constraints (org.opengis.metadata.constraint.Constraints)2 HashMap (java.util.HashMap)1 Locale (java.util.Locale)1 DefaultConstraints (org.apache.sis.metadata.iso.constraint.DefaultConstraints)1 DefaultLegalConstraints (org.apache.sis.metadata.iso.constraint.DefaultLegalConstraints)1 DefaultSecurityConstraints (org.apache.sis.metadata.iso.constraint.DefaultSecurityConstraints)1 SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)1 ResponsibleParty (org.opengis.metadata.citation.ResponsibleParty)1 LegalConstraints (org.opengis.metadata.constraint.LegalConstraints)1 SecurityConstraints (org.opengis.metadata.constraint.SecurityConstraints)1 Format (org.opengis.metadata.distribution.Format)1 Extent (org.opengis.metadata.extent.Extent)1 MaintenanceInformation (org.opengis.metadata.maintenance.MaintenanceInformation)1 SpatialRepresentationType (org.opengis.metadata.spatial.SpatialRepresentationType)1 InternationalString (org.opengis.util.InternationalString)1 NameFactory (org.opengis.util.NameFactory)1