From dc37867d7a8d29ab641b382dcf0549ceeda6dd44 Mon Sep 17 00:00:00 2001 From: amercader Date: Tue, 11 Mar 2014 17:05:08 +0000 Subject: [PATCH] [#62] Add new fields to the ISO parser * Metadata standard name / version * Unique resource identifier (reenabled and fixed) * Presentation form * Purpose * Maintenance note * Access constraints * Distributor * Usage * Aggregation info --- ckanext/spatial/model/harvested_metadata.py | 148 ++++++++++++++++++-- 1 file changed, 137 insertions(+), 11 deletions(-) diff --git a/ckanext/spatial/model/harvested_metadata.py b/ckanext/spatial/model/harvested_metadata.py index a84cc97..d0ecfcd 100644 --- a/ckanext/spatial/model/harvested_metadata.py +++ b/ckanext/spatial/model/harvested_metadata.py @@ -402,6 +402,63 @@ class ISOKeyword(ISOElement): ] +class ISOUsage(ISOElement): + + elements = [ + ISOElement( + name="usage", + search_paths=[ + "gmd:specificUsage/gco:CharacterString/text()", + ], + multiplicity="1", + ), + ISOResponsibleParty( + name="contact-info", + search_paths=[ + "gmd:userContactInfo/gmd:CI_ResponsibleParty", + ], + multiplicity="1", + ), + + ] + + +class ISOAggregationInfo(ISOElement): + + elements = [ + ISOElement( + name="aggregate-dataset-name", + search_paths=[ + "gmd:aggregateDatasetName/gmd:CI_Citation/gmd:title/gco:CharacterString/text()", + ], + multiplicity="0..1", + ), + ISOElement( + name="aggregate-dataset-identifier", + search_paths=[ + "gmd:aggregateDatasetIdentifier/gmd:MD_Identifier/gmd:code/gco:CharacterString/text()", + ], + multiplicity="0..1", + ), + ISOElement( + name="association-type", + search_paths=[ + "gmd:associationType/gmd:DS_AssociationTypeCode/@codeListValue", + "gmd:associationType/gmd:DS_AssociationTypeCode/text()", + ], + multiplicity="0..1", + ), + ISOElement( + name="initiative-type", + search_paths=[ + "gmd:initiativeType/gmd:DS_InitiativeTypeCode/@codeListValue", + "gmd:initiativeType/gmd:DS_InitiativeTypeCode/text()", + ], + multiplicity="0..1", + ), + ] + + class ISODocument(MappedXmlDocument): # Attribute specifications from "XPaths for GEMINI" by Peter Parslow. @@ -420,6 +477,16 @@ class ISODocument(MappedXmlDocument): ], multiplicity="0..1", ), + ISOElement( + name="metadata-standard-name", + search_paths="gmd:metadataStandardName/gco:CharacterString/text()", + multiplicity="0..1", + ), + ISOElement( + name="metadata-standard-version", + search_paths="gmd:metadataStandardVersion/gco:CharacterString/text()", + multiplicity="0..1", + ), ISOElement( name="resource-type", search_paths=[ @@ -475,15 +542,25 @@ class ISODocument(MappedXmlDocument): ], multiplicity="1..*", ), - ## Todo: Suggestion from PP not to bother pulling this into the package. - #ISOElement( - # name="unique-resource-identifier", - # search_paths=[ - # "gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:identifier/gmd:RS_Identifier", - # "gmd:identificationInfo/srv:SV_ServiceIdentification/gmd:citation/gmd:CI_Citation/gmd:identifier/gmd:RS_Identifier", - # ], - # multiplicity="1", - #), + ISOElement( + name="unique-resource-identifier", + search_paths=[ + "gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:identifier/gmd:MD_Identifier/gmd:code/gco:CharacterString/text()", + "gmd:identificationInfo/gmd:SV_ServiceIdentification/gmd:citation/gmd:CI_Citation/gmd:identifier/gmd:MD_Identifier/gmd:code/gco:CharacterString/text()", + ], + multiplicity="0..1", + ), + ISOElement( + name="presentation-form", + search_paths=[ + "gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:presentationForm/gmd:CI_PresentationFormCode/text()", + "gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:presentationForm/gmd:CI_PresentationFormCode/@codeListValue", + "gmd:identificationInfo/srv:SV_ServiceIdentification/gmd:citation/gmd:CI_Citation/gmd:presentationForm/gmd:CI_PresentationFormCode/text()", + "gmd:identificationInfo/srv:SV_ServiceIdentification/gmd:citation/gmd:CI_Citation/gmd:presentationForm/gmd:CI_PresentationFormCode/@codeListValue", + + ], + multiplicity="*", + ), ISOElement( name="abstract", search_paths=[ @@ -492,6 +569,14 @@ class ISODocument(MappedXmlDocument): ], multiplicity="1", ), + ISOElement( + name="purpose", + search_paths=[ + "gmd:identificationInfo/gmd:MD_DataIdentification/gmd:purpose/gco:CharacterString/text()", + "gmd:identificationInfo/srv:SV_ServiceIdentification/gmd:purpose/gco:CharacterString/text()", + ], + multiplicity="1", + ), ISOResponsibleParty( name="responsible-organisation", search_paths=[ @@ -506,12 +591,19 @@ class ISODocument(MappedXmlDocument): search_paths=[ "gmd:identificationInfo/gmd:MD_DataIdentification/gmd:resourceMaintenance/gmd:MD_MaintenanceInformation/gmd:maintenanceAndUpdateFrequency/gmd:MD_MaintenanceFrequencyCode/@codeListValue", "gmd:identificationInfo/srv:SV_ServiceIdentification/gmd:resourceMaintenance/gmd:MD_MaintenanceInformation/gmd:maintenanceAndUpdateFrequency/gmd:MD_MaintenanceFrequencyCode/@codeListValue", - "gmd:identificationInfo/gmd:MD_DataIdentification/gmd:resourceMaintenance/gmd:MD_MaintenanceInformation/gmd:maintenanceAndUpdateFrequency/gmd:MD_MaintenanceFrequencyCode/text()", "gmd:identificationInfo/srv:SV_ServiceIdentification/gmd:resourceMaintenance/gmd:MD_MaintenanceInformation/gmd:maintenanceAndUpdateFrequency/gmd:MD_MaintenanceFrequencyCode/text()", ], multiplicity="0..1", ), + ISOElement( + name="maintenance-note", + search_paths=[ + "gmd:identificationInfo/gmd:MD_DataIdentification/gmd:resourceMaintenance/gmd:MD_MaintenanceInformation/gmd:maintenanceNote/gco:CharacterString/text()", + "gmd:identificationInfo/gmd:SV_ServiceIdentification/gmd:resourceMaintenance/gmd:MD_MaintenanceInformation/gmd:maintenanceNote/gco:CharacterString/text()", + ], + multiplicity="0..1", + ), ISOElement( name="progress", search_paths=[ @@ -546,14 +638,33 @@ class ISODocument(MappedXmlDocument): ], multiplicity="*", ), + ISOUsage( + name="usage", + search_paths=[ + "gmd:identificationInfo/gmd:MD_DataIdentification/gmd:resourceSpecificUsage/gmd:MD_Usage", + "gmd:identificationInfo/srv:SV_ServiceIdentification/gmd:resourceSpecificUsage/gmd:MD_Usage", + ], + multiplicity="*" + ), ISOElement( name="limitations-on-public-access", search_paths=[ "gmd:identificationInfo/gmd:MD_DataIdentification/gmd:resourceConstraints/gmd:MD_LegalConstraints/gmd:otherConstraints/gco:CharacterString/text()", "gmd:identificationInfo/srv:SV_ServiceIdentification/gmd:resourceConstraints/gmd:MD_LegalConstraints/gmd:otherConstraints/gco:CharacterString/text()", ], - multiplicity="1..*", + multiplicity="*", ), + ISOElement( + name="access-constraints", + search_paths=[ + "gmd:identificationInfo/gmd:MD_DataIdentification/gmd:resourceConstraints/gmd:MD_LegalConstraints/gmd:accessConstraints/gmd:MD_RestrictionCode/@codeListValue", + "gmd:identificationInfo/srv:SV_ServiceIdentification/gmd:resourceConstraints/gmd:MD_LegalConstraints/gmd:accessConstraints/gmd:MD_RestrictionCode/@codeListValue", + "gmd:identificationInfo/gmd:MD_DataIdentification/gmd:resourceConstraints/gmd:MD_LegalConstraints/gmd:accessConstraints/gmd:MD_RestrictionCode/text()", + "gmd:identificationInfo/srv:SV_ServiceIdentification/gmd:resourceConstraints/gmd:MD_LegalConstraints/gmd:accessConstraints/gmd:MD_RestrictionCode/text()", + ], + multiplicity="*", + ), + ISOElement( name="use-constraints", search_paths=[ @@ -562,6 +673,14 @@ class ISODocument(MappedXmlDocument): ], multiplicity="*", ), + ISOAggregationInfo( + name="aggregation-info", + search_paths=[ + "gmd:identificationInfo/gmd:MD_DataIdentification/gmd:aggregationInfo/gmd:MD_AggregateInformation", + "gmd:identificationInfo/gmd:SV_ServiceIdentification/gmd:aggregationInfo/gmd:MD_AggregateInformation", + ], + multiplicity="*" + ), ISOElement( name="spatial-data-service-type", search_paths=[ @@ -678,6 +797,13 @@ class ISODocument(MappedXmlDocument): ], multiplicity="*", ), + ISOResponsibleParty( + name="distributor", + search_paths=[ + "gmd:distributionInfo/gmd:MD_Distribution/gmd:distributor/gmd:MD_Distributor/gmd:distributorContact/gmd:CI_ResponsibleParty", + ], + multiplicity="*", + ), ISOResourceLocator( name="resource-locator", search_paths=[