16 |
# write to the Free Software Foundation, Inc., 59 Temple Place |
# write to the Free Software Foundation, Inc., 59 Temple Place |
17 |
# - Suite 330, Boston, MA 02111-1307, USA. |
# - Suite 330, Boston, MA 02111-1307, USA. |
18 |
# |
# |
19 |
# Copyright 2002 Free Software Foundation |
# Copyright 2002-2003 Free Software Foundation |
20 |
# |
# |
21 |
# FILE: |
# FILE: |
22 |
# GNParser.py |
# GIParser.py |
23 |
# |
# |
24 |
# DESCRIPTION: |
# DESCRIPTION: |
25 |
# Class that contains a sax based xml processor for GNUE Integrator |
# Class that contains a sax based xml processor for GNUE Integrator |
27 |
# NOTES: |
# NOTES: |
28 |
# |
# |
29 |
|
|
30 |
from gnue.common import GParser |
from gnue.common import GParser, GDataSource |
31 |
|
|
32 |
import copy, types |
import copy, types |
33 |
from gnue.common import GTypecast |
from gnue.common import GTypecast |
56 |
# not want the loaded form to connect to databases, etc) |
# not want the loaded form to connect to databases, etc) |
57 |
####################################################### |
####################################################### |
58 |
|
|
59 |
def loadMapping(buffer, initialize=1): |
def loadMapping(buffer, connections, initialize=1): |
60 |
return GParser.loadXMLObject (buffer, xmlProcessHandler, 'GNProcesses', 'processes', |
return GParser.loadXMLObject(buffer, xmlProcessHandler, 'GIMappings', |
61 |
initialize, attributes={}) |
'mappings',initialize, |
62 |
|
attributes={"_connections" :connections}) |
63 |
|
|
64 |
|
|
65 |
xmlElements = None |
xmlElements = None |
70 |
global xmlElements |
global xmlElements |
71 |
|
|
72 |
if xmlElements == None: |
if xmlElements == None: |
73 |
import GNObjects |
import GIObjects |
74 |
|
import GISources |
75 |
|
from gnue.common import GTrigger |
76 |
|
|
77 |
xmlElements = { |
xmlElements = { |
78 |
'mappings': { |
'mappings': { |
82 |
'Attributes': { |
'Attributes': { |
83 |
'title': { |
'title': { |
84 |
'Typecast': GTypecast.text, |
'Typecast': GTypecast.text, |
85 |
'Default': 'Untitled Menu' } }, |
'Default': 'Untitled Menu' }, |
86 |
|
'type': { |
87 |
|
'ValueSet': { |
88 |
|
'direct': {}, |
89 |
|
'rowmerge': {}, |
90 |
|
'rowsplit': {}}, |
91 |
|
'Default': 'simple', |
92 |
|
'Typecast': GTypecast.name }}, |
93 |
'ParentTags': None }, |
'ParentTags': None }, |
94 |
|
|
95 |
'mapping': { |
'mapping': { |
99 |
# 'Required': 1, |
# 'Required': 1, |
100 |
'Unique': 1, |
'Unique': 1, |
101 |
'Typecast': GTypecast.name }, |
'Typecast': GTypecast.name }, |
102 |
'title': { |
'name': { |
103 |
'Typecast': GTypecast.text } }, |
'Unique': 1, |
104 |
|
'Required': 1, |
105 |
|
'Typecast': GTypecast.name }, |
106 |
|
'source': { |
107 |
|
'Required': 1, |
108 |
|
'Typecast': GTypecast.name }, |
109 |
|
'destination': { |
110 |
|
'Required': 1, |
111 |
|
'Typecast': GTypecast.name }, |
112 |
|
'append': { |
113 |
|
'Required': 0, |
114 |
|
'Default': 1, |
115 |
|
'Description':'if set to false, destination datasources will'+\ |
116 |
|
' be cleared before inserting new data.', |
117 |
|
'Typecast': GTypecast.boolean } }, |
118 |
'ParentTags': ('mappings',) }, |
'ParentTags': ('mappings',) }, |
119 |
|
|
120 |
|
'sources': { |
121 |
|
'BaseClass': GISources.GISources, |
122 |
|
'Attributes': {}, |
123 |
|
'ParentTags': ('mappings',) }, |
124 |
|
|
125 |
|
## 'process': { |
126 |
|
## 'BaseClass': GIObjects.GIProcess, |
127 |
|
## 'Attributes': { |
128 |
|
## 'rowmapping': { |
129 |
|
## 'ValueSet': { |
130 |
|
## 'merge': {}, |
131 |
|
## 'split': {}, |
132 |
|
## 'simple': {}}, |
133 |
|
## 'Default': 'simple', |
134 |
|
## 'Typecast': GTypecast.name }}, |
135 |
|
## 'ParentTags': ('mapping',) }, |
136 |
|
|
137 |
|
'submapping': { |
138 |
|
'BaseClass': GIObjects.GISubMapping, |
139 |
|
'Attributes': { |
140 |
|
'name': { |
141 |
|
'Required': 1, |
142 |
|
'Typecast': GTypecast.name }, |
143 |
|
'type': { |
144 |
|
# 'Required': 1, |
145 |
|
'ValueSet': { |
146 |
|
'child': {}, |
147 |
|
'direct': {}, |
148 |
|
'addition': {}}, |
149 |
|
'default':'direct'}}, |
150 |
|
'ParentTags': ('mapping',) }, |
151 |
|
|
152 |
|
|
153 |
|
'action': { |
154 |
|
'BaseClass': GIObjects.GIAction, |
155 |
|
'Attributes': { |
156 |
|
'type': { |
157 |
|
'Required': 1, |
158 |
|
'ValueSet': { |
159 |
|
'merge': {}, |
160 |
|
'split': {}, |
161 |
|
'copy': {}}}, |
162 |
|
# 'parameter': { |
163 |
|
# 'Required': 1, |
164 |
|
# 'Typecast': GTypecast.name }, |
165 |
|
'on-fail': { |
166 |
|
# 'Required': 1, |
167 |
|
'Typecast': GTypecast.name }, |
168 |
|
'splitmask': { |
169 |
|
# 'Required': 1, |
170 |
|
'Typecast': GTypecast.name }, |
171 |
|
'mergemask': { |
172 |
|
# 'Required': 1, |
173 |
|
'Default':'@1', |
174 |
|
'Typecast': GTypecast.name }}, |
175 |
|
'ParentTags': ('process','mapping') }, |
176 |
|
|
177 |
|
'field': { |
178 |
|
'BaseClass': GIObjects.GIField, |
179 |
|
'Attributes': { |
180 |
|
'name': { |
181 |
|
'Required': 1, |
182 |
|
'Typecast': GTypecast.name }, |
183 |
|
'type': { |
184 |
|
'Required': 1, |
185 |
|
'ValueSet': { |
186 |
|
'src': {}, |
187 |
|
'dest': {}}}, |
188 |
|
'trim': { |
189 |
|
# 'Required': 1, |
190 |
|
'Default': 0, |
191 |
|
'Typecast': GTypecast.name }}, |
192 |
|
'ParentTags': ('merge',) } |
193 |
|
|
194 |
|
}; |
195 |
|
|
196 |
|
# |
197 |
|
# Add DataSource elements |
198 |
|
# |
199 |
|
xmlElements.update( |
200 |
|
GDataSource.getXMLelements( |
201 |
|
updates={'datasource': { |
202 |
|
'BaseClass': GISources.GIDataSource, |
203 |
|
'ParentTags': ('sources',) } #, |
204 |
|
#'cparam': { |
205 |
|
# 'BaseClass': GFObjects.GFCParam } |
206 |
|
})) |
207 |
|
|
208 |
|
# |
209 |
|
# Add trigger elements |
210 |
|
# |
211 |
|
xmlElements.update( |
212 |
|
GTrigger.getXMLelements( |
213 |
|
updates={'trigger':{ |
214 |
|
'ParentTags': ('mapping','submapping','action') }, |
215 |
|
})) |
216 |
|
|
217 |
|
|
218 |
return xmlElements |
return xmlElements |
219 |
|
|