ontomde-uml2-flex 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,40 @@
1
+
2
+
3
+ module Mrdf_Model
4
+
5
+ # EXAMPLE
6
+ # // ActionScript file
7
+ # import src.package1.Adresse;
8
+ # import src.package1.AdresseType2;
9
+ # import src.package1.AdresseType1;
10
+ # import src.package1.Session;
11
+ # import src.package1.Client;
12
+ # import src.package1.Contrat;
13
+ # import src.package1.methods.ClientajoutRapideContratMPC;
14
+ #
15
+ #
16
+ #
17
+ # cpForm:AdresseType1;
18
+ # cpForm:AdresseType2;
19
+ # cpForm:Adresse;
20
+ # cpForm:ClientajoutRapideContratMPC;
21
+ # cpForm:Contrat;
22
+ # cpForm:Client;
23
+ # cpForm:Session;
24
+ def flex_generateImportationAS
25
+ mtk_writeSession("#{context[:javaDir]}/importation.as"){
26
+ flex_writeImportationAS
27
+ }
28
+ end
29
+ def flex_writeImportationAS
30
+ write("// Action Script file used to force inclusion of view into .swf\n")
31
+ struts_viewableClassifier(true).each { |b|
32
+ write("import #{Muml_Class::FLEX_NS_PREFIX}#{b.java_qualifiedName};\n")
33
+ }
34
+ write("\n//force inclusion of class in .swf by creating dummy instances\n")
35
+ struts_viewableClassifier(true).each { |b|
36
+ write("cpForm:#{b.java_Name};\n")
37
+ }
38
+ write("// eof \n")
39
+ end
40
+ end
@@ -0,0 +1,338 @@
1
+
2
+ module Mrdf_Model
3
+ def flex_generateVO
4
+ struts_viewableClassifier(false).each { |b|
5
+ b.flex_generateVO
6
+ }
7
+ end
8
+ end
9
+
10
+ module Muml_Class
11
+ def flex_generateVO
12
+ mtk_writeSession("#{java_FileName.to_s.gsub(/\.[^.\/]*$/,"")}VO.as") {
13
+ flex_writeVO
14
+ }
15
+ end
16
+
17
+
18
+ def flex_NameVO
19
+ return "#{java_Name}VO"
20
+ end
21
+ FLEX_NS_PREFIX=STRUTS_XML_VIEW_PREFIX
22
+ def flex_writeVO
23
+ importSet=Set.new
24
+ flex_ownedAttributeSet.each { |c|
25
+ t=c.uml_type_one
26
+ next if t.kind_of?(Muml_DataType)
27
+ importSet.add(t)
28
+ }
29
+
30
+ importString=""
31
+ importSet.each { |t|
32
+ importString="#{importString}\n import #{FLEX_NS_PREFIX}#{t.java_qualifiedName}VO;"
33
+ }
34
+
35
+ before= <<ENDHEAD
36
+ package #{FLEX_NS_PREFIX}#{umlx_owner_one.java_qualifiedName}
37
+ {
38
+ import mx.collections.ArrayCollection;
39
+ import utils.DeserializeXMLUtil;
40
+ #{importString}
41
+ [Bindable]
42
+ public class #{flex_NameVO}
43
+ {
44
+ ENDHEAD
45
+
46
+ after= <<ENDBOTTOM
47
+ }
48
+ }
49
+ ENDBOTTOM
50
+
51
+ encloseWrite(before,after) {
52
+ flex_writeVO_vars
53
+ flex_writeVO_initFromXML
54
+ flex_writeVO_initItemFromXML
55
+ flex_writeVO_getParameter
56
+ }
57
+ end
58
+
59
+ def flex_writeVO_vars
60
+ flex_ownedAttributeSet.each { |prop|
61
+ tpl=JavaMapping.instance.getTemplate(prop.uml_type_one)
62
+ tpl.flex_writeVO_vars_datatype(prop)
63
+ }
64
+ end
65
+
66
+ #Generates variable declaration
67
+ def flex_writeVO_initFromXML
68
+ before= <<ENDHEAD
69
+ //initialisation du formulaire a partir du XML recu de l'application Struts
70
+ public function initFromXML(source:XML):void{
71
+ ENDHEAD
72
+
73
+ after= <<ENDBOTTOM
74
+ } // end initFromXML
75
+ ENDBOTTOM
76
+
77
+ encloseWrite(before,after) {
78
+ flex_ownedAttributeSet.each { |prop|
79
+ tpl=JavaMapping.instance.getTemplate(prop.uml_type_one)
80
+ tpl.flex_writeVO_initFromXML_mapping(prop)
81
+ }
82
+ }
83
+ end
84
+
85
+
86
+ # EXAMPLES:
87
+ # nom = utils.DeserializeXMLUtil.getOptionAttributValue(source, 'nom');
88
+ # id= DeserializeXMLUtil.getOptionAttributValue(source, 'id');
89
+ # //recuperation de la valeur de type date de l'atribut x de l'option
90
+ # datedenaissance = DeserializeXMLUtil.getOptionDateAttributValue(source, 'datedenaissance');
91
+ def flex_writeVO_initItemFromXML
92
+ before= <<ENDHEAD
93
+ //initialisation d'un item du type de la class pour etre referencer dans les VOs a partir des options du XML
94
+ public function initItemFromXML(source:XMLList):void{
95
+ ENDHEAD
96
+
97
+ after=<<ENDBOTTOM
98
+ } // initItemFromXML
99
+ ENDBOTTOM
100
+
101
+ encloseWrite(before,after) {
102
+ flex_ownedAttributeSet.each { |prop|
103
+ tpl=JavaMapping.instance.getTemplate(prop.uml_type_one)
104
+ tpl.flex_writeVO_initItemFromXML_mapping(prop)
105
+ }
106
+ }
107
+ end
108
+ def flex_writeVO_getParameter
109
+ before=<<ENDHEAD
110
+ //parametres complementaires à passer aux requetes concernant cette objet
111
+ public function getParameter():Object{
112
+ var param:Object= {};
113
+ ENDHEAD
114
+
115
+ after=<<ENDBOTTOM
116
+ return param;
117
+ } // getParameter
118
+ ENDBOTTOM
119
+
120
+ encloseWrite(before,after) {
121
+ flex_ownedAttributeSet.each { |prop|
122
+ tpl=JavaMapping.instance.getTemplate(prop.uml_type_one)
123
+ tpl.flex_writeVO_getParameter(prop)
124
+ }}
125
+
126
+ end
127
+
128
+ end
129
+
130
+ class JavaMapping
131
+ def flex_writeVO_vars_datatype(prop)
132
+ prop.write("<!-- # no mapping for #{prop.java_Name} errcode=1 (#{self.class}) -->\n")
133
+ end
134
+ def flex_writeVO_getParameter(prop)
135
+ prop.write("<!-- # no mapping for #{prop.java_Name} errcode=2 (#{self.class}) -->\n")
136
+ end
137
+ def flex_writeVO_initItemFromXML_mapping(prop)
138
+ prop.write("<!-- # no mapping for #{prop.java_Name} errcode=3 (#{self.class}) -->\n")
139
+ end
140
+
141
+ def flex_writeVO_initFromXML_mapping(prop)
142
+ prop.write("<!-- # no mapping for #{prop.java_Name} errcode=4 (#{self.class}) -->\n")
143
+ end
144
+ def flex_writeMXML_vo_mapping(prop)
145
+ puts("WARNING: Unknown flex_writeMXML_vo_mapping for property #{prop.java_Name} and mapping=#{self.class}")
146
+ #ignore element
147
+ #prop.write("<!-- # no mapping for #{prop.java_Name} errcode=5 (#{self.class}) -->\n")
148
+ end
149
+ def flex_writeMXML_Form_item_property(prop)
150
+ prop.write("<!-- # no mapping for #{prop.java_Name} errcode=6 (#{self.class}) -->\n")
151
+ end
152
+ def flex_writeMXML_Form_item_property_column(prop)
153
+ prop.write("<!-- # no mapping for #{prop.java_Name} errcode=7 (#{self.class}) -->\n")
154
+ end
155
+ end
156
+
157
+ class JavaMappingBoolean < JavaMapping
158
+ def flex_writeVO_vars_datatype(prop)
159
+ prop.write("public var #{prop.java_Name}:Boolean;\n")
160
+ end
161
+ def flex_writeVO_getParameter(prop)
162
+ prop.write("param.#{prop.java_Name} = #{prop.java_Name};\n")
163
+ end
164
+
165
+ # EXAMPLES:
166
+ # isX = DeserializeXMLUtil.getFormBooleanAttributValue(source, 'isX');
167
+ def flex_writeVO_initFromXML_mapping(prop)
168
+ prop.write("#{prop.java_Name} = DeserializeXMLUtil.getFormBooleanAttributValue(source, '#{prop.java_Name}');\n")
169
+ end
170
+
171
+ def flex_writeVO_initItemFromXML_mapping(prop)
172
+ prop.write("#{prop.java_Name}=DeserializeXMLUtil.getOptionBooleanAttributValue(source,'#{prop.java_Name}');\n")
173
+ end
174
+ end
175
+
176
+ class JavaMappingText < JavaMapping
177
+ # EXAMPLES:
178
+ # public var nom:String;
179
+ # public var id:String;
180
+ def flex_writeVO_vars_datatype(prop)
181
+ prop.write("public var #{prop.java_Name}:String;\n")
182
+ end
183
+
184
+ # EXAMPLE:
185
+ # param.nom = nom;
186
+ def flex_writeVO_getParameter(prop)
187
+ prop.write("param.#{prop.java_Name} = #{prop.java_Name};\n")
188
+ end
189
+
190
+ # nom = DeserializeXMLUtil.getFormAttributValue(source, 'nom');
191
+ # id = DeserializeXMLUtil.getFormAttributValue(source, 'id');
192
+ def flex_writeVO_initFromXML_mapping(prop)
193
+ prop.write("#{prop.java_Name} = DeserializeXMLUtil.getFormAttributValue(source, '#{prop.java_Name}');\n")
194
+ end
195
+ def flex_writeVO_initItemFromXML_mapping(prop)
196
+ prop.write("#{prop.java_Name}=DeserializeXMLUtil.getOptionAttributValue(source,'#{prop.java_Name}');\n")
197
+ end
198
+ end
199
+ class JavaMappingOrdinal < JavaMappingText
200
+ # EXAMPLES:
201
+ # public var datedenaissance:Number;
202
+ def flex_writeVO_vars_datatype(prop)
203
+ prop.write("public var #{prop.java_Name}:Number;\n")
204
+ end
205
+ # EXAMPLE:
206
+ # DeserializeXMLUtil.getFormNumberAttributValue(source, 'numero');
207
+ def flex_writeVO_initFromXML_mapping(prop)
208
+ prop.write("#{prop.java_Name} = DeserializeXMLUtil.getFormNumberAttributValue(source, '#{prop.java_Name}');\n")
209
+ end
210
+ # EXAMPLE:
211
+ # numero=DeserializeXMLUtil.getOptionNumberAttributValue(source,'numero');
212
+ def flex_writeVO_initItemFromXML_mapping(prop)
213
+ prop.write("#{prop.java_Name}=DeserializeXMLUtil.getOptionNumberAttributValue(source,'#{prop.java_Name}');\n")
214
+ end
215
+ end
216
+
217
+ class JavaMappingTimeStamp < JavaMapping
218
+ # EXAMPLES:
219
+ # public var datedenaissance:Date;
220
+ def flex_writeVO_vars_datatype(prop)
221
+ prop.write("public var #{prop.java_Name}:Date;\n")
222
+ end
223
+ # EXAMPLES:
224
+ # param.datedenaissance = utils.DateUtil.FormatForDatabase(datedenaissance);
225
+ def flex_writeVO_getParameter(prop)
226
+ prop.write("param.#{prop.java_Name} = utils.DateUtil.FormatForDatabase(#{prop.java_Name});\n")
227
+ end
228
+
229
+ # EXAMPLES:
230
+ # datedenaissance = DeserializeXMLUtil.getFormDateAttributValue(source, 'datedenaissance');
231
+ def flex_writeVO_initFromXML_mapping(prop)
232
+ prop.write("#{prop.java_Name} = DeserializeXMLUtil.getFormDateAttributValue(source, '#{prop.java_Name}');\n")
233
+ end
234
+ def flex_writeVO_initItemFromXML_mapping(prop)
235
+ prop.write("#{prop.java_Name}=DeserializeXMLUtil.getOptionDateAttributValue(source,'#{prop.java_Name}');\n")
236
+ end
237
+ end
238
+
239
+ # EXAMPLES:
240
+ # public var datedenaissance:Date;
241
+ class JavaMappingCalendar < JavaMapping
242
+ def flex_writeVO_vars_datatype(prop)
243
+ prop.write("public var #{prop.java_Name}:Date;\n")
244
+ end
245
+
246
+ # EXAMPLES:
247
+ # param.datedenaissance = utils.DateUtil.FormatForDatabase(datedenaissance);
248
+ def flex_writeVO_getParameter(prop)
249
+ prop.write("param.#{prop.java_Name} = utils.DateUtil.FormatForDatabase(#{prop.java_Name});\n")
250
+ end
251
+
252
+ # EXAMPLES:
253
+ # datedenaissance = DeserializeXMLUtil.getFormDateAttributValue(source, 'datedenaissance');
254
+ def flex_writeVO_initFromXML_mapping(prop)
255
+ prop.write("#{prop.java_Name} = DeserializeXMLUtil.getFormDateAttributValue(source, '#{prop.java_Name}');\n")
256
+ end
257
+
258
+ def flex_writeVO_initItemFromXML_mapping(prop)
259
+ prop.write("#{prop.java_Name}=DeserializeXMLUtil.getOptionDateAttributValue(source,'#{prop.java_Name}');\n")
260
+ end
261
+ end
262
+
263
+ class JavaMappingGenericEnum < JavaMapping
264
+ # EXAMPLES:
265
+ # public var civilite:Object;
266
+ # public var selectedItemCivilite:Object;
267
+ # public var civiliteSug:ArrayCollection;
268
+ def flex_writeVO_vars_datatype(prop)
269
+ prop.write("public var #{prop.java_Name}:Object;\n")
270
+ prop.write("public var #{prop.java_Name}Sug:ArrayCollection;\n")
271
+ prop.write("public var selectedItem#{prop.java_Name}:Object;\n")
272
+ end
273
+
274
+ # EXAMPLES:
275
+ # //key car c'est un item de l'enum
276
+ # param.civilite = civilite.key;
277
+ def flex_writeVO_getParameter(prop)
278
+ prop.write("param.#{prop.java_Name} = #{prop.java_Name}.key;\n")
279
+ end
280
+
281
+ # EXAMPLES:
282
+ # civiliteSug = DeserializeXMLUtil.getFormEnum(source, 'civilite');
283
+ # civilite = DeserializeXMLUtil.getFormEnumAttributSelected(source, 'civilite', civiliteSug);
284
+ def flex_writeVO_initFromXML_mapping(prop)
285
+ prop.write("#{prop.java_Name}Sug = DeserializeXMLUtil.getFormEnum(source, '#{prop.java_Name}');\n")
286
+ prop.write("#{prop.java_Name} = DeserializeXMLUtil.getFormEnumAttributSelected(source, '#{prop.java_Name}', #{prop.java_Name}Sug);\n")
287
+ end
288
+
289
+ def flex_writeVO_initItemFromXML_mapping(prop)
290
+ #nop
291
+ end
292
+ end
293
+
294
+ class JavaMappingGenericClass < JavaMapping
295
+
296
+ # EXAMPLES:
297
+ # public var adresse:ArrayCollection;
298
+ # public var adressesSug:ArrayCollection;
299
+ # public var dernierContrat:ArrayCollection;
300
+ # public var dernierContratSug:ArrayCollection;
301
+ def flex_writeVO_vars_datatype(prop)
302
+ prop.write("public var #{prop.java_Name}:ArrayCollection;\n")
303
+ if(prop.umlx_isComposite?)
304
+ prop.write("public var #{prop.java_Name}CreateAndAddSug:ArrayCollection;\n")
305
+ prop.write("public var #{prop.java_Name}Sug:ArrayCollection;\n")
306
+ else
307
+ prop.write("public var #{prop.java_Name}Sug:ArrayCollection;\n")
308
+ end
309
+ end
310
+ def flex_writeVO_getParameter(prop)
311
+ prop.write("// #{prop.java_Name}\n")
312
+ end
313
+
314
+ #EXAMPLES:
315
+ # For a composition:
316
+ # adresseSug = DeserializeXMLUtil.getFormAttributeAssignable(source, 'adresse');
317
+ # adresse = DeserializeXMLUtil.getFormAttributSelection(source, 'adresse', AdresseVO);
318
+ # for an association:
319
+ # adresse = DeserializeXMLUtil.getFormAttributSelection(source, 'adresse', AdresseVO);
320
+ # favorisSug = DeserializeXMLUtil.getFormAttributSug(source, 'favoris', ContratVO);
321
+ def flex_writeVO_initFromXML_mapping(prop)
322
+
323
+ if(prop.umlx_isComposite?)
324
+ prop.write("#{prop.java_Name}CreateAndAddSug = DeserializeXMLUtil.getFormAttributeAssignable(source, '#{prop.java_Name}');\n")
325
+ else
326
+ prop.write("#{prop.java_Name}Sug = DeserializeXMLUtil.getFormAttributSug(source, '#{prop.java_Name}',#{prop.uml_type_one.java_Name}VO);\n")
327
+ end
328
+ prop.write("#{prop.java_Name} = DeserializeXMLUtil.getFormAttributSelection(source, '#{prop.java_Name}', #{prop.uml_type_one.java_Name}VO);\n")
329
+ end
330
+
331
+ def flex_writeVO_initItemFromXML_mapping(prop)
332
+ #nop
333
+ end
334
+ end
335
+ #
336
+
337
+
338
+ #
@@ -0,0 +1,19 @@
1
+
2
+ #require 'ontomde-core'
3
+ #
4
+ #
5
+ ##Action Script file type
6
+ #class FileTypeActionScript < FileTypeJava
7
+ # def initialize(ext=".as")
8
+ # super(ext)
9
+ # end
10
+ #end
11
+ #FileTypeActionScript.instance # register
12
+ #
13
+ #class FileTypeJavaScript < FileTypeActionScript
14
+ # def initialize(ext=".js")
15
+ # super(ext)
16
+ # end
17
+ #end
18
+ #FileTypeJavaScript.instance # register
19
+