From e4c41ec8f6b4d48048f3054c1e75288deb7ccae9 Mon Sep 17 00:00:00 2001 From: Sesostris Vieira Date: Fri, 3 Jun 2011 12:20:26 +0000 Subject: [PATCH] =?UTF-8?q?Conclus=C3=A3o=20da=20interface?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sigi/birtReport/birtReport.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/sigi/birtReport/birtReport.py b/sigi/birtReport/birtReport.py index 0841ce2..0252ff6 100644 --- a/sigi/birtReport/birtReport.py +++ b/sigi/birtReport/birtReport.py @@ -64,7 +64,24 @@ class BirtReport(): for xmlProp in dataSet.getElementsByTagName('xml-property'): if xmlProp.getAttribute('name') == 'queryText': formField['queryText'] = xmlProp.childNodes[0].data - + + labelFieldName = formField['labelExpr'].replace('dataSetRow["', '').replace('"]', '') + valueFieldName = formField['valueExpr'].replace('dataSetRow["', '').replace('"]', '') + + for struct in dataSet.getElementsByTagName('structure'): + if struct.getAttribute('name') == 'cachedMetaData': + for list in struct.getElementsByTagName('list-property'): + if list.getAttribute('name') == 'resultSet': + for subStructure in list.getElementsByTagName('structure'): + dataSetField = {} + for fieldProp in subStructure.getElementsByTagName('property'): + dataSetField[fieldProp.getAttribute('name').encode('ascii')] = fieldProp.childNodes[0].data + + if dataSetField['name'] == labelFieldName: + labelFieldIndex = int(dataSetField['position']) - 1 + if dataSetField['name'] == valueFieldName: + valueFieldIndex = int(dataSetField['position']) - 1 + try: from django.db import connection cursor = connection.cursor() @@ -72,7 +89,7 @@ class BirtReport(): resultSet = cursor.fetchall() formField['selectionList'] = () for record in resultSet: - formField['selectionList'] = formField['selectionList'] + ({'value': record[0],'label': record[1]},) + formField['selectionList'] = formField['selectionList'] + ({'value': record[valueFieldIndex],'label': record[labelFieldIndex]},) # formField['selectionList'] = resultSet except: @@ -100,7 +117,7 @@ class BirtReport(): -#r = birtReport('/home/sesostris/workspace/sigi/BIRT_Reports/teste_parametros.rptdesign') +#r = BirtReport('/home/sesostris/workspace/sigi/BIRT_Reports/teste_parametros.rptdesign') #p = r.getReportParams() #print p['prm_estado']