Mercurial > hg > MetaDataProvider
comparison MetaData.py @ 11:a29665fa9c62
more work for non-bib metadata
author | casties |
---|---|
date | Fri, 29 Jul 2011 14:45:13 +0200 |
parents | eeaad777d3d7 |
children | 7f0e2b656e5c |
comparison
equal
deleted
inserted
replaced
10:68bc459c9f59 | 11:a29665fa9c62 |
---|---|
26 {'label':'Main Config','action':'changeMetaDataForm'}, | 26 {'label':'Main Config','action':'changeMetaDataForm'}, |
27 {'label':'Import XML Schema','action':'importMetaDataExportXML'}, | 27 {'label':'Import XML Schema','action':'importMetaDataExportXML'}, |
28 #{'label':'Select Fields for Display','action':'indicateDisplayFieldsForm'}, | 28 #{'label':'Select Fields for Display','action':'indicateDisplayFieldsForm'}, |
29 ) | 29 ) |
30 | 30 |
31 mappingSelectAttribute = 'type' | 31 mappingSelectAttribute = None |
32 """the name of the attribute that can be used to select a mapping (if applicable)""" | 32 """the name of the attribute that can be used to select a mapping (if applicable)""" |
33 | 33 |
34 def __init__(self,id,shortDescription='',description='',fields=''): | 34 def __init__(self,id,title=None,shortDescription='',description='',fields=''): |
35 """initialize a new instance""" | 35 """initialize a new instance""" |
36 self.id = id | 36 self.id = id |
37 # title is tag name | |
38 if title: | |
39 self.title = title | |
40 else: | |
41 # assume id is tag name | |
42 self.title = id | |
43 | |
37 self.shortDescription =shortDescription #label fuer link auf add page | 44 self.shortDescription =shortDescription #label fuer link auf add page |
38 self.description=description #description of the method for link page | 45 self.description=description #description of the method for link page |
39 self.fieldList=fields.split(",")[0:] | 46 self.fieldList=fields.split(",")[0:] |
40 #self.metaDataServerUrl="" # muss mit change metadata gesetzt werden | 47 #self.metaDataServerUrl="" # muss mit change metadata gesetzt werden |
41 | 48 |
44 """returns fieldList""" | 51 """returns fieldList""" |
45 return ','.join(self.fieldList) | 52 return ','.join(self.fieldList) |
46 | 53 |
47 def getTagName(self): | 54 def getTagName(self): |
48 """returns the tag name of this element""" | 55 """returns the tag name of this element""" |
49 return self.shortDescription | 56 if self.title: |
57 return self.title | |
58 else: | |
59 return self.shortDescription | |
50 | 60 |
51 def getXmlPath(self, omitRoot=False): | 61 def getXmlPath(self, omitRoot=False): |
52 """returns the xpath to this element""" | 62 """returns the xpath to this element""" |
53 path = '/%s'%self.getTagName() | 63 path = '/%s'%self.getTagName() |
54 parent = self.aq_parent | 64 parent = self.aq_parent |
123 return mapping | 133 return mapping |
124 | 134 |
125 def getMapFields(self, data): | 135 def getMapFields(self, data): |
126 """returns dict with metadata description for data""" | 136 """returns dict with metadata description for data""" |
127 fields = {} | 137 fields = {} |
128 type = data['@type'] | 138 type = data.get('@type', None) |
139 if not type: | |
140 logging.error("getMapFields: no @type!") | |
141 return fields | |
142 | |
129 # get mapping from main/meta/bib | 143 # get mapping from main/meta/bib |
130 mapping = self.getMapping(type) | 144 mapping = self.getMapping(type) |
131 if mapping is None: | 145 if mapping is None: |
132 logging.error("getMapFields: no mapping for type: %s"%type) | 146 logging.error("getMapFields: no mapping for type: %s"%type) |
133 return fields | 147 return fields |
295 | 309 |
296 security.declarePublic('changeMetaDataForm') | 310 security.declarePublic('changeMetaDataForm') |
297 changeMetaDataForm = PageTemplateFile('zpt/changeMetadata', globals()) | 311 changeMetaDataForm = PageTemplateFile('zpt/changeMetadata', globals()) |
298 | 312 |
299 security.declarePublic('changeMetaData') | 313 security.declarePublic('changeMetaData') |
300 def changeMetaData(self,shortDescription,description,fields,metaDataServerUrl,RESPONSE=None): | 314 def changeMetaData(self,title=None,shortDescription=None,description=None,mappingSelectAttribute=None,fields=None,metaDataServerUrl=None,RESPONSE=None): |
301 """Change Metadata""" | 315 """Change Metadata""" |
316 self.title = title | |
302 self.shortDescription=shortDescription | 317 self.shortDescription=shortDescription |
303 self.description=description | 318 self.description=description |
304 self.fieldList=fields.split(",")[0:] | 319 self.mappingSelectAttribute=mappingSelectAttribute |
320 if fields: | |
321 self.fieldList=fields.split(",")[0:] | |
322 | |
305 self.metaDataServerUrl=metaDataServerUrl | 323 self.metaDataServerUrl=metaDataServerUrl |
324 | |
306 if RESPONSE is not None: | 325 if RESPONSE is not None: |
307 RESPONSE.redirect('manage_main') | 326 RESPONSE.redirect('manage_main') |
308 | 327 |
309 | 328 |
310 def manage_addMetaDataForm(self): | 329 def manage_addMetaDataForm(self): |