[5321] | 1 | ## |
---|
| 2 | ## batching.py |
---|
| 3 | ## Login : <uli@pu.smp.net> |
---|
| 4 | ## Started on Fri Jul 23 15:42:46 2010 Uli Fouquet |
---|
| 5 | ## $Id$ |
---|
| 6 | ## |
---|
| 7 | ## Copyright (C) 2010 Uli Fouquet |
---|
| 8 | ## This program is free software; you can redistribute it and/or modify |
---|
| 9 | ## it under the terms of the GNU General Public License as published by |
---|
| 10 | ## the Free Software Foundation; either version 2 of the License, or |
---|
| 11 | ## (at your option) any later version. |
---|
| 12 | ## |
---|
| 13 | ## This program is distributed in the hope that it will be useful, |
---|
| 14 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | ## GNU General Public License for more details. |
---|
| 17 | ## |
---|
| 18 | ## You should have received a copy of the GNU General Public License |
---|
| 19 | ## along with this program; if not, write to the Free Software |
---|
| 20 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
| 21 | ## |
---|
| 22 | """Batch processing for applicants. |
---|
| 23 | """ |
---|
| 24 | import grok |
---|
| 25 | from zope.interface import Interface |
---|
| 26 | from waeup.sirp.interfaces import IBatchProcessor |
---|
| 27 | from waeup.sirp.utils.batching import BatchProcessor |
---|
[5689] | 28 | from waeup.sirp.applicants.jambtables.interfaces import IApplicantPDEImportData |
---|
[5321] | 29 | |
---|
[5728] | 30 | class JAMBDataImporter(BatchProcessor): |
---|
[5321] | 31 | """An importer for applicants. |
---|
| 32 | """ |
---|
[5474] | 33 | grok.implements(IBatchProcessor) |
---|
[5321] | 34 | grok.provides(IBatchProcessor) |
---|
| 35 | grok.context(Interface) |
---|
[5728] | 36 | util_name = 'application importer' |
---|
[5321] | 37 | grok.name(util_name) |
---|
| 38 | |
---|
[5728] | 39 | name = u'JAMB Data Importer' |
---|
[5475] | 40 | mode = u'create' |
---|
[5321] | 41 | iface = IApplicantPDEImportData |
---|
| 42 | |
---|
| 43 | location_fields = ['reg_no',] |
---|
| 44 | factory_name = 'waeup.Applicant' |
---|
| 45 | |
---|
| 46 | def parentsExist(self, row, site): |
---|
[5728] | 47 | return 'jambdata' in site.keys() |
---|
[5321] | 48 | |
---|
| 49 | def entryExists(self, row, site): |
---|
[5728] | 50 | return row['reg_no'] in site['jambdata'].keys() |
---|
[5321] | 51 | |
---|
| 52 | def getParent(self, row, site): |
---|
[5728] | 53 | return site['jambdata'] |
---|
[5321] | 54 | |
---|
| 55 | def getEntry(self, row, site): |
---|
| 56 | if not self.entryExists(row, site): |
---|
| 57 | return None |
---|
| 58 | parent = self.getParent(row, site) |
---|
| 59 | return parent.get(row['reg_no']) |
---|
| 60 | |
---|
| 61 | def addEntry(self, obj, row, site): |
---|
| 62 | parent = self.getParent(row, site) |
---|
| 63 | reg_no = row['reg_no'] |
---|
| 64 | parent[reg_no] = obj |
---|
| 65 | return |
---|
| 66 | |
---|
| 67 | def delEntry(self, row, site): |
---|
| 68 | parent = self.getParent(row, site) |
---|
| 69 | del parent[row['reg_no']] |
---|
| 70 | return |
---|