Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/allow csw constraints #192

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion ckanext/spatial/harvesters/csw.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions ckanext/spatial/lib/csw_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down