Module: Muml_Class

Defined in:
lib/ontomde-uml2-flex/main.rb,
lib/ontomde-uml2-flex/Editor.mxml.rb,
lib/ontomde-uml2-flex/ValueObjectAS.rb,
lib/ontomde-uml2-flex/Editor.mxml.as.rb

Constant Summary collapse

FLEX_NS_PREFIX =
STRUTS_XML_VIEW_PREFIX

Instance Method Summary collapse

Instance Method Details

#as_addFormReference!Object



327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
# File 'lib/ontomde-uml2-flex/main.rb', line 327

def as_addFormReference!
	log.error{"adding flexFormRef for #{self}:#{self.class}"}
	p=umlx_createAndAddProperty("#{self.rdf_uri}_flexFormRef","flexForm")
	p.uml_isReadOnly="true"

	p.uml_type=as_formClass
	p.umlx_owner_one.as_addAccessorsFor!(p)
	p.as_getter_property_inv.each {|get|
		log.error("maj code")
		get.as_code=<<END
if(#{p.as_Name}==null){
#{p.as_Name} = new #{as_formClass.as_Name}();
#{p.as_Name}.setModif(this);
}
return #{p.as_Name};
END
	}
end

#as_formClassObject



324
325
326
# File 'lib/ontomde-uml2-flex/main.rb', line 324

def as_formClass
	return umlx_getOrCreateClass("#{as_qualifiedName}Form")
end

#flex_generateMXMLObject



17
18
19
20
21
# File 'lib/ontomde-uml2-flex/Editor.mxml.rb', line 17

def flex_generateMXML
	mtk_writeSession("#{java_FileName.to_s.gsub(/\.[^.\/]*$/,"")}.mxml"){
		flex_writeMXML
		}
end

#flex_generateVOObject



11
12
13
14
15
# File 'lib/ontomde-uml2-flex/ValueObjectAS.rb', line 11

def flex_generateVO
	mtk_writeSession("#{java_FileName.to_s.gsub(/\.[^.\/]*$/,"")}VO.as") {
		flex_writeVO
		}
end

#flex_mxml_as_generateAsObject



11
12
13
14
15
16
17
18
# File 'lib/ontomde-uml2-flex/Editor.mxml.as.rb', line 11

def flex_mxml_as_generateAs
	#flex_mxml_as_generateAs_jspHeader
	flex_mxml_as_generateAs_commun
	flex_mxml_as_generateAs_operations
	flex_mxml_as_generateAs_edit_remove_add
	flex_mxml_as_generateAs_validateForm
	flex_mxml_as_generateAs_createAndAdd
end

#flex_mxml_as_generateAs_communObject



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/ontomde-uml2-flex/Editor.mxml.as.rb', line 65

def flex_mxml_as_generateAs_commun
 #//TODO this.#{Muml_Class::STRUTS_REQUESTED_TAB}=model.id.toString();
	write <<-END_SCRIPT
public function #{STRUTS_REFRESH_ACTION}() :void{
 this.#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}="#{STRUTS_REFRESH_ACTION}";
 submit();
 }
public function #{STRUTS_RETURN_ACTION}() :void{
 this.#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}="#{STRUTS_RETURN_ACTION}";
 submit();
 }
public function #{STRUTS_PROCEED_ACTION}() :void{
 this.#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}="#{STRUTS_PROCEED_ACTION}";
 submit();
 }
	END_SCRIPT
end

#flex_mxml_as_generateAs_createAndAddObject



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ontomde-uml2-flex/Editor.mxml.as.rb', line 21

def flex_mxml_as_generateAs_createAndAdd
	flex_ownedAttributeSet.each { |a|
		next unless a.umlx_isComposite?
		#next if a.umlx_oneSide?
		f="createAndAdd#{a.java_NameBean}"
		write %{
public function #{f}(reqTypeParam:String):void {
 this.#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}="#{f}";
 this.#{STRUTS_REQUESTED_CREATION_TYPE_FIELD_NAME}=reqTypeParam;
 submit();
 }
}}
end

#flex_mxml_as_generateAs_edit_remove_addObject



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/ontomde-uml2-flex/Editor.mxml.as.rb', line 83

def flex_mxml_as_generateAs_edit_remove_add
flex_ownedAttributeSet.each { |a|
	#next unless a.umlx_isComposite?
	#next unless a.umlx_isAssociation?
	#next if a.umlx_oneSide?
		li=a.uml_isReadOnly? ? ["edit"] : ["edit","removeAndDelete"]
		li.each {|meth|
			f="#{meth}#{a.java_NameBean}"
			write <<-END
public function #{f}(objidParam:String) :void{
 if("_"+objidParam != "_empty") {
  this.#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}="#{f}";
  this.#{Muml_Class::STRUTS_REQUESTED_TAB}=objidParam;
  submit();
  } else {
   ExtendedAlert.error("no element selected for \\n#{flex_localizeMsg("#{self.java_qualifiedName}.#{a.java_Name}")}");
  }
 }
			END
		}
		li=a.uml_isReadOnly? ? [] : ["add"]
		li.each {|meth|
			f="#{meth}#{a.java_NameBean}"
			write <<-END
public function #{f}(e:SuggestionAddedEvent) :void{
 if("_"+e.idToAdd != "_empty") {
  this.#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}="#{f}";
  this.#{Muml_Class::STRUTS_REQUESTED_TAB}=e.idToAdd;
  submit();
  } else {
   ExtendedAlert.error("no element selected for \\n#{flex_localizeMsg("#{self.java_qualifiedName}.#{a.java_Name}")}");
  }
 }
			END
		}
	}
end

#flex_mxml_as_generateAs_operationsObject



52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/ontomde-uml2-flex/Editor.mxml.as.rb', line 52

def flex_mxml_as_generateAs_operations
uml_ownedOperation.each {|biz|
	next unless biz.umlx_businessMethod?
	f=biz.java_Name
	write <<-ENDMETH
public function #{f}() :void{
 this.#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}="#{f}";
 submit();
 }
	ENDMETH
	}
end

#flex_mxml_as_generateAs_validateFormObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/ontomde-uml2-flex/Editor.mxml.as.rb', line 35

def flex_mxml_as_generateAs_validateForm
	head=<<-ENDHEAD
public function validForm():Boolean{
	ENDHEAD

	foot=<<-ENDFOOT
 	return true;
 	}
	ENDFOOT

	encloseWrite(head,foot){ flex_ownedAttributeSet.each { |prop|
		tpl=JavaMapping.instance.getTemplate(prop.uml_type_one)
		tpl.flex_writeMXML_validate(prop)
	}}

end

#flex_NameVOObject



18
19
20
# File 'lib/ontomde-uml2-flex/ValueObjectAS.rb', line 18

def flex_NameVO
	return "#{java_Name}VO"
end

#flex_ownedAttributeSet(ignoreId = false) ⇒ Object



13
14
15
# File 'lib/ontomde-uml2-flex/Editor.mxml.rb', line 13

def flex_ownedAttributeSet(ignoreId=false)
	return struts_formAttribute(ignoreId)
end

#flex_writeMXMLObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/ontomde-uml2-flex/Editor.mxml.rb', line 23

def flex_writeMXML
	before=<<ENDHEAD
<?xml version="1.0" encoding="utf-8"?>
<mx:Box xmlns:mx="http://www.adobe.com/2006/mxml"  creationComplete="initForm()" height="100%" width="100%" xmlns:vo="#{FLEX_NS_PREFIX}#{umlx_owner_one.java_qualifiedName}.*" xmlns:utils="utils.*" xmlns:components="components.*" >
ENDHEAD

	after=<<ENDFOOT
</mx:Box>
ENDFOOT
	encloseWrite(before,after) {
		flex_writeMXML_script
		flex_writeMXML_vo
		flex_writeMXML_menu
		flex_writeMXML_MXvalidators
		flex_writeMXML_Form

	}
end

#flex_writeMXML_FormObject



259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
# File 'lib/ontomde-uml2-flex/Editor.mxml.rb', line 259

def flex_writeMXML_Form
	before= <<ENDHEAD
	<utils:ValidatorForm id="MyForm" defaultButton="{btnValidate}" validators="{validators}" valid="handleFormValidate(event)" invalid="handleFormValidate(event)" width="100%" height="100%">
		<mx:FormHeading styleName="PetitTitrePose" label="{getString('#{self.struts_actionForm_one.java_qualifiedName}.title')}"/>
ENDHEAD

	after= <<ENDFOOT
	</utils:ValidatorForm>

	<mx:ControlBar id="ControlButtons">
		<mx:Text id="status" width="186"/>
		<mx:Button label="{getString('button.validate')}" click="biz_proceed()" id="btnValidate"/>
		<mx:Button label="{getString('button.reset')}" click="this.executeBindings(true)" id="button2"/>
		<mx:Button label="HTML" click="{HTML_Display()}" id="buttontest"/>
		<mx:Button label="print" click="{doPrint()}" id="buttonPrint"/>
	</mx:ControlBar>
ENDFOOT

	encloseWrite(before,after) {
		#uml_ownedOperation.each { |operation|
		#	next unless operation.umlx_businessMethod?
		#	operation.flex_writeMXML_Form_item_methods
		#	}
		ignoreId=true
		flex_ownedAttributeSet(ignoreId).each { |prop|
			encloseWrite(%{<mx:FormItem label="{getString('#{self.struts_actionForm_one.java_qualifiedName}.#{prop.java_Name}')}">\n} ,%{</mx:FormItem>\n}) {
				tpl=JavaMapping.instance.getTemplate(prop.uml_type_one)
				tpl.flex_writeMXML_Form_item_property(prop)
				}
			}
		}
end

#flex_writeMXML_menuObject

generate menu (fixed and dynamic based on object functions)



232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# File 'lib/ontomde-uml2-flex/Editor.mxml.rb', line 232

def flex_writeMXML_menu
	before=<<ENDHEAD
<mx:ArrayCollection id="methods" source="{buXML.businessaction}"/>

<mx:Model id="buXML">
<businessactions>
<businessaction label="Valider" functionName="biz_proceed" icon="@Embed('/assets/valider.gif')"/>
<businessaction label="Annuler" functionName="" icon="@Embed('/assets/delete.png')"/>
<businessaction label="HTML" functionName="HTML_Display" icon="@Embed('/assets/html.gif')"/>
<businessaction label="Print" functionName="doPrint" icon="@Embed('/assets/printpca.gif')"/>
<businessaction label="{modelGlob.fullscreen?'Normal Size':'FullScreen'}" functionName="fullScreen" icon="@Embed('/assets/fullscreen.gif')"/>
ENDHEAD

	after=<<ENDFOOT
</businessactions>
</mx:Model>
ENDFOOT
	encloseWrite(before,after) {
		uml_ownedOperation.each { |op|
			next unless op.umlx_businessMethod?
			write(%{<businessaction label="{getString('#{op.umlx_owner_one.java_qualifiedName}.#{op.java_Name}')}" functionName="#{op.java_Name}"/>\n})
			}
}
end

#flex_writeMXML_MXvalidatorsObject



41
42
43
44
45
46
47
48
# File 'lib/ontomde-uml2-flex/Editor.mxml.rb', line 41

def flex_writeMXML_MXvalidators
	encloseWrite(%{<mx:Array id="validators">\n},%{</mx:Array>\n}) {
		flex_ownedAttributeSet.each { |prop|
			tpl=JavaMapping.instance.getTemplate(prop.uml_type_one)
			tpl.flex_writeMXML_MXvalidator(prop)
		}
	}
end

#flex_writeMXML_scriptObject

function editAdresse(objid) { if(“_”+objid != “_empty”) { doWhat=“editAdresse”; reqtab=objid; submit(); } else { Alert.show(“no element selected for nadresse”); } }

function removeAndDeleteAdresse(objid:String):void { if(“_”+objid != “_empty”) { doWhat=“removeAndDeleteAdresse”; reqtab=objid; submit(); } else { Alert.show(“no element selected for nadresse”); } }

function createAndAddAdresse(reqType):void { doWhat=“createAndAddAdresse”; this.reqType=reqType; submit(); }

function editFavoris(objid) { if(“_”+objid != “_empty”) { doWhat=“editFavoris”; reqtab=objid; submit(); } else { Alert.show(“no element selected for nfavoris”); } }

function removeAndDeleteFavoris(objid) { if(“_”+objid != “_empty”) { doWhat=“removeAndDeleteFavoris”; reqtab=objid; submit(); } else { Alert.show(“no element selected for nfavoris”); } }

function addFavoris(objid) { if(“_”+objid != “_empty”) { doWhat=“addFavoris”; reqtab=objid; submit(); } else { Alert.show(“no element selected for nfavoris”); } }

function createAndAddContrats(reqType) { doWhat=“createAndAddContrats”; this.reqType=“package1_dot_Contrat”; submit(); }

function editContrats(objid) { if(“_”+objid != “_empty”) { doWhat=“editContrats”; reqtab=objid; submit(); } else { Alert.show(“no element selected for ncontrats”); } }

function removeAndDeleteContrats(objid) { if(“_”+objid != “_empty”) { doWhat=“removeAndDeleteContrats”; reqtab=objid; submit(); } else { Alert.show(“no element selected for ncontrats”); } }

function addDernierContrat(id) { doWhat=“addDernierContrat”; this.reqtab=id; submit(); }

function editDernierContrat(objid) { if(“_”+objid != “_empty”) { doWhat=“editDernierContrat”; reqtab=objid; submit(); } else { Alert.show(“no element selected for ncontrats”); } }

function editLastMonthContracts(objid) { if(“_”+objid != “_empty”) { doWhat=“editLastMonthContracts”; reqtab=objid; submit(); } else { Alert.show(“no element selected for nLastMonthContracts”); } }

function removeAndDeleteDernierContrat(objid) { if(“_”+objid != “_empty”) { doWhat=“removeAndDeleteDernierContrat”; reqtab=objid; submit(); } else { Alert.show(“no element selected for ncontrats”); } }

function ajoutRapideContrat() { doWhat=“ajoutRapideContrat”; submit(); }

//////////////////////////////////////////////////// debut des fonctions metiers ////////////////////////////////////////////////////



192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/ontomde-uml2-flex/Editor.mxml.rb', line 192

def flex_writeMXML_script

	# (script directory is relative)
	before= <<ENDHEAD
 <mx:Script source="#{"../"*(umlx_hierarchy.length)}script/formsGlobalFunctions.as" />
 <mx:Script>
	<![CDATA[
ENDHEAD

	after=<<ENDFOOT
 	]]>
 </mx:Script>
ENDFOOT
	encloseWrite(before,after)  {
		flex_mxml_as_generateAs
	}
end

#flex_writeMXML_voObject

SAMPLE: nom=“Muml_Class.txtNomtxtNom.text” adresse=“Muml_Class.cmbAdressecmbAdresse.selectedItemcmbAdresse.selectedItem.id”



214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# File 'lib/ontomde-uml2-flex/Editor.mxml.rb', line 214

def flex_writeMXML_vo
	before=<<ENDHEAD
 <vo:#{flex_NameVO}  id="model"
ENDHEAD

	after=<<ENDFOOT
 />
ENDFOOT

	encloseWrite(before,after) {
		noId=true
		flex_ownedAttributeSet(noId).each { |prop|
			tpl=JavaMapping.instance.getTemplate(prop.uml_type_one)
			tpl.flex_writeMXML_vo_mapping(prop)
	}}
end

#flex_writeVOObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/ontomde-uml2-flex/ValueObjectAS.rb', line 22

def flex_writeVO
	importSet=Set.new
	flex_ownedAttributeSet.each { |c|
		t=c.uml_type_one
		next if t.kind_of?(Muml_DataType)
		importSet.add(t)
	}

	importString=""
	importSet.each { |t|
		importString="#{importString}\n	import #{FLEX_NS_PREFIX}#{t.java_qualifiedName}VO;"
	}

	before= <<ENDHEAD
package #{FLEX_NS_PREFIX}#{umlx_owner_one.java_qualifiedName}
{
	import mx.collections.ArrayCollection;
	import utils.DeserializeXMLUtil;
	#{importString}
	[Bindable]
	public class #{flex_NameVO}
	{
ENDHEAD

	after= <<ENDBOTTOM
	}
}
ENDBOTTOM

	encloseWrite(before,after) {
			flex_writeVO_vars
			flex_writeVO_initFromXML
			flex_writeVO_initItemFromXML
			flex_writeVO_getParameter
		}
end

#flex_writeVO_getParameterObject



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/ontomde-uml2-flex/ValueObjectAS.rb', line 108

def flex_writeVO_getParameter
	before=<<ENDHEAD
		//parametres complementaires à passer aux requetes concernant cette objet
		public function getParameter():Object{
			var param:Object= {};
ENDHEAD

	after=<<ENDBOTTOM
			return param;
		} // getParameter
ENDBOTTOM

	encloseWrite(before,after) {
			flex_ownedAttributeSet.each { |prop|
				tpl=JavaMapping.instance.getTemplate(prop.uml_type_one)
				tpl.flex_writeVO_getParameter(prop)
		}}

end

#flex_writeVO_initFromXMLObject

Generates variable declaration



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/ontomde-uml2-flex/ValueObjectAS.rb', line 67

def flex_writeVO_initFromXML
	before= <<ENDHEAD
	//initialisation du formulaire a partir du XML recu de l'application Struts
	public function initFromXML(source:XML):void{
ENDHEAD

	after= <<ENDBOTTOM
	} // end initFromXML
ENDBOTTOM

	encloseWrite(before,after) {
		flex_ownedAttributeSet.each { |prop|
			tpl=JavaMapping.instance.getTemplate(prop.uml_type_one)
			tpl.flex_writeVO_initFromXML_mapping(prop)
		}
	}
end

#flex_writeVO_initItemFromXMLObject

EXAMPLES:

nom = utils.DeserializeXMLUtil.getOptionAttributValue(source, 'nom');
id= DeserializeXMLUtil.getOptionAttributValue(source, 'id');
//recuperation de la valeur de type date de l'atribut x de l'option
datedenaissance = DeserializeXMLUtil.getOptionDateAttributValue(source, 'datedenaissance');


91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/ontomde-uml2-flex/ValueObjectAS.rb', line 91

def flex_writeVO_initItemFromXML
	before= <<ENDHEAD
		//initialisation d'un item du type de la class pour etre referencer dans les VOs a partir des options du XML
		public function initItemFromXML(source:XMLList):void{
ENDHEAD

	after=<<ENDBOTTOM
		} // initItemFromXML
ENDBOTTOM

	encloseWrite(before,after) {
		flex_ownedAttributeSet.each { |prop|
			tpl=JavaMapping.instance.getTemplate(prop.uml_type_one)
			tpl.flex_writeVO_initItemFromXML_mapping(prop)
		}
	}
end

#flex_writeVO_varsObject



59
60
61
62
63
64
# File 'lib/ontomde-uml2-flex/ValueObjectAS.rb', line 59

def flex_writeVO_vars
	flex_ownedAttributeSet.each { |prop|
		tpl=JavaMapping.instance.getTemplate(prop.uml_type_one)
		tpl.flex_writeVO_vars_datatype(prop)
		}
end