diff --git a/ckanext/spatial/harvesters/csw.py b/ckanext/spatial/harvesters/csw.py index 2853a10c..9875c572 100644 --- a/ckanext/spatial/harvesters/csw.py +++ b/ckanext/spatial/harvesters/csw.py @@ -62,6 +62,12 @@ def get_original_url(self, harvest_object_id): def output_schema(self): return 'gmd' + def get_constraints(self, harvest_job): + '''Returns the CSW constraints that should be used during gather stage. + Should be overwritten by sub-classes. + ''' + return [] + def gather_stage(self, harvest_job): log = logging.getLogger(__name__ + '.CSW.gather') log.debug('CswHarvester gather_stage for job: %r', harvest_job) @@ -92,7 +98,7 @@ def gather_stage(self, harvest_job): log.debug('Starting gathering for %s' % url) guids_in_harvest = set() try: - for identifier in self.csw.getidentifiers(page=10, outputschema=self.output_schema(), cql=cql): + for identifier in self.csw.getidentifiers(page=10, outputschema=self.output_schema(), cql=cql, constraints=self.get_constraints(harvest_job)): try: log.info('Got identifier %s from the CSW', identifier) if identifier is None: diff --git a/ckanext/spatial/lib/csw_client.py b/ckanext/spatial/lib/csw_client.py index 207a0d40..7366a592 100644 --- a/ckanext/spatial/lib/csw_client.py +++ b/ckanext/spatial/lib/csw_client.py @@ -101,9 +101,8 @@ def getrecords(self, qtype=None, keywords=[], def getidentifiers(self, qtype=None, typenames="csw:Record", esn="brief", keywords=[], limit=None, page=10, outputschema="gmd", - startposition=0, cql=None, **kw): + startposition=0, cql=None, constraints=[], **kw): from owslib.csw import namespaces - constraints = [] csw = self._ows(**kw) if qtype is not None: