2011-04-06 13:45:00 +02:00
|
|
|
from ckan.plugins.interfaces import Interface
|
|
|
|
|
|
|
|
class IHarvester(Interface):
|
|
|
|
'''
|
|
|
|
Common harvesting interface
|
|
|
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
def get_type(self):
|
|
|
|
'''
|
|
|
|
Plugins must provide this method, which will return a string with the
|
|
|
|
Harvester type implemented by the plugin (e.g ``CSW``,``INSPIRE``, etc).
|
|
|
|
This will ensure that they only receive Harvest Jobs and Objects
|
|
|
|
relevant to them.
|
|
|
|
|
|
|
|
returns: A string with the harvester type
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
def gather_stage(self, harvest_job):
|
|
|
|
'''
|
|
|
|
The gather stage will recieve a HarvestJob object and will be
|
|
|
|
responsible for:
|
|
|
|
- gathering all the necessary objects to fetch on a later.
|
|
|
|
stage (e.g. for a CSW server, perform a GetRecords request)
|
2011-04-07 17:59:11 +02:00
|
|
|
- creating the necessary HarvestObjects in the database, specifying
|
2011-05-10 12:05:44 +02:00
|
|
|
the guid and a reference to its job. The HarvestObjects need a
|
|
|
|
reference date with the last modified date for the resource, this
|
|
|
|
may need to be set in a different stage depending on the type of
|
|
|
|
source.
|
2011-04-06 13:45:00 +02:00
|
|
|
- creating and storing any suitable HarvestGatherErrors that may
|
|
|
|
occur.
|
|
|
|
- returning a list with all the ids of the created HarvestObjects.
|
|
|
|
|
|
|
|
:param harvest_job: HarvestJob object
|
|
|
|
:returns: A list of HarvestObject ids
|
|
|
|
'''
|
|
|
|
|
|
|
|
def fetch_stage(self, harvest_object):
|
|
|
|
'''
|
|
|
|
The fetch stage will receive a HarvestObject object and will be
|
|
|
|
responsible for:
|
|
|
|
- getting the contents of the remote object (e.g. for a CSW server,
|
|
|
|
perform a GetRecordById request).
|
|
|
|
- saving the content in the provided HarvestObject.
|
|
|
|
- creating and storing any suitable HarvestObjectErrors that may
|
|
|
|
occur.
|
|
|
|
- returning True if everything went as expected, False otherwise.
|
|
|
|
|
|
|
|
:param harvest_object: HarvestObject object
|
|
|
|
:returns: True if everything went right, False if errors were found
|
|
|
|
'''
|
|
|
|
|
|
|
|
def import_stage(self, harvest_object):
|
|
|
|
'''
|
|
|
|
The import stage will receive a HarvestObject object and will be
|
|
|
|
responsible for:
|
|
|
|
- performing any necessary action with the fetched object (e.g
|
|
|
|
create a CKAN package).
|
2011-04-11 17:30:56 +02:00
|
|
|
Note: if this stage creates or updates a package, a reference
|
|
|
|
to the package should be added to the HarvestObject.
|
2011-04-07 17:59:11 +02:00
|
|
|
- creating the HarvestObject - Package relation (if necessary)
|
2011-04-06 13:45:00 +02:00
|
|
|
- creating and storing any suitable HarvestObjectErrors that may
|
|
|
|
occur.
|
2011-04-07 17:59:11 +02:00
|
|
|
- returning True if everything went as expected, False otherwise.
|
2011-04-06 13:45:00 +02:00
|
|
|
|
|
|
|
:param harvest_object: HarvestObject object
|
|
|
|
:returns: True if everything went right, False if errors were found
|
|
|
|
'''
|
|
|
|
|