ontomde-uml2-jpdl 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,114 @@
1
+
2
+ module Mrdf_Model
3
+
4
+ BPM_JPDL_DEPLOY_CLASS="xmda.jpdl.Deploy"
5
+
6
+ # Generates a JPDL deployer as a JUNIT class
7
+ # Junit provides easy diagnostic an a convenient GUI
8
+ def bpm_genJPDLDeploy
9
+ #TODO A enlever
10
+ return
11
+ mrdf=context[:umlModel,self]
12
+ muml=mrdf.umlx_reserved_model
13
+
14
+ deploy=muml.umlx_getOrCreateClass(BPM_JPDL_DEPLOY_CLASS)
15
+ return unless deploy.java_customCode.empty?
16
+
17
+ deploy.umlx_businessMethod=RDF_FALSE
18
+ deploy.apaCom_addLogger!
19
+ deploy.umlx_external=RDF_FALSE
20
+ deploy.java_import_add('org.junit.*')
21
+ deploy.java_import_add('java.io.PrintWriter');
22
+ deploy.java_import_add('java.io.StringWriter');
23
+
24
+ deploy.db_isTransient=RDF_TRUE
25
+ deploy.struts_isForm=RDF_FALSE
26
+
27
+
28
+ bpm_allProcess.each { |c|
29
+ op=deploy.umlx_createAndAddOperation("#{c.rdf_uri}_deploy","deploy_#{c.bpm_processName.to_s.tr('.','_')}")
30
+ op.java_annotation_add('@org.junit.Test')
31
+ op.umlx_businessMethod=RDF_FALSE
32
+ op.java_code=%{
33
+ #{c.bpm_javaProcessJobsClass_one.java_qualifiedName} c=new #{c.bpm_javaProcessJobsClass_one.java_qualifiedName}();
34
+ try {
35
+ c.deploy();
36
+ } catch (Exception e) {
37
+ StringWriter s=new StringWriter();
38
+ PrintWriter p = new PrintWriter(s);
39
+ e.printStackTrace(p);
40
+ org.junit.Assert.fail(e.toString()+"\\n\\n"+s.toString());
41
+ }
42
+ }
43
+ }
44
+ bpm_allProcess.each { |c|
45
+ op=deploy.umlx_createAndAddOperation("#{c.rdf_uri}_deploy}","ping_#{c.bpm_processName.to_s.tr('.','_')}")
46
+ op.java_annotation_add('@org.junit.Test')
47
+ op.umlx_businessMethod=RDF_FALSE
48
+ op.java_code=%{
49
+ #{c.bpm_javaProcessJobsClass_one.java_qualifiedName} c=new #{c.bpm_javaProcessJobsClass_one.java_qualifiedName}();
50
+ try {
51
+ c.start();
52
+ } catch (Exception e) {
53
+ StringWriter s=new StringWriter();
54
+ PrintWriter p = new PrintWriter(s);
55
+ e.printStackTrace(p);
56
+ org.junit.Assert.fail(e.toString()+"\\n\\n"+s.toString());
57
+ }
58
+ }
59
+ }
60
+
61
+
62
+ deploy.java_customCode= %{
63
+ /**
64
+ * @throws java.lang.Exception
65
+ */
66
+ @org.junit.BeforeClass
67
+ public static void setUpBeforeClass() throws Exception {
68
+ }
69
+ /**
70
+ * @throws java.lang.Exception
71
+ */
72
+ @org.junit.AfterClass
73
+ public static void tearDownAfterClass() throws Exception {
74
+ }
75
+ /**
76
+ * @throws java.lang.Exception
77
+ */
78
+ @org.junit.Before
79
+ public void setUp() throws Exception {
80
+ }
81
+ /**
82
+ * @throws java.lang.Exception
83
+ */
84
+ @org.junit.After
85
+ public void tearDown() throws Exception {
86
+ //TODO: cleanup db
87
+ }
88
+ public static junit.framework.Test suite(){
89
+ return new junit.framework.JUnit4TestAdapter(#{deploy.java_qualifiedName}.class);
90
+ }
91
+ @Test
92
+ public void check_database_connection() {
93
+ log.error("TODO: check db connection");
94
+ }
95
+ @Test
96
+ public void install_jbpm_schema() {
97
+ log.error("TODO: install jbpm schema");
98
+
99
+
100
+ //private JbpmConfiguration jbpmConfiguration = null;
101
+ //protected void deploy(String processDef) throws Exception {
102
+ // try {
103
+ // jbpmContext = jbpmConfiguration.createJbpmContext();
104
+ // jbpmContext.deployProcessDefinition(processDef);
105
+ // } finally {
106
+ // jbpmContext.close();
107
+ // }
108
+ //}
109
+
110
+
111
+ }
112
+ }
113
+ end
114
+ end
@@ -0,0 +1,311 @@
1
+ #:include: main.rdoc
2
+
3
+ require "rexml/document"
4
+
5
+ module Mrdf_Model
6
+ def java_getClassWithQualifiedName(qname)
7
+ uml_Class_all.each { |f|
8
+ return f if f.java_qualifiedName.to_s.casecmp(qname)==0
9
+ }
10
+ puts "not found #{qname}"
11
+ #exit 1
12
+ return nil
13
+ end
14
+ def bpm_loadBPM
15
+ loadMetaModelFromFile("#{File.dirname(__FILE__)}/bpm.rdfs",true)
16
+ end
17
+ def bpm_transform!
18
+ #mtk_writeSession("bpm.log") {
19
+ s=Array.new
20
+ each { |k,res|
21
+ next unless res.kind_of?(Mbpm_process)
22
+ s << res
23
+ }
24
+ s.each { |res|
25
+ res.bpm_transform!
26
+ }
27
+ #bpm_dumpJPDL
28
+ bpm_genJPDLDeploy
29
+ end
30
+
31
+ #adds ping node to all process in model
32
+ #(feature used for process deployement test)
33
+ def bpm_addPingNode!
34
+ bpm_allProcess.each { |c|
35
+ c.bpm_addPingNode!
36
+ }
37
+ end
38
+
39
+ def bpm_allProcess(ret=Array.new)
40
+ self.each { |k,c|
41
+ ret<< c if c.kind_of?(Mbpm_process)
42
+ }
43
+ return ret
44
+ end
45
+ end
46
+
47
+ module Muml_ClassProcess
48
+ #Surcharge pour les objets de type Process cette méthode
49
+ #afin de ne pas avoir l'id généré
50
+ def jpa_deriveFromPersistent?
51
+ return true;
52
+ end
53
+ end
54
+
55
+
56
+ module Mbpm_process
57
+ rdf_safe_attr_reader_many :bpm_javaProcessJobsClass
58
+
59
+ # returns a qualified name for this process
60
+ #(return processName itself because processName is supposed to be a qualifiedName)
61
+ def bpm_qualifiedName
62
+ return bpm_processName.to_s
63
+ end
64
+
65
+ def bpm_getProcessClass(muml)
66
+ bpmClass = BPM::BpmClass
67
+ bpmClass += "<#{self.bpm_processReturnTypeOrNullReturn}>"
68
+ ret=muml.umlx_getOrCreateClass(bpmClass)
69
+ ret.java_isGeneric=RDF_TRUE
70
+ #ret.db_isTransient=RDF_FALSE
71
+ ret.db_isTransient=RDF_FALSE
72
+ puts "ProcessClass = #{bpmClass}"
73
+ return ret
74
+ end
75
+
76
+ def bpm_transform!
77
+ mrdf=context[:umlModel,self.rdf_model]
78
+ muml=mrdf.umlx_reserved_model
79
+ j=mrdf.java_getClassWithQualifiedName(bpm_qualifiedName.to_s)
80
+ j=muml.umlx_getOrCreateClass("#{bpm_qualifiedName}",::Muml_Namespace::UMLX_SEARCH_EVERY_MODEL) if j.nil?
81
+ #TODO Gérer la récupération dans la signature de la méthode du type et la génération de deux méthodes
82
+ #Evite la génération de l'ID
83
+ j.extend(Muml_ClassProcess);
84
+ j.db_isTransient=RDF_FALSE
85
+ self.bpm_javaProcessJobsClass=j # store direct reference
86
+ j.umlx_external="false"
87
+
88
+ j.umlx_createAndAddGeneralization( bpm_getProcessClass(muml))
89
+
90
+
91
+ bpm_processNode.each {|n|
92
+ next if n.kind_of?(Mbpm_passive_Node)
93
+ if n.kind_of?(Mbpm_source_Node)
94
+ n.bpm_createEnumerationForTransitions!(j)
95
+ end
96
+ #n.bpm_createConnectorForNodeAction!
97
+ n.bpm_addJavaProcessOperation(j)
98
+ }
99
+
100
+ m=j.umlx_createAndAddOperation("#{j.rdf_uri}_processDefinition","getProcessDefinition")
101
+ m.java_annotation_add("@Override")
102
+ p=m.umlx_createAndAddReturnParameter("#{j.rdf_uri}_ret","return")
103
+ p.uml_type=j.umlx_dataType_string
104
+ m.java_code=%{return ""\n#{mtk_stss{bpm_writeJPDL}.gsub(/"/,'\\"').gsub(/^(.*)$/,' +"\1"')};}
105
+
106
+ # external process name
107
+ m=j.umlx_createAndAddOperation("#{j.rdf_uri}_externalProcessName","getExternalProcessName")
108
+ p=m.umlx_createAndAddReturnParameter("#{j.rdf_uri}_ret","return")
109
+ p.uml_type=j.umlx_dataType_string
110
+ m.java_code=%{return "#{bpm_qualifiedName}";}
111
+
112
+
113
+ me=j.umlx_createAndAddOperation("#{j.rdf_uri}_onEnd","xmdaOnEnd")
114
+ me.java_annotation_add("@Override")
115
+ p=me.umlx_createAndAddReturnParameter("#{me.rdf_uri}_ret","return")
116
+
117
+ p.uml_type=j.umlx_getOrCreateClass("#{bpm_processReturnTypeOrNullReturn}")
118
+ me.java_code=%{return null;}
119
+
120
+ # p.uml_type=j.umlx_getOrCreateClass("java.lang.Class")
121
+
122
+ # external process id
123
+ # moved to base class
124
+ #p=j.umlx_createAndAddProperty("#{j.rdf_uri}_externalBPMid","BpmExternalId")
125
+ #m.uml_type=j.umlx_dataType_long
126
+
127
+ end
128
+
129
+ #pingTest node is a node added to
130
+ #ping the process for testing purposses
131
+ #and deployement test purposes
132
+ def bpm_addPingNode!
133
+ return unless context[:bpm_addPingNode,true]
134
+ s=bpm_getOrCreateStartNode
135
+ e=bpm_getOrCreateEndNode
136
+ d=bpm_createAndAddSynchronousDecisionNode("_pingMode")
137
+ t=s.bpm_leavingTransition_one
138
+
139
+ #insert node d between s and first node after s
140
+ d.bpm_addTransition!("productionMode",t.bpm_destinationNode_one)
141
+ d.bpm_addTransition!("testMode",e)
142
+ t.bpm_destinationNode=d
143
+ end
144
+
145
+ #create
146
+ def bpm_createAndAddSynchronousDecisionNode(name)
147
+ ret=Cbpm_synchronousDecisionNode.new(self.rdf_model,"#{self.rdf_uri}_#{name}")
148
+ ret.bpm_nodeName=name
149
+ self.bpm_processNode_add(ret)
150
+ return ret
151
+ end
152
+
153
+ #returns process start node
154
+ #creates one if necessary
155
+ def bpm_getOrCreateStartNode
156
+ bpm_processNode.each {|n|
157
+ return n if n.kind_of?(Mbpm_startNode)
158
+ }
159
+ ret=Cbpm_startNode.new(self.rdf_model,"#{self.rdf_uri}_startNode")
160
+ ret.bpm_nodeName="startNode"
161
+ self.bpm_processNode_add(ret)
162
+ return ret
163
+ end
164
+ #returns process start node
165
+ #creates one if necessary
166
+ def bpm_getOrCreateEndNode
167
+ bpm_processNode.each {|n|
168
+ return n if n.kind_of?(Mbpm_endNode)
169
+ }
170
+ ret=Cbpm_startNode.new(self.rdf_model,"#{self.rdf_uri}_endNode")
171
+ ret.bpm_nodeName="endNode"
172
+ self.bpm_processNode_add(ret)
173
+ return ret
174
+ end
175
+
176
+ def bpm_graphGen_dot
177
+ mtk_writeSession("bpm.dot") {
178
+ write("digraph {\n")
179
+ bpm_processNode.each {|n|
180
+ n.bpm_graphGen_dot
181
+ }
182
+ write ("} // end of file\n")
183
+ }
184
+ end
185
+ end
186
+ module Mbpm_named_Node
187
+ # returns a qualified name for this node
188
+ def bpm_qualifiedName
189
+ return "#{bpm_processNode_inv_one.bpm_qualifiedName}.#{bpm_nodeName}"
190
+ end
191
+
192
+ def hasMultipleTransitions?
193
+ return false
194
+ end
195
+
196
+ #adds a method in java process for this node
197
+ def bpm_addJavaProcessOperation(j)
198
+ o=nil
199
+ j.uml_ownedOperation.each { |op|
200
+ o=op if op.java_Name.to_s.casecmp(op.java_safeName(self.bpm_nodeName.to_s))==0
201
+ }
202
+ o=j.umlx_createAndAddOperation(self.rdf_uri+"meth",self.bpm_nodeName) if o.nil?
203
+ o.uml_name=self.bpm_nodeName #case fix
204
+ if self.kind_of?(Mbpm_source_Node) && hasMultipleTransitions?
205
+ r=o.umlx_createAndAddReturnParameter(o.rdf_uri+"_return")
206
+ r.uml_type=self.bpm_javaTransitionNameEnum_one
207
+ o.java_code=<<END
208
+ //TODO: replace this test code by real implementation
209
+ log.debug("test method called #{o.uml_name}");
210
+ return #{self.bpm_javaTransitionNameEnum_one.java_qualifiedName}.values()[0];
211
+ END
212
+ else
213
+ o.java_code=<<END
214
+ //TODO: replace this test code by real implementation
215
+ log.debug("test method called #{o.uml_name}");
216
+ END
217
+ end
218
+ if self.kind_of?(Mbpm_asynchronousNode)
219
+ #Ajout du paramètre callback
220
+ p=o.umlx_createAndAddParameter(o.rdf_uri+"_param", "_callback")
221
+ mrdf=context[:umlModel,self.rdf_model]
222
+ muml=mrdf.umlx_reserved_model
223
+ i=muml.umlx_getOrCreateInterface(BPM::CallbackClass)
224
+ i.umlx_external="true"
225
+ p.uml_type=i
226
+ end
227
+ end
228
+ end
229
+
230
+ module Mbpm_source_Node
231
+ rdf_safe_attr_reader_many :bpm_javaTransitionNameEnum
232
+
233
+ #Indique si ce noeud a plusieurs sorties et donc si on génère un Enum pour son type de retour
234
+ def hasMultipleTransitions?
235
+ return false if bpm_leavingTransition.nil?
236
+ nb = 0
237
+ bpm_leavingTransition.each { |transition|
238
+ nb += 1 if !transition.kind_of?(Mbpm_timeOutTransition)
239
+ }
240
+ return nb > 1
241
+ end
242
+
243
+ # creates an uml enumeration listing
244
+ # every node leaving this transition
245
+ # This is usefull for decision node.
246
+ def bpm_createEnumerationForTransitions!(processClass)
247
+ mrdf=context[:umlModel,self.rdf_model]
248
+ muml=mrdf.umlx_reserved_model
249
+ p=processClass.umlx_owner_one
250
+ return if !hasMultipleTransitions?
251
+
252
+ p=p.umlx_getOrCreatePackage(p.context[:bpm_javaSubPackage],p)
253
+ p=p.umlx_getOrCreatePackage(processClass.uml_name.to_s)
254
+
255
+ i=p.umlx_getOrCreateEnumeration("#{bpm_nodeName}_BpmTransitions",p)
256
+ i.umlx_external="false"
257
+ self.bpm_javaTransitionNameEnum=i
258
+ bpm_leavingTransition.each { |t|
259
+ i.umlx_createAndAddLiteral(t.bpm_transitionName.to_s)
260
+ }
261
+ end
262
+ end
263
+ module Mbpm_decision_Node
264
+ def not_used_bpm_createConnectorForNodeAction!
265
+ mrdf=context[:umlModel,self.rdf_model]
266
+ #muml=mrdf.umlx_reserved_model
267
+ j=muml.umlx_getOrCreateClass("#{bpm_qualifiedName} Connector")
268
+ j.umlx_external="false"
269
+
270
+
271
+ m=j.umlx_createAndAddOperation("#{self.rdf_uri}_connectorMethod","execute")
272
+ i=muml.umlx_getOrCreateInterface("jpdl.anInterface_tbd")
273
+ i.umlx_external="true"
274
+ j.umlx_createAndAddImplementation(i)
275
+
276
+ end
277
+ end
278
+ module Mbpm_node
279
+ def bpm_graphGen_dot
280
+ return # todo
281
+ write %{#{self.dotId} [#{bpm_dotStyle}]\n}
282
+ bpm_leavingTransition.each { |t|
283
+ e=t.bpm_enteringTransition_inv_one
284
+ write %{#{self.dotId} -> #{e.dotId} \n}
285
+ } if kind_of?(Mbpm_source_Node)
286
+
287
+ end
288
+
289
+ end
290
+
291
+
292
+ module Mbpm_startNode
293
+ def bpm_nodeName
294
+ return "start"
295
+ end
296
+ end
297
+
298
+ module Mbpm_endNode
299
+ def bpm_nodeName
300
+ return "end"
301
+ end
302
+ end
303
+
304
+ module Mbpm_source_Node
305
+ def bpm_addTransition!(transitionName,targetNode)
306
+ t=Cbpm_transition.new(self.rdf_model,"#{self.rdf_uri}_#{transitionName}")
307
+ self.bpm_leavingTransition_add(t)
308
+ t.bpm_destinationNode=targetNode
309
+ t.bpm_transitionName=transitionName
310
+ end
311
+ end
@@ -0,0 +1,2 @@
1
+
2
+ TODO: documentation
@@ -0,0 +1,316 @@
1
+
2
+
3
+ #module Muml_Classifier
4
+ # STRUTS_APPLY_TO_PARAM="applyTo"
5
+ # STRUTS_APPLY_TO_PROP="ApplyTo"
6
+ #end
7
+
8
+ module Muml_Operation
9
+ rdf_safe_attr_reader_many :bpm_bizOperationReverse
10
+ end
11
+
12
+ module Muml_Parameter
13
+ #the method parameter
14
+ rdf_safe_attr_reader_many :bpm_sourceParameter
15
+ end
16
+
17
+
18
+ module Mrdf_Model
19
+ def bpm_handleProcessMethods!
20
+ #return unless context[:withGenerateMethodForm]
21
+ uml_Class_all.each { |c|
22
+ next unless c.kind_of?(Muml_Class)
23
+ c.uml_ownedOperation.each {|biz|
24
+ next unless biz.kind_of?(Muml_Operation)
25
+ #next unless biz.umlx_businessMethod?
26
+
27
+ next if biz.umlx_isConstructor?
28
+ bpm_processMethods(c, biz) if biz.umlx_hasStereotype?("Process")
29
+ c.bpm_asyncMethods(biz) if biz.umlx_hasStereotype?("Async")
30
+ c.bpm_callbackMethods(biz) if biz.umlx_hasStereotype?("Callback")
31
+ }}
32
+ end
33
+
34
+
35
+ def bpm_processMethods(c, biz)
36
+
37
+ p=c.umlx_package
38
+ if p.nil?
39
+ log.error{"Model modification required !!! class #{c} is in root model element. Classes should be in a package."}
40
+ next
41
+ end
42
+ #Type de retour dans le mod�le
43
+ initialReturnParam = biz.uml_getReturnParameter
44
+ mpc=java_getClassWithQualifiedName("#{c.umlx_owner_one.java_qualifiedName}.#{biz.java_Name}")
45
+ mpc=p.umlx_createAndAddClass(biz.rdf_uri+"_proc") if mpc.nil?
46
+ mpc.umlx_businessMethod=RDF_TRUE
47
+ mpc.bpm_addAllOperationAggregateParameterClass!(biz)
48
+ code=%{ #{mpc.java_qualifiedName} proc=new #{mpc.java_qualifiedName}();}
49
+ biz.uml_ownedParameter.each { |param|
50
+ code=code+"proc.set#{param.java_NameBean}(#{param.java_Name});\n"
51
+ }
52
+
53
+ #Set the right Return Type on the Process
54
+ #If already specified in the Process definition, not overhide
55
+ #find the corresponding process
56
+ self.each { |k,p|
57
+ next if !p.kind_of?(Mbpm_process)
58
+ if "#{p.bpm_processName}" == "#{mpc.java_qualifiedName}"
59
+ # bpm_processReturnType is a string
60
+ p.bpm_processReturnType = initialReturnParam.uml_type.to_s if !initialReturnParam.nil? && p.bpm_processReturnType_one0.nil?
61
+ break
62
+ end
63
+ }
64
+
65
+ #If return set handler
66
+ code_getCallBackMethod = ""
67
+ if !initialReturnParam.nil?
68
+ c.bpm_manageAsynchronousMethods(biz)
69
+ code_getCallBackMethod = "handler"
70
+ end
71
+
72
+
73
+ #Modifiy the code of the method to manage the asynchronous
74
+ code=code+"proc.persist();proc.startAsynchronously(#{code_getCallBackMethod});\n"
75
+ biz.java_code=code
76
+
77
+ #Ajoute un champ calcul� pour la visualization de la console
78
+ console=mpc.umlx_createAndAddProperty(mpc.rdf_uri+"_console","console")
79
+ console.uml_isDerived=RDF_TRUE
80
+ console.uml_type=mpc.umlx_getOrCreateDataType("URL")
81
+ mpc.java_addAccessorsFor!(console)
82
+ getter = console.java_AttributeGlobalGetter
83
+ getter[0].java_code = <<END_OF_STRING
84
+ if (this.getProcessId() != null) {
85
+ return "/ontomde-bpm-console/processimage?id=" + this.getProcessId();
86
+ } else {
87
+ return "#";
88
+ }
89
+ END_OF_STRING
90
+
91
+
92
+ # biz.uml_appliedStereotype.each {|s|
93
+ # #TODO: utiliser processImpl
94
+ # puts "add stereotype #{s} to #{mpc}::#{mpc.class}"
95
+ # mpc.uml_appliedStereotype_add(s)
96
+ # }
97
+
98
+ end
99
+
100
+
101
+ end
102
+
103
+ module Muml_Class
104
+
105
+ alias super_jpa_addStdImports! jpa_addStdImports!
106
+ def jpa_addStdImports!
107
+ super_jpa_addStdImports!
108
+
109
+ java_import_add("xmda.bpm.api.XmdaCallbackHandler")
110
+ java_import_add("xmda.bpm.api.client.EntityInstanceDescription")
111
+ java_import_add("xmda.bpm.api.client.EntityTaskDescription")
112
+ java_import_add("xmda.bpm.api.client.EntityTaskWithoutCallbackDescription")
113
+ java_import_add("xmda.bpm.api.jms.JmsCallbackHandler")
114
+ java_import_add(::DB::EntityGenericInterface)
115
+
116
+ end
117
+
118
+ #Ajoute une m�thode utilitaire pour r�cup�rer un handler correspondant � la m�thode
119
+ def bpm_callbackMethods(biz)
120
+ c=self
121
+ p=c.umlx_package
122
+ if p.nil?
123
+ log.error{"Model modification required !!! class #{c} is in root model element. Classes should be in a package."}
124
+ next
125
+ end
126
+ biz.java_annotation_add(%{@xmda.common.Callback})
127
+ type_callback=biz.bpm_callbackType
128
+
129
+ m=c.umlx_createAndAddOperation(biz.rdf_uri+"_handler","getOntomdeHandlerFor#{biz.uml_name}")#+self.java_NameBean)
130
+ m.uml_isStatic=RDF_TRUE
131
+ #m.uml_class=self
132
+ m.uml_visibility=Cuml_VisibilityKind::Public
133
+ #m.uml_isStatic=RDF_TRUE
134
+
135
+ param=m.umlx_createAndAddParameter(m.rdf_uri+"_this","_this")
136
+ i=c.umlx_getOrCreateInterface(DB::EntityInterface)
137
+ i.java_isGeneric=RDF_TRUE
138
+ param.uml_type=i
139
+ param.uml_direction=Cuml_ParameterDirectionKind::In
140
+ param.uml_upperValue=umlx_literal(1)
141
+ param.uml_lowerValue=umlx_literal(1)
142
+
143
+ rp=m.umlx_createAndAddParameter(m.rdf_uri+"_ret_param","return")
144
+ rp.uml_direction=Cuml_ParameterDirectionKind::Return
145
+ rp.uml_upperValue=umlx_literal(1)
146
+ rp.uml_lowerValue=umlx_literal(1)
147
+ i=c.umlx_getOrCreateInterface("xmda.bpm.api.XmdaCallbackHandler<#{type_callback}>")
148
+ i.java_isGeneric=RDF_TRUE
149
+ rp.uml_type=i
150
+ rp.uml_isOrdered=RDF_TRUE
151
+
152
+ m.java_annotation_add(%{@SuppressWarnings("unchecked")})
153
+
154
+ m.java_code=<<END_OF_STRING
155
+ return JmsCallbackHandler.Factory.createCallbackHandler(xmda.bpm.async.AsyncUtils.createAsyncTaskDescription(_this,"#{biz.uml_name}", new String[] {#{type_callback}.class.getName()}));
156
+ END_OF_STRING
157
+
158
+ end
159
+
160
+ def bpm_manageAsynchronousMethods(biz, not_delete_param=false)
161
+ returnParam = nil
162
+ biz.uml_returnResult.each { |p|
163
+ #pour RSM (non conformite de l'export)
164
+ next unless p.uml_direction_one.isReturn?
165
+ returnParam=p
166
+ biz.uml_returnResult.delete(p) if !not_delete_param
167
+ }
168
+ biz.uml_ownedParameter.each { |p|
169
+ next unless p.uml_direction_one.isReturn?
170
+ returnParam=p
171
+ biz.uml_ownedParameter.delete(p) if !not_delete_param
172
+ }
173
+ return if returnParam.nil?
174
+
175
+ downcaseName=biz.uml_name_one0
176
+ if downcaseName[0..0].downcase!=downcaseName[0..0]
177
+ downcaseName="#{downcaseName[0..0].downcase}#{downcaseName[1,downcaseName.length]}"
178
+ end
179
+
180
+ param=biz.umlx_createAndAddParameter(biz.rdf_uri+"_handler_param","handler")
181
+ i=self.umlx_getOrCreateInterface("xmda.bpm.api.XmdaCallbackHandler<#{returnParam.uml_type}>")
182
+ i.java_isGeneric=RDF_TRUE
183
+ param.uml_type=i
184
+ param.uml_direction=Cuml_ParameterDirectionKind::In
185
+ end
186
+
187
+
188
+ def bpm_asyncMethods(biz)
189
+ biz.java_annotation_add(%{@xmda.bpm.async.Async})
190
+ bpm_manageAsynchronousMethods(biz, true)
191
+ end
192
+
193
+ end
194
+
195
+ module Muml_Operation
196
+
197
+ def uml_getReturnParameter
198
+ fp=nil
199
+ uml_returnResult.each { |p|
200
+ #pour RSM (non conformite de l'export)
201
+ next unless p.uml_direction_one.isReturn?
202
+ fp=p
203
+ }
204
+ uml_ownedParameter.each { |p|
205
+ next unless p.uml_direction_one.isReturn?
206
+ fp=p
207
+ }
208
+ return fp
209
+ end
210
+
211
+ def bpm_returnType
212
+ fp = uml_getReturnParameter
213
+ if !fp
214
+ return "#{BPM::NullReturn}"
215
+ else
216
+ return "#{fp.uml_type}"
217
+ end
218
+ end
219
+
220
+ def bpm_callbackType
221
+ fp=nil
222
+ uml_ownedParameter.each { |p|
223
+ next if p.uml_direction_one.isReturn?
224
+ if !fp.nil?
225
+ log.error("Method #{self.uml_name} : Should not define Callback method with multiple parameters")
226
+ raise Warning.new(),"Method #{self.uml_name} : Should not define Callback method with multiple parameters"
227
+ else
228
+ fp=p
229
+ end
230
+
231
+ }
232
+ if !fp
233
+ return "#{BPM::NullReturn}"
234
+ else
235
+ return "#{fp.uml_type}"
236
+ end
237
+ end
238
+
239
+ end
240
+
241
+
242
+ module Muml_Classifier
243
+
244
+ rdf_safe_attr_reader_many :bpm_bizOperation
245
+ #
246
+ #Creates a class for every business method holding every parameters
247
+ #and
248
+ #
249
+ #
250
+
251
+ #STRUTS_RESULT_PARAM_NAME="_result"
252
+
253
+ def bpm_addAllOperationAggregateParameterClass!(biz)
254
+ mpc=self
255
+ mpc.bpm_bizOperation=biz
256
+ biz.bpm_bizOperationReverse_add(mpc)
257
+ #biz.bpm_bizForm=mpc
258
+ #mpc.uml_name="#{biz.umlx_owner_one.java_Name}#{biz.java_Name}PROC"
259
+ #method process is expected to be unique
260
+ #in namespace
261
+ mpc.uml_name="#{biz.java_Name.to_s}"
262
+
263
+ (biz.uml_ownedParameter+biz.uml_returnResult).each { |param|
264
+ next if param.uml_direction_one.isReturn?
265
+ mpcp=mpc.umlx_createAndAddProperty(param.rdf_uri+"_proc")
266
+ param.umlx_copyToAttributeProperty(mpcp)
267
+ mpcp.uml_name= param.uml_direction_one.isReturn? ? STRUTS_RESULT_PARAM_NAME : param.uml_name
268
+ }
269
+ mpc.bpm_addApplyToParameter!(biz)
270
+ mpc.bpm_addProceed!(biz)
271
+ #mpc.apaCom_addLogger!
272
+ end
273
+
274
+ def bpm_addApplyToParameter!(biz)
275
+ return
276
+ mpc=self
277
+ m,m1,m2=mpc.umlx_createAndAddAssociation(mpc.rdf_uri+"_apply",biz.umlx_owner_one)
278
+ m1.uml_name=STRUTS_APPLY_TO_PARAM
279
+ m2.uml_name="#{STRUTS_APPLY_TO_PARAM}_inv"
280
+ end
281
+
282
+ def bpm_addProceed!(biz)
283
+ return
284
+ mpc=self
285
+ cpt=mpc.umlx_createAndAddOperation(mpc.rdf_uri+"_proceed","proceed")
286
+ params=""; sep=""
287
+ hasRP=false
288
+ (biz.uml_ownedParameter+biz.uml_returnResult).each { |param|
289
+ if param.uml_direction_one.isReturn?
290
+ hasRP=true
291
+ next
292
+ end
293
+ params="#{params}#{sep}#{param.java_Name}"
294
+ sep=","
295
+ }
296
+ if(biz.uml_raisedException.empty?)
297
+ cpt.java_code=%{
298
+ #{hasRP ? "#{STRUTS_RESULT_PARAM_NAME}=" : ""} #{STRUTS_APPLY_TO_PARAM}.#{biz.java_Name}(#{params});
299
+ }
300
+ else
301
+ cpt.java_code=%{
302
+ try {
303
+ //log.error("before biz method");
304
+ //log.error("applyTo="+#{STRUTS_APPLY_TO_PARAM});
305
+ #{hasRP ? "#{STRUTS_RESULT_PARAM_NAME}=" : ""} #{STRUTS_APPLY_TO_PARAM}.#{biz.java_Name}(#{params});
306
+ //log.error("after biz method");
307
+ //log.error("result="+#{hasRP ? STRUTS_RESULT_PARAM_NAME : %{"-none-"}});
308
+ } catch(Exception e) {
309
+ //TODO: implement proper exception handling
310
+ throw new java.lang.RuntimeException(e);
311
+ }
312
+ }
313
+ end
314
+
315
+ end
316
+ end