Difference between revisions of "Legacy ISO Metadata Publishing"

From Gcube Wiki
Jump to: navigation, search
(Filling parameters)
(GcubeISOMetadata class)
Line 191: Line 191:
  
 
meta.addTopicCategory(TopicCategory.BIOTA);
 
meta.addTopicCategory(TopicCategory.BIOTA);
 +
</source>
 +
===Getting the metadata===
 +
Once the metadata information have been set to the GCubeISOMetadata instance, the caller can obtain the metadata to publish just by calling its '''public org.opengis.metadata.Metadata getMetadata()''' method. In case any mandatory value is missing a ''MissingInformationException'' is thrown.
 +
 +
<source lang="java">
 +
ScopeProvider.instance.set("/gcube/devsec");
 +
GcubeISOMetadata meta=new GcubeISOMetadata();
 +
 +
// Set information
 +
....
 +
 +
// Print out the metadata
 +
XML.marshal(meta.getMetadata(),System.out);
 +
 
</source>
 
</source>
  
 
=Extending default behaviour=
 
=Extending default behaviour=

Revision as of 19:42, 16 July 2013

This page aims to explain how to publish ISO metadata using legacy GIS library org.gcube.common.geoserverinterface (referred as GeoServerInterface from now on).

Since various components still rely on GeoServerInterface to publish geo-referenced data, the library has been enhanced to facilitate publication of ISO Metadata correctly filled (see GCube Object Metadata).

This guide require the reader to already know the functionality of GeoServerInterface library.

Maven Dependency

The GeoServerInterface library is released as a maven artifact with the following coordinates

<groupId>org.gcube.common</groupId>
<artifactId>geoserverinterface</artifactId>

Please note that ISO Metadata facilities are released from version 1.10.2.

ISO 19115:2003 metadata compliance

Metadata objects used by the libraries implement GeoAPI interfaces, which are fully compliant to ISO 19115:2003/19139. Current implementation is based on GeoToolkit Metadata module.

Code Adaptation

Introduced enhancements have been designed in order to make code adaptation as easy as possible from developers view. The class org.gcube.common.geoserverinterface.GeoCaller remains the main entry point of GeoServerInterface library for publishing means.

Preexistent publishing methods have been doubled in a way that users just need to change the passed arguments in order to change ISO Metadata publishing behavior.

The following is the list of newly introduced methods

public boolean addGeoLayer(String fileUrl, String layerName, String layerTitle, String workspace, GeonetworkCategory category, Metadata toPublishMeta, String scope, String defaultStyle) throws Exception;
public boolean addFeatureType(FeatureTypeRest featureTypeRest,String defaultStyle, GeonetworkCategory category, Metadata toPublishMeta) throws Exception;
public boolean addGeoTiff(String geoTiffUrl, final String layerName, String layerTitle, final String workspace, GeonetworkCategory category, Metadata toPublishMeta, String scope, String defaultStyle) throws Exception;
public boolean addPreExistentGeoTiff(String fileName, final String layerName, String layerTitle, final String workspace, GeonetworkCategory category, Metadata toPublishMeta,String defaultStyle) throws Exception;

To summerize difference in methods signature :

  • removed argument String description
  • removed argument String abstract
  • added argument org.opengis.metadata.Metadata toPublishMeta : ISO Metadata object representation. It must be already filled with all needed information but layer OGC links, which will be generated at publishing time by the library.
  • added arguemnt String defaultStyle : the defaultStyle to be used when generating OGC links in ISO metadata

Instances of org.opengis.metadata.Metadata interface can be arbitrarily generated by the invoking application. However, the library has been provided with facilities to easily generate Metadata instances for most gCube applications needs.

Metadata generation facilities

Instances of org.opengis.metadata.Metadata interface can be generated in very different ways. However, we identified a common set of information which every application should include in its published metadata. Providing a common way to generate these metadata entry aims to :

GcubeISOMetadata class

The utility class org.gcube.common.geoserverinterface.bean.iso.GcubeISOMetadata lets developers to simply specify the metadata information strictly needed for the generation, relying on internal logic for generic behavior.

Instantiating

A GcubeISOMetadata instance should be generated for each publishing request, but this behavior depends on the caller application logic. At construction time, common information fetched from the gCube IS is loaded. Queries to IS are done via the ic-client, so be sure that a proper scope is setted via org.gcube.common.scope.api.ScopeProvider. Loaded configuration is represented by instances of the class org.gcube.common.geoserverinterface.bean.iso.EnvironmentConfiguration see #EnvironmentConfiguration class.

import org.gcube.common.geoserverinterface.bean.iso.EnvironmentConfiguration;
import org.gcube.common.geoserverinterface.bean.iso.GcubeISOMetadata;
import org.gcube.common.scope.api.ScopeProvider;
....
ScopeProvider.instance.set(...);
GcubeISOMetadata meta=new GcubeISOMetadata();
EnvironmentConfiguration configuration = meta.getConfig();
System.out.println("Current configuration is "+configuration);

Filling parameters

The GcubeISOMetadata class exposes setter/add methods to let users specify metadata information. The following is a list of attributes that can be set along with their cardinality. Attributes which cardinality can be more then 1 are setted via the related addXXX() method, while setXXX() methods are provided for the other ones.

Attribute Name Type Cardinality
User java.lang.String 1


Title java.lang.String 1
Date java.lang.Date 1
Presentation Form org.opengis.metadata.citation.PresentationForm 1
Abstract java.lang.String 1
Purpose java.lang.String 1
Credits java.lang.String 1..N
Descriptive Keyword java.lang.String 1..N
Topic Category org.opengis.metadata.identification.TopicCategory 1..N
Extent org.geotoolkit.metadata.iso.extent.DefaultExtent 1
Geometric Object Type org.opengis.metadata.spatial.GeometricObjectType 1
Geometry Count int 1
Topology Level org.opengis.metadata.spatial.TopologyLevel 1
Resolution double 1
Graphic Overview String 0..N

The following snippets shows how this parameters are set :

import org.gcube.common.geoserverinterface.bean.iso.EnvironmentConfiguration;
import org.gcube.common.geoserverinterface.bean.iso.GcubeISOMetadata;
import org.gcube.common.geoserverinterface.bean.iso.Thesaurus;
import org.geotoolkit.metadata.iso.extent.DefaultExtent;
import org.opengis.metadata.citation.PresentationForm;
import org.opengis.metadata.identification.TopicCategory;
import org.opengis.metadata.spatial.GeometricObjectType;
import org.opengis.metadata.spatial.TopologyLevel;
 
...
 
GcubeISOMetadata meta=new GcubeISOMetadata();
//Setter methods
meta.setAbstractField(...);
meta.setCreationDate(...);
meta.setExtent(DefaultExtent.WORLD);
meta.setGeometricObjectType(GeometricObjectType.SURFACE);
meta.setPresentationForm(PresentationForm.MAP_DIGITAL);
meta.setPurpose(...);
meta.setResolution(...);
meta.setTitle(..);
meta.setTopologyLevel(TopologyLevel.GEOMETRY_ONLY);
meta.setUser(...);						
 
//Add methods
meta.addCredits(..);
meta.addGraphicOverview(...);
 
//Need to get keywords referred Thesaurus
Thesaurus generalThesaurus=meta.getConfig().getThesauri().get(...);		
meta.addKeyword(..., generalThesaurus);
meta.addKeyword(..., generalThesaurus);
 
 
meta.addTopicCategory(TopicCategory.BIOTA);

Getting the metadata

Once the metadata information have been set to the GCubeISOMetadata instance, the caller can obtain the metadata to publish just by calling its public org.opengis.metadata.Metadata getMetadata() method. In case any mandatory value is missing a MissingInformationException is thrown.

ScopeProvider.instance.set("/gcube/devsec");
GcubeISOMetadata meta=new GcubeISOMetadata();
 
// Set information
....
 
// Print out the metadata
XML.marshal(meta.getMetadata(),System.out);

Extending default behaviour