source: TI01-discovery/trunk/OAIInfoEditor/oai_info_editor/controllers/harvest.py @ 5239

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI01-discovery/trunk/OAIInfoEditor/oai_info_editor/controllers/harvest.py@5239
Revision 5239, 1.7 KB checked in by cbyrom, 11 years ago (diff)

Add Harvester class to run the jOAI Harvester API and run repository
harvests. Add code throughout the app to allow harvests to be
ran from the UI. Add new test data and tests to exercise the new
functionality and adjust the config file to allow input of required
harvest data. Add confirmation pop up when running deletes.

  • Property svn:executable set to *
Line 
1'''
2 Class representing pylons controller for the harvesting of provider info
3 
4 @author: C Byrom, Tessella Apr 2009
5'''
6import logging, urllib
7from oai_info_editor.lib.base import *
8from oai_info_editor.controllers.master import MasterController
9import oai_info_editor.lib.constants as const
10
11class HarvestController(MasterController):
12
13    def harvestProviderInfo(self, providerName, repositoryName):
14        '''
15        Harvest the repository info associated with the input name and provider
16        @param providerName: name of provider whose info should be displayed
17        @param repositoryName: name of repository whose info should be displayed
18        '''
19        providerName = urllib.unquote(providerName)
20        repositoryName = urllib.unquote(repositoryName)
21        self._setUpController(providerName = providerName)
22        logging.info("Setting up page to display info for provider, '%s'" %providerName)
23
24        ri = g.dao.getRepositoryInfo(providerName, repositoryName)
25        if not ri:
26            raise ValueError("Could not find repository, '%s' for provider, '%s'" \
27                             %(repositoryName, providerName))
28
29        outMessage = "Repository data, %s, for provider with name, %s, successfully harvested" \
30            %(repositoryName, providerName)
31        status, result = g.harvester.harvestRepository(ri)
32        if not status:
33            outMessage = "A problem (%s) occurred whilst harvesting the data - please retry later" \
34                %result
35           
36        # now return to the home page - and display pop up
37        session[const.POP_UP_MESSAGE_SESSION_KEY] = outMessage
38        session.save()
39
40        # now, return to the view page
41        h.redirect_to('home')
Note: See TracBrowser for help on using the repository browser.