[ckan-changes] commit/ckanext-inspire: 4 new changesets

Bitbucket commits-noreply at bitbucket.org
Wed Nov 9 19:21:06 UTC 2011


4 new commits in ckanext-inspire:


https://bitbucket.org/okfn/ckanext-inspire/changeset/003a52dc04ba/
changeset:   003a52dc04ba
user:        amercader
date:        2011-11-08 13:59:21
summary:     Remove debugger calls
affected #:  1 file

diff -r ad55aadc3ace6af000e264d4b786ed9c15fd373e -r 003a52dc04baa23983de9ddd6f9666aa089fe825 ckanext/inspire/harvesters.py
--- a/ckanext/inspire/harvesters.py
+++ b/ckanext/inspire/harvesters.py
@@ -414,10 +414,8 @@
         try:
             package_dict = action_function(context, package_dict)
         except ValidationError,e:
-            import pdb; pdb.set_trace()
             raise Exception('Validation Error: %s' % str(e.error_summary))
         except Exception, e:
-            import pdb; pdb.set_trace()
             raise e
 
         # Return the actual package object



https://bitbucket.org/okfn/ckanext-inspire/changeset/9f937d7eedd1/
changeset:   9f937d7eedd1
user:        amercader
date:        2011-11-09 13:01:11
summary:     Minor changes in model for new version of the GEMINI scheamtron
affected #:  1 file

diff -r 003a52dc04baa23983de9ddd6f9666aa089fe825 -r 9f937d7eedd1c46c0588b50f5a948439463315da ckanext/inspire/model/__init__.py
--- a/ckanext/inspire/model/__init__.py
+++ b/ckanext/inspire/model/__init__.py
@@ -512,7 +512,7 @@
                 "gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:beginPosition/text()",
                 "gmd:identificationInfo/srv:SV_ServiceIdentification/srv:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:beginPosition/text()",
             ],
-            multiplicity="0..1",
+            multiplicity="*",
         ),
         GeminiElement(
             name="temporal-extent-end",
@@ -520,7 +520,7 @@
                 "gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:endPosition/text()",
                 "gmd:identificationInfo/srv:SV_ServiceIdentification/srv:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:endPosition/text()",
             ],
-            multiplicity="0..1",
+            multiplicity="*",
         ),
         GeminiElement(
             name="vertical-extent",
@@ -528,7 +528,7 @@
                 "gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:verticalElement/gmd:EX_VerticalExtent",
                 "gmd:identificationInfo/srv:SV_ServiceIdentification/srv:extent/gmd:EX_Extent/gmd:verticalElement/gmd:EX_VerticalExtent",
             ],
-            multiplicity="0..1",
+            multiplicity="*",
         ),
         GeminiCoupledResources(
             name="coupled-resource",



https://bitbucket.org/okfn/ckanext-inspire/changeset/3e3ce7886311/
changeset:   3e3ce7886311
user:        amercader
date:        2011-11-09 20:06:24
summary:     [harvester] Handle multiple resource locators

We now create as many package resources as resource locators are present
in the XML document. The following information is extracted (if present):
name
description
url
function
protocol

format is set to 'WMS' if it's a verified WMS, otherwise 'Unverified'.
If WMS are verified, a 'verified' and 'verified_date' are added. Also
a 'ckan_recommended_wms_preview' is added.
affected #:  2 files

diff -r 9f937d7eedd1c46c0588b50f5a948439463315da -r 3e3ce788631167dd73f940ccbd9a3a9e5e3b9799 ckanext/inspire/harvesters.py
--- a/ckanext/inspire/harvesters.py
+++ b/ckanext/inspire/harvesters.py
@@ -220,7 +220,7 @@
 
         extras = {
             'published_by': int(self.obj.source.publisher_id or 0),
-            'INSPIRE': 'True',
+            'INSPIRE': 'True'
         }
 
         # Just add some of the metadata as extras, not the whole lot
@@ -290,6 +290,7 @@
             'title': gemini_values['title'],
             'notes': gemini_values['abstract'],
             'tags': tags,
+            'resources':[]
         }
 
         if package is None or package.title != gemini_values['title']:
@@ -302,22 +303,42 @@
         else:
             package_dict['name'] = package.name
 
-        resource_locator = gemini_values.get('resource-locator', []) and gemini_values['resource-locator'][0].get('url') or ''
+        resource_locators = gemini_values.get('resource-locator', [])
+        
+        if len(resource_locators):
+            for resource_locator in resource_locators:
+                url = resource_locator.get('url','')
+                if url:
+                    resource_format = ''
+                    resource = {}
+                    if extras['resource-type'] == 'service':
+                        # Check if the service is a view service
+                        test_url = url.split('?')[0] if '?' in url else url
+                        if self._is_wms(test_url):
+                            resource['verified'] = True
+                            resource['verified_date'] = datetime.now().isoformat()
+                            resource_format = 'WMS'
+                    resource.update(
+                        {
+                            'url': url,
+                            'name': resource_locator.get('name',''),
+                            'description': resource_locator.get('description') if resource_locator.get('description') else 'Resource locator',
+                            'format': resource_format or 'Unverified',
+                            'resource_locator_protocol': resource_locator.get('protocol',''),
+                            'resource_locator_function':resource_locator.get('function','')
 
-        if resource_locator:
-            if extras['resource-type'] == 'service':
-                _format = 'WMS' if self._is_wms(resource_locator) else 'Unverified'
+                        })
+                    package_dict['resources'].append(resource)
+
+            # Guess the best view service to use in WMS preview
+            verified_view_resources = [r for r in package_dict['resources'] if 'verified' in r and r['format'] == 'WMS']
+            if len(verified_view_resources):
+                verified_view_resources[0]['ckan_recommended_wms_preview'] = True
             else:
-                _format = 'Unverified'
-
-            package_dict['resources'] = [
-                {
-                    'url': resource_locator,
-                    'description': 'Resource locator',
-                    'format': _format,
-                },
-            ]
-
+                view_resources = [r for r in package_dict['resources'] if r['format'] == 'WMS']
+                if len(view_resources):
+                    view_resources[0]['ckan_recommended_wms_preview'] = True
+        
         extras_as_dict = []
         for key,value in extras.iteritems():
             if isinstance(value,(basestring,Number)):


diff -r 9f937d7eedd1c46c0588b50f5a948439463315da -r 3e3ce788631167dd73f940ccbd9a3a9e5e3b9799 ckanext/inspire/model/__init__.py
--- a/ckanext/inspire/model/__init__.py
+++ b/ckanext/inspire/model/__init__.py
@@ -191,7 +191,28 @@
             ],
             multiplicity="0..1",
         ),
-    ]
+        GeminiElement(
+            name="name",
+            search_paths=[
+                "gmd:name/gco:CharacterString/text()",
+            ],
+            multiplicity="0..1",
+        ),
+        GeminiElement(
+            name="description",
+            search_paths=[
+                "gmd:description/gco:CharacterString/text()",
+            ],
+            multiplicity="0..1",
+        ),
+        GeminiElement(
+            name="protocol",
+            search_paths=[
+                "gmd:protocol/gco:CharacterString/text()",
+            ],
+            multiplicity="0..1",
+        ),
+        ]
 
 
 class GeminiDataFormat(GeminiElement):



https://bitbucket.org/okfn/ckanext-inspire/changeset/824544e1d940/
changeset:   824544e1d940
user:        amercader
date:        2011-11-09 20:19:29
summary:     [harvester] Save reference to harvest object id as package extra
affected #:  1 file

diff -r 3e3ce788631167dd73f940ccbd9a3a9e5e3b9799 -r 824544e1d940f4491d9b9d5fe1b1fff11aec89ff ckanext/inspire/harvesters.py
--- a/ckanext/inspire/harvesters.py
+++ b/ckanext/inspire/harvesters.py
@@ -220,7 +220,8 @@
 
         extras = {
             'published_by': int(self.obj.source.publisher_id or 0),
-            'INSPIRE': 'True'
+            'INSPIRE': 'True',
+            'harvest_object_id': self.obj.id
         }
 
         # Just add some of the metadata as extras, not the whole lot

Repository URL: https://bitbucket.org/okfn/ckanext-inspire/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.




More information about the ckan-changes mailing list