This commit is contained in:
Fabio Sinibaldi 2013-03-20 17:40:47 +00:00
parent cfbce91781
commit 38d188c60b
1 changed files with 98 additions and 0 deletions

View File

@ -0,0 +1,98 @@
package org.gcube.spatial.data.geonetwork.test;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map.Entry;
import org.geotoolkit.metadata.iso.DefaultMetadata;
import org.geotoolkit.metadata.iso.citation.DefaultCitation;
import org.geotoolkit.metadata.iso.citation.DefaultCitationDate;
import org.geotoolkit.metadata.iso.citation.DefaultResponsibleParty;
import org.geotoolkit.metadata.iso.identification.DefaultDataIdentification;
import org.geotoolkit.metadata.iso.identification.DefaultKeywords;
import org.geotoolkit.metadata.iso.maintenance.DefaultMaintenanceInformation;
import org.geotoolkit.metadata.iso.spatial.DefaultGeometricObjects;
import org.geotoolkit.metadata.iso.spatial.DefaultVectorSpatialRepresentation;
import org.geotoolkit.util.DefaultInternationalString;
import org.opengis.metadata.citation.DateType;
import org.opengis.metadata.citation.PresentationForm;
import org.opengis.metadata.identification.KeywordType;
import org.opengis.metadata.maintenance.MaintenanceFrequency;
import org.opengis.metadata.spatial.GeometricObjectType;
import org.opengis.metadata.spatial.TopologyLevel;
public class AMMetaCreation {
/**
* @param args
*/
// ref http://www.fao.org/geonetwork/srv/en/csw?service=CSW&request=GetRecordById&Version=2.0.2&elementSetName=full&outputSchema=http://www.isotc211.org/2005/gmd&id=74f6864c-3e3e-4cd8-a2ea-188337dc6334
public static void main(String[] args) {
String user="test.user";
Integer geometryCount=100;
String title="MyDistributionMap";
Date creationDate=new Date(System.currentTimeMillis());
Date publishDate=new Date(System.currentTimeMillis());
Date revisionDate=new Date(System.currentTimeMillis());
String abstractField="Species Distribution Map, generated by gCube AquaMaps Suite.";
String purpose="To serve and protect";
HashMap<KeywordType,HashSet<String>> descriptiveKeyWords=new HashMap<KeywordType, HashSet<String>>();
//*************** Responsible Party : author
DefaultResponsibleParty party=new DefaultResponsibleParty();
party.setIndividualName(user);
//*************** Identification
DefaultDataIdentification ident=new DefaultDataIdentification();
DefaultCitation citation=new DefaultCitation();
citation.setTitle(new DefaultInternationalString(title));
citation.getDates().add(new DefaultCitationDate(creationDate, DateType.CREATION));
citation.getDates().add(new DefaultCitationDate(publishDate, DateType.PUBLICATION));
citation.getDates().add(new DefaultCitationDate(revisionDate, DateType.REVISION));
citation.getPresentationForms().add(PresentationForm.MAP_DIGITAL);
ident.setCitation(citation);
ident.setAbstract(new DefaultInternationalString(abstractField));
ident.setPurpose(new DefaultInternationalString(purpose));
ident.getResourceMaintenances().add(new DefaultMaintenanceInformation(MaintenanceFrequency.AS_NEEDED));
for(Entry<KeywordType,HashSet<String>> entry:descriptiveKeyWords.entrySet()){
DefaultKeywords keywords=new DefaultKeywords();
for(String key:entry.getValue())keywords.getKeywords().add(new DefaultInternationalString(key));
keywords.setType(entry.getKey());
DefaultCitation thesaurus=new DefaultCitation();
thesaurus.setTitle(new DefaultInternationalString("General"));
keywords.setThesaurusName(thesaurus);
ident.getDescriptiveKeywords().add(keywords);
}
ident.set
//Spatial Rapresentation Info
DefaultGeometricObjects geoObjs=new DefaultGeometricObjects();
geoObjs.setGeometricObjectType(GeometricObjectType.SURFACE);
geoObjs.setGeometricObjectCount(geometryCount);
DefaultVectorSpatialRepresentation spatial=new DefaultVectorSpatialRepresentation();
spatial.setTopologyLevel(TopologyLevel.GEOMETRY_ONLY);
spatial.getGeometricObjects().add(geoObjs);
//*************** The Meta Object
DefaultMetadata meta=new DefaultMetadata(party, new Date(System.currentTimeMillis()), ident);
meta.getSpatialRepresentationInfo().add(spatial);
}
}