From 386ad5dfcfa3dcef7b2a3c0c89e3736bcf20913a Mon Sep 17 00:00:00 2001 From: Gianpaolo Coro Date: Thu, 6 Mar 2014 11:57:09 +0000 Subject: [PATCH] git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-analysis/EcologicalEngineGeoSpatialExtension@92748 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../geo/meta/GenericLayerMetadata.java | 178 ++++++++++++++++++ 1 file changed, 178 insertions(+) diff --git a/src/main/java/org/gcube/dataanalysis/geo/meta/GenericLayerMetadata.java b/src/main/java/org/gcube/dataanalysis/geo/meta/GenericLayerMetadata.java index 069bb72..b23c5d8 100644 --- a/src/main/java/org/gcube/dataanalysis/geo/meta/GenericLayerMetadata.java +++ b/src/main/java/org/gcube/dataanalysis/geo/meta/GenericLayerMetadata.java @@ -648,4 +648,182 @@ public class GenericLayerMetadata { } return categories; } + + + public Metadata createBasicMeta(String[] urls,String[] protocols) throws Exception { + + + // layer uri: wms, wfs wcs + List layerUris = new ArrayList(); + for (int i=0;i> descriptiveKeyWords = new HashMap>(); + HashSet keySet = new HashSet(); + + if (customTopics!=null) + keySet.addAll(customTopics); + + descriptiveKeyWords.put(KeywordType.THEME, keySet); + + if (startDate!=null){ + HashSet temporalkeySet = new HashSet(); + temporalkeySet.add(startDate.toString()); + if (!endDate.equals(startDate)) + temporalkeySet.add(endDate.toString()); + descriptiveKeyWords.put(KeywordType.TEMPORAL, temporalkeySet); + } + + // author: + DefaultResponsibleParty party = new DefaultResponsibleParty(); + party.setIndividualName(author); + DefaultContact contact = new DefaultContact(); + contact.setContactInstructions(new DefaultInternationalString(contactInfo)); + party.setContactInfo(contact); + party.setRole(Role.ORIGINATOR); + + // citation: + DefaultCitation citation = new DefaultCitation(); + citation.setTitle(new DefaultInternationalString(title)); + ArrayList citDates = new ArrayList(); + citDates.add(new DefaultCitationDate(sourceGenerationDate, DateType.CREATION)); + citDates.add(new DefaultCitationDate(sourceGenerationDate, DateType.PUBLICATION)); + citDates.add(new DefaultCitationDate(sourceGenerationDate, DateType.REVISION)); + citation.setDates(citDates); + ArrayList citAltTitle = new ArrayList(); + citAltTitle.add(new DefaultInternationalString(title)); + citation.setAlternateTitles(citAltTitle); + citation.setEditionDate(sourceGenerationDate); + citation.getPresentationForms().add(PresentationForm.MAP_DIGITAL); + ArrayList keywordslist = new ArrayList(); + for (Entry> 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")); + thesaurus.setDates(citDates); + keywords.setThesaurusName(thesaurus); + keywordslist.add(keywords); + } + + // usage: + DefaultUsage usage = new DefaultUsage(); + usage.setSpecificUsage(new DefaultInternationalString(usageField)); + usage.setUsageDate(sourceGenerationDate); + usage.setUserDeterminedLimitations(new DefaultInternationalString(usageLimitations)); + usage.setUserContactInfo(new ArrayList(Arrays.asList(party))); + ArrayList usages = new ArrayList(Arrays.asList(usage)); + //build categories by guessing on the filename + List categories = guessTopicCategory(categoryTypes); + AnalysisLogger.getLogger().debug("Guessed Topics: "+categories); + // Spatial Rapresentation Info + DefaultGeometricObjects geoObjs = new DefaultGeometricObjects(); + geoObjs.setGeometricObjectType(GeometricObjectType.COMPLEX); + DefaultVectorSpatialRepresentation spatial = new DefaultVectorSpatialRepresentation(); + spatial.setTopologyLevel(TopologyLevel.GEOMETRY_ONLY); + spatial.getGeometricObjects().add(geoObjs); + + // Extent: + DefaultExtent extent = new DefaultExtent(); + extent.setGeographicElements(Collections.singleton(new DefaultGeographicBoundingBox(xLL, xRU, yLL, yRU))); + extent.setDescription(new DefaultInternationalString("Bounding box")); + + /*Only with Geotoolkit 4.x + DefaultTemporalExtent stext = new DefaultTemporalExtent(startDate,endDate); + stext.setStartTime(startDate); + stext.setEndTime(endDate); + extent.setTemporalElements(Arrays.asList(stext)); + */ + extent.freeze(); + + //resolution + DefaultNominalResolution resolution = new DefaultNominalResolution(); + resolution.setGroundResolution(res); + resolution.setScanningResolution(res); + DefaultResolution dres = new DefaultResolution(); + dres.setDistance(res); + + // layers access: + DefaultDistribution distribution = new DefaultDistribution(); + DefaultDigitalTransferOptions transferOptions = new DefaultDigitalTransferOptions(); + for (String uri : layerUris) + transferOptions.getOnLines().add(new DefaultOnlineResource(new URI(uri))); + distribution.getTransferOptions().add(transferOptions); + + DefaultFormat [] formats = new DefaultFormat[protocols.length]; + for (int i=0;i(Arrays.asList(formats))); + + // legal constraints + DefaultLegalConstraints constraints = new DefaultLegalConstraints(); + constraints.getUseLimitations().add(new DefaultInternationalString("Licensed")); + constraints.getAccessConstraints().add(Restriction.LICENSE); + constraints.getUseConstraints().add(Restriction.LICENSE); + + // quality declaration: + DefaultDataQuality processQuality = new DefaultDataQuality(); + + //citation + DefaultCitation sourceCitation = new DefaultCitation(); + sourceCitation.setTitle(new DefaultInternationalString(title)); + sourceCitation.getDates().add(new DefaultCitationDate(sourceGenerationDate, DateType.CREATION)); + sourceCitation.getIdentifiers().add(new DefaultIdentifier(categoryTypes)); + + //source + DefaultSource source = new DefaultSource(); + source.setResolution(resolution); + source.setDescription(new DefaultInternationalString(title)); + source.setSourceCitation(sourceCitation); + + // provenance + DefaultProcessStep preprocessStep = new DefaultProcessStep(); + DefaultProcessStep processStep = new DefaultProcessStep(preprocessStep); + DefaultProcessing processing = new DefaultProcessing(); + processing.setSoftwareReferences(new ArrayList(Arrays.asList(sourceCitation))); + processStep.setDescription(new DefaultInternationalString(processdescription)); + DefaultLineage processLineage = new DefaultLineage(); + processLineage.setProcessSteps(new ArrayList(Arrays.asList(processStep))); + processQuality.setLineage(processLineage); + processQuality.setScope(new DefaultScope(ScopeCode.DATASET)); + + // fulfill identification + DefaultDataIdentification ident = new DefaultDataIdentification(); + ident.setCitation(citation); + ident.setAbstract(new DefaultInternationalString(abstractField)); + ident.setPurpose(new DefaultInternationalString(purpose)); + ident.getResourceMaintenances().add(new DefaultMaintenanceInformation(MaintenanceFrequency.AS_NEEDED)); + ident.setDescriptiveKeywords(keywordslist); + ident.setTopicCategories(categories); + ident.setResourceSpecificUsages(usages); + ident.setExtents(new ArrayList(Arrays.asList(extent))); + ident.setSpatialRepresentationTypes(new ArrayList(Arrays.asList(SpatialRepresentationType.GRID))); + ident.setSpatialResolutions(new ArrayList(Arrays.asList(dres))); + ident.setLanguages(new ArrayList(Arrays.asList(Locale.ENGLISH))); + + // Metadata Obj: + DefaultMetadata meta = new DefaultMetadata(party, sourceGenerationDate, ident); + meta.getSpatialRepresentationInfo().add(spatial); + meta.setDistributionInfo(distribution); + meta.getMetadataConstraints().add(constraints); + meta.getDataQualityInfo().add(processQuality); + meta.setLanguage(Locale.ENGLISH); + + return meta; + + } + + + + + }