ontomde-uml2-struts 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.
- data/History.txt +5 -0
- data/Manifest.txt +31 -0
- data/README.txt +38 -0
- data/Rakefile +32 -0
- data/lib/ontomde-uml2-struts/MessageResources.rb +356 -0
- data/lib/ontomde-uml2-struts/action.rb +886 -0
- data/lib/ontomde-uml2-struts/blob.rb +11 -0
- data/lib/ontomde-uml2-struts/exceptionHandling.rb +167 -0
- data/lib/ontomde-uml2-struts/footer.rb +128 -0
- data/lib/ontomde-uml2-struts/form.rb +483 -0
- data/lib/ontomde-uml2-struts/header.rb +37 -0
- data/lib/ontomde-uml2-struts/header_link.rb +39 -0
- data/lib/ontomde-uml2-struts/jsp_edit.rb +866 -0
- data/lib/ontomde-uml2-struts/jsp_edit_field.rb +1 -0
- data/lib/ontomde-uml2-struts/jsp_edit_js.rb +124 -0
- data/lib/ontomde-uml2-struts/jsp_index.rb +131 -0
- data/lib/ontomde-uml2-struts/localeAction.rb +641 -0
- data/lib/ontomde-uml2-struts/main.rb +140 -0
- data/lib/ontomde-uml2-struts/mappingForBean.rb +132 -0
- data/lib/ontomde-uml2-struts/mappingForJsp.rb +272 -0
- data/lib/ontomde-uml2-struts/mappingToJavaHierarchy.rb +87 -0
- data/lib/ontomde-uml2-struts/reloadAction.rb +33 -0
- data/lib/ontomde-uml2-struts/spring.rb +89 -0
- data/lib/ontomde-uml2-struts/struts-config.rb +232 -0
- data/lib/ontomde-uml2-struts/validation.rb +116 -0
- data/lib/ontomde-uml2-struts/validator.rb +341 -0
- data/lib/ontomde-uml2-struts/version.rb +7 -0
- data/lib/ontomde-uml2-struts/webXml.rb +165 -0
- data/lib/ontomde-uml2-struts/xmlForm.rb +308 -0
- data/lib/ontomde-uml2-struts.rb +34 -0
- data/test/test_ontomde-uml2-struts.rb +0 -0
- metadata +112 -0
@@ -0,0 +1,886 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
module Muml_Classifier
|
5
|
+
STRUTS_NEW_ACTION="newa"
|
6
|
+
STRUTS_CREATE_ACTION="sgbd_create"
|
7
|
+
STRUTS_UPDATE_ACTION="sgbd_update"
|
8
|
+
STRUTS_READ_ACTION="sgbd_read"
|
9
|
+
STRUTS_DELETE_ACTION="sgbd_delete"
|
10
|
+
STRUTS_PROCEED_ACTION="biz_proceed"
|
11
|
+
STRUTS_INPUT_FWD="inputfw"
|
12
|
+
STRUTS_RESULTS_FWD="retour" #TODO
|
13
|
+
|
14
|
+
#terminate local treatment and return control to calling controller.
|
15
|
+
STRUTS_RETURN_ACTION="returnTo"
|
16
|
+
#Resume local treatment avect geting control back from another controler.
|
17
|
+
STRUTS_RESUME_ACTION="resume"
|
18
|
+
|
19
|
+
STRUTS_REFRESH_ACTION="executeRefresh"
|
20
|
+
STRUTS_SGBD_STATE="sgbd_state"
|
21
|
+
STRUTS_SGBD_STATE_PROP="Sgbd_state"
|
22
|
+
#STRUTS_RETURN_TO_FIELD="jsp_return_to"
|
23
|
+
#STRUTS_RETURN_TO_PROP="Jsp_return_to"
|
24
|
+
|
25
|
+
STRUTS_ACTION_MAPPING="org.apache.struts.action.ActionMapping"
|
26
|
+
STRUTS_ACTION_FORWARD="org.apache.struts.action.ActionForward"
|
27
|
+
|
28
|
+
STRUTS_ACTION_STARTEDIT="startEditAction"
|
29
|
+
|
30
|
+
#class from which this StrutsAction was generated.
|
31
|
+
rdf_safe_attr_reader_many :struts_actionSrc
|
32
|
+
|
33
|
+
#Creates an add a struts "execute" method of an action bean
|
34
|
+
#Names needs not be "execute" thanks to struts dispatch feature.
|
35
|
+
def struts_createAndAddExecuteOperation(name)
|
36
|
+
action=self
|
37
|
+
afo=action.umlx_createAndAddOperation(action.rdf_uri+"_"+name,name)
|
38
|
+
p=afo.umlx_createAndAddParameter(afo.rdf_uri+"_to","mapping")
|
39
|
+
p.uml_type=umlx_getOrCreateClass(STRUTS_ACTION_MAPPING)
|
40
|
+
p=afo.umlx_createAndAddParameter(afo.rdf_uri+"_form","abstractForm")
|
41
|
+
p.uml_type=umlx_getOrCreateClass("org.apache.struts.action.ActionForm")
|
42
|
+
|
43
|
+
p=afo.umlx_createAndAddParameter(afo.rdf_uri+"_request","request")
|
44
|
+
p.uml_type=umlx_getOrCreateClass("javax.servlet.http.HttpServletRequest")
|
45
|
+
|
46
|
+
p=afo.umlx_createAndAddParameter(afo.rdf_uri+"_response","response")
|
47
|
+
p.uml_type=umlx_getOrCreateClass("javax.servlet.http.HttpServletResponse")
|
48
|
+
p=afo.umlx_createAndAddReturnParameter(afo.rdf_uri+"_return","return")
|
49
|
+
p.uml_type=umlx_getOrCreateClass("org.apache.struts.action.ActionForward")
|
50
|
+
|
51
|
+
return afo
|
52
|
+
end
|
53
|
+
|
54
|
+
#Return java code to be included at the begining of every action execute method.
|
55
|
+
#Example:
|
56
|
+
# EffectiveFormType form=<EffectiveFormType> abstractForm;
|
57
|
+
def struts_formCastJavaCode(action=nil)
|
58
|
+
action=struts_actionForm_one if action.nil?
|
59
|
+
return <<ENDMETH
|
60
|
+
#{action.java_qualifiedName} form=(#{action.java_qualifiedName})abstractForm;
|
61
|
+
form.set#{STRUTS_DISPATCH_FIELD_METH}("");
|
62
|
+
ENDMETH
|
63
|
+
end
|
64
|
+
|
65
|
+
#Struts Action associated to this class
|
66
|
+
rdf_safe_attr_reader_many :struts_action
|
67
|
+
def struts_addAction!
|
68
|
+
#log.debug { "struts_addAction! #{self}::#{self.class.name}" }
|
69
|
+
if struts_bizOperation.empty?
|
70
|
+
struts_addActionCRUD!
|
71
|
+
else
|
72
|
+
struts_addActionBiz!
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def struts_addActionBiz!
|
77
|
+
action=struts_createAndAddActionBase!
|
78
|
+
struts_addStartEditAction!(action)
|
79
|
+
|
80
|
+
struts_addsetTimeZoneAction!(action)
|
81
|
+
struts_addsetSkinAction!(action)
|
82
|
+
struts_addsetLocaleAction!(action)
|
83
|
+
struts_addRefreshAction!(action)
|
84
|
+
struts_addNewBizAction!(action)
|
85
|
+
struts_addProceedBizAction!(action)
|
86
|
+
struts_addTabsBiz!(action)
|
87
|
+
struts_addSwitchToFlexAction!(action)
|
88
|
+
|
89
|
+
struts_addReturnAction!(action)
|
90
|
+
#struts_addProceedAction!(action)
|
91
|
+
struts_addResumeAction!(action)
|
92
|
+
#struts_addNewAction!(action)
|
93
|
+
#struts_addCreateAction!(action)
|
94
|
+
struts_addReadAction!(action)
|
95
|
+
#struts_addUpdateAction!(action)
|
96
|
+
#struts_addDeleteAction!(action)
|
97
|
+
#struts_addBusinessMethods!(action)
|
98
|
+
struts_addCreateAndAddActions!(action)
|
99
|
+
struts_addRemoveAndDeleteActions!(action)
|
100
|
+
|
101
|
+
struts_addFieldMethods!(action)
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
def struts_addNewBizAction!(action)
|
106
|
+
create=action.struts_createAndAddExecuteOperation(STRUTS_NEW_ACTION)
|
107
|
+
create.java_code=<<ENDMETH
|
108
|
+
#{struts_formCastJavaCode}
|
109
|
+
/* TPL: ACTION-001 */
|
110
|
+
form.setReference(new #{java_qualifiedName}());
|
111
|
+
form.initFromReference();
|
112
|
+
form.set#{STRUTS_DISPATCH_FIELD_METH}("#{STRUTS_CREATE_ACTION}");
|
113
|
+
return mapping.findForward("#{STRUTS_INPUT_FWD}");
|
114
|
+
ENDMETH
|
115
|
+
end
|
116
|
+
|
117
|
+
def struts_addProceedBizAction!(action)
|
118
|
+
proceed=action.struts_createAndAddExecuteOperation(STRUTS_PROCEED_ACTION)
|
119
|
+
proceed.java_code=<<ENDMETH
|
120
|
+
#{struts_formCastJavaCode}
|
121
|
+
form.copyToReference();
|
122
|
+
form.getReference().proceed();
|
123
|
+
form.initFromReference();
|
124
|
+
form.set#{STRUTS_DISPATCH_FIELD_METH}("#{STRUTS_CREATE_ACTION}");
|
125
|
+
return new org.apache.struts.action.ActionForward("/pages/#{java_InternalFilePath}form/#{java_Name}#{STRUTS_RESULTS_FWD}.jsp",false);
|
126
|
+
ENDMETH
|
127
|
+
end
|
128
|
+
|
129
|
+
STRUTS_SESSION_KEY_EditAction="objToEdit"
|
130
|
+
|
131
|
+
def struts_addStartEditAction!(action)
|
132
|
+
edit=action.struts_createAndAddExecuteOperation(STRUTS_ACTION_STARTEDIT)
|
133
|
+
edit.java_code= <<ENDCODE
|
134
|
+
#{struts_formCastJavaCode}
|
135
|
+
javax.servlet.http.HttpSession session=request.getSession();
|
136
|
+
#{self.java_qualifiedName} obj=(#{self.java_qualifiedName}) session.getAttribute("#{STRUTS_SESSION_KEY_EditAction}");
|
137
|
+
session.removeAttribute("#{STRUTS_SESSION_KEY_EditAction}");
|
138
|
+
form.setReference(obj);
|
139
|
+
form.initFromReference();
|
140
|
+
form.setSgbd_state("#{STRUTS_UPDATE_ACTION}");
|
141
|
+
return mapping.findForward("#{STRUTS_INPUT_FWD}");
|
142
|
+
ENDCODE
|
143
|
+
end
|
144
|
+
|
145
|
+
def struts_createAndAddActionBase!
|
146
|
+
p=umlx_owner_one
|
147
|
+
p=p.umlx_getOrCreatePackage(context[:strutsActionPackage,context[:strutsActionFormPackage,"struts"]],p)
|
148
|
+
action=p.umlx_createAndAddClass(rdf_uri+"_Action")
|
149
|
+
action.db_isTransient=RDF_TRUE
|
150
|
+
|
151
|
+
action.struts_actionSrc=self
|
152
|
+
self.struts_action=action
|
153
|
+
action.uml_name="#{uml_name}StrutsAction"
|
154
|
+
#af=action.umlx_getOrCreateClass("org.apache.struts.action.Action")
|
155
|
+
af=action.umlx_getOrCreateClass("org.apache.struts.actions.DispatchAction")
|
156
|
+
action.umlx_createAndAddGeneralization(af)
|
157
|
+
|
158
|
+
action.apaCom_addLogger!
|
159
|
+
|
160
|
+
#all=action.umlx_createAndAddProperty("#{action.rdf_uri}FORWARD","FORWARD");
|
161
|
+
#mtk_context(:struts_tab=> struts_defaultTabId ){
|
162
|
+
# all.java_code=%{"/#{struts_jsp_edit_path}"}
|
163
|
+
# }
|
164
|
+
# all.uml_isStatic=RDF_TRUE;
|
165
|
+
# all.uml_type=uml_type=umlx_dataType_string
|
166
|
+
|
167
|
+
return action
|
168
|
+
end
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
def struts_addActionCRUD!
|
173
|
+
action=struts_createAndAddActionBase!
|
174
|
+
|
175
|
+
struts_addStartEditAction!(action)
|
176
|
+
struts_addsetTimeZoneAction!(action)
|
177
|
+
struts_addsetSkinAction!(action)
|
178
|
+
struts_addsetLocaleAction!(action)
|
179
|
+
struts_addReturnAction!(action)
|
180
|
+
struts_addProceedAction!(action)
|
181
|
+
struts_addResumeAction!(action)
|
182
|
+
struts_addRefreshAction!(action)
|
183
|
+
struts_addNewAction!(action)
|
184
|
+
struts_addCreateAction!(action)
|
185
|
+
struts_addReadAction!(action)
|
186
|
+
struts_addUpdateAction!(action)
|
187
|
+
struts_addDeleteAction!(action)
|
188
|
+
|
189
|
+
struts_addCreateAndAddActions!(action)
|
190
|
+
struts_addRemoveAndDeleteActions!(action)
|
191
|
+
struts_addTabs!(action)
|
192
|
+
struts_addSwitchToFlexAction!(action)
|
193
|
+
|
194
|
+
struts_addFieldMethods!(action)
|
195
|
+
|
196
|
+
return if db_isTransient?
|
197
|
+
struts_addBusinessMethods!(action)
|
198
|
+
end
|
199
|
+
def struts_addTabs!(action)
|
200
|
+
struts_addTabFromInterface!(action)
|
201
|
+
struts_addTabAll!(action)
|
202
|
+
end
|
203
|
+
def struts_addTabsBiz!(action)
|
204
|
+
struts_addTabFromInterface!(action)
|
205
|
+
struts_addTabAll!(action)
|
206
|
+
struts_addTabReturnParameter!(action)
|
207
|
+
end
|
208
|
+
|
209
|
+
def struts_addTabReturnParameter!(action)
|
210
|
+
t=Cstruts_tab.new(rdf_model,self.rdf_uri+"_tab_return")
|
211
|
+
self.struts_ownedTab_add(t);
|
212
|
+
t.java_Name=STRUTS_RESULTS_FWD
|
213
|
+
self.uml_ownedAttribute.each { |a|
|
214
|
+
next if a.struts_ignoreInForm?
|
215
|
+
next unless a.java_Name==STRUTS_RESULT_PARAM_NAME
|
216
|
+
#next unless a.struts_sourceProperty_one.uml_direction_one.isReturn?
|
217
|
+
t.struts_ownedAttribute_add(a);
|
218
|
+
break # there can be only one return parameter
|
219
|
+
}
|
220
|
+
end
|
221
|
+
|
222
|
+
def struts_addTabFromInterface!(action)
|
223
|
+
return if kind_of?(Muml_Interface)
|
224
|
+
uml_implementation.each {|imp|
|
225
|
+
ie=imp.uml_supplier_one
|
226
|
+
next if ie.java_ignoreMe?
|
227
|
+
t=Cstruts_tab.new(rdf_model,self.rdf_uri+"_tab_"+ie.rdf_uri)
|
228
|
+
self.struts_ownedTab_add(t);
|
229
|
+
t.java_Name=ie.java_Name
|
230
|
+
ie.uml_ownedAttribute.each { |a|
|
231
|
+
next if a.struts_ignoreInForm?
|
232
|
+
t.struts_ownedAttribute_add(a)
|
233
|
+
}
|
234
|
+
}
|
235
|
+
end
|
236
|
+
|
237
|
+
#adds a tab with all attributes
|
238
|
+
def struts_addTabAll!(action)
|
239
|
+
t=Cstruts_tab.new(rdf_model,self.rdf_uri+"_taball")
|
240
|
+
t.java_Name="all"
|
241
|
+
self.struts_ownedTab_add(t);
|
242
|
+
cgi=umlx_classifier_generalization_indirect
|
243
|
+
cgi.add(self)
|
244
|
+
cgi.each { |c|
|
245
|
+
c.uml_ownedAttribute.each { |a|
|
246
|
+
next if a.struts_ignoreInForm?
|
247
|
+
next if a.java_Name==STRUTS_RESULT_PARAM_NAME
|
248
|
+
t.struts_ownedAttribute_add(a)
|
249
|
+
}
|
250
|
+
}
|
251
|
+
end
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
def struts_addProceedAction!(action)
|
256
|
+
proca=action.struts_createAndAddExecuteOperation(STRUTS_PROCEED_ACTION)
|
257
|
+
j=%{
|
258
|
+
#{struts_formCastJavaCode}
|
259
|
+
String s=form.get#{STRUTS_SGBD_STATE_PROP}();
|
260
|
+
}
|
261
|
+
|
262
|
+
[STRUTS_NEW_ACTION,STRUTS_CREATE_ACTION,STRUTS_UPDATE_ACTION,STRUTS_READ_ACTION,STRUTS_DELETE_ACTION].each {|m|
|
263
|
+
j=j+%{if(s.compareTo("#{m}")==0) { return #{m}(mapping,form,request,response); }\n}
|
264
|
+
}
|
265
|
+
j=j+%{
|
266
|
+
String msg="unexpected value for #{STRUTS_SGBD_STATE_PROP} in #{STRUTS_PROCEED_ACTION}";
|
267
|
+
log.error(msg);
|
268
|
+
org.apache.struts.action.ActionErrors ae=new org.apache.struts.action.ActionErrors();
|
269
|
+
ae.add("Error processing request",new org.apache.struts.action.ActionMessage("errors.ioException",msg));
|
270
|
+
saveErrors(request, ae);
|
271
|
+
return mapping.findForward("#{STRUTS_INPUT_FWD}");
|
272
|
+
}
|
273
|
+
proca.java_code=j
|
274
|
+
end
|
275
|
+
|
276
|
+
def struts_addReturnAction!(action)
|
277
|
+
reta=action.struts_createAndAddExecuteOperation(STRUTS_RETURN_ACTION)
|
278
|
+
reta.java_code=%{
|
279
|
+
#{struts_formCastJavaCode}
|
280
|
+
javax.servlet.http.HttpSession session=request.getSession();
|
281
|
+
String key=form.getReference().getClass().getName()+"_returnTo";
|
282
|
+
String url=(String)session.getAttribute(key);
|
283
|
+
session.removeAttribute(key);
|
284
|
+
if(url==null) {
|
285
|
+
// loop on self when reach top of returnTo stack.
|
286
|
+
return mapping.findForward("#{STRUTS_INPUT_FWD}");
|
287
|
+
}
|
288
|
+
|
289
|
+
//external redirect is not supported nor desired when FLEX.
|
290
|
+
// FLEX: redirect = false , not FLEX: redirected= true
|
291
|
+
boolean redirect = request.getParameter("FLEX")==null ;
|
292
|
+
return new org.apache.struts.action.ActionForward(url,redirect);
|
293
|
+
}
|
294
|
+
end
|
295
|
+
|
296
|
+
def struts_addResumeAction!(action)
|
297
|
+
resume=action.struts_createAndAddExecuteOperation(STRUTS_RESUME_ACTION)
|
298
|
+
resume.java_code=<<ENDRESCODE
|
299
|
+
#{struts_formCastJavaCode}
|
300
|
+
#{%{
|
301
|
+
long referenceId = form.getReference().getId();
|
302
|
+
#{self.java_qualifiedName} reference = #{self.java_qualifiedName}.find(referenceId);
|
303
|
+
form.setReference(reference);
|
304
|
+
} unless java_DAOClass.empty? }
|
305
|
+
form.setSgbd_state("#{STRUTS_UPDATE_ACTION}");
|
306
|
+
form.initFromReference();
|
307
|
+
return mapping.findForward("#{STRUTS_INPUT_FWD}");
|
308
|
+
ENDRESCODE
|
309
|
+
end
|
310
|
+
|
311
|
+
def struts_addNewAction!(action)
|
312
|
+
if uml_isAbstract? || kind_of?(Muml_Interface)
|
313
|
+
struts_addNewActionNotAvailable!(action)
|
314
|
+
else
|
315
|
+
struts_addNewActionAvailable!(action)
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
def struts_addNewActionNotAvailable!(action)
|
320
|
+
create=action.struts_createAndAddExecuteOperation(STRUTS_NEW_ACTION)
|
321
|
+
create.java_code=%{
|
322
|
+
throw new java.lang.RuntimeException("new not available for abstract class #{self.java_qualifiedName}");
|
323
|
+
}
|
324
|
+
end
|
325
|
+
|
326
|
+
|
327
|
+
def struts_addNewActionAvailable!(action)
|
328
|
+
create=action.struts_createAndAddExecuteOperation(STRUTS_NEW_ACTION)
|
329
|
+
create.java_code= <<ENDMETH
|
330
|
+
// Creates a new transient object instance and forwards to an edit page.
|
331
|
+
#{struts_formCastJavaCode}
|
332
|
+
form.setReference(new #{java_qualifiedName}());
|
333
|
+
#{%{ form.getReference().initData();\nform.getReference().persist(); } if self.java_isATestFile? }
|
334
|
+
form.initFromReference();
|
335
|
+
//form.getReference().persist();
|
336
|
+
form.set#{STRUTS_SGBD_STATE_PROP}("#{STRUTS_CREATE_ACTION}");
|
337
|
+
#{java_debug(%{"STATE="+form.get#{STRUTS_SGBD_STATE_PROP}()})}
|
338
|
+
return mapping.findForward("#{STRUTS_INPUT_FWD}");
|
339
|
+
ENDMETH
|
340
|
+
end
|
341
|
+
|
342
|
+
|
343
|
+
def struts_addCreateAction!(action)
|
344
|
+
create=action.struts_createAndAddExecuteOperation(STRUTS_CREATE_ACTION)
|
345
|
+
#note: persist must be before copyTo
|
346
|
+
create.java_code=<<ENDMETH
|
347
|
+
#{struts_formCastJavaCode}
|
348
|
+
form.copyToReference();
|
349
|
+
form.setReference(form.getReference().merge());
|
350
|
+
form.initFromReference();
|
351
|
+
form.set#{STRUTS_SGBD_STATE_PROP}("#{STRUTS_UPDATE_ACTION}");
|
352
|
+
return #{STRUTS_RETURN_ACTION}(mapping,form,request,response);
|
353
|
+
ENDMETH
|
354
|
+
end
|
355
|
+
|
356
|
+
def struts_addReadAction!(action)
|
357
|
+
update=action.struts_createAndAddExecuteOperation(STRUTS_READ_ACTION)
|
358
|
+
if java_DAOClass.empty?
|
359
|
+
update.java_code=<<ENDMETH
|
360
|
+
throw new RuntimeException("method #{update.java_Name} is only available for persistent elements");
|
361
|
+
ENDMETH
|
362
|
+
else
|
363
|
+
update.java_code=<<ENDMETH
|
364
|
+
//loads object from database using id and forwards to edit page
|
365
|
+
#{struts_formCastJavaCode}
|
366
|
+
form.setReference(#{java_DAOClass_one.java_qualifiedName}.find(Long.parseLong(form.getId())));
|
367
|
+
form.initFromReference();
|
368
|
+
form.set#{STRUTS_SGBD_STATE_PROP}("#{STRUTS_UPDATE_ACTION}");
|
369
|
+
return mapping.findForward("#{STRUTS_INPUT_FWD}");
|
370
|
+
ENDMETH
|
371
|
+
end
|
372
|
+
end
|
373
|
+
|
374
|
+
def struts_addUpdateAction!(action)
|
375
|
+
update=action.struts_createAndAddExecuteOperation(STRUTS_UPDATE_ACTION)
|
376
|
+
if false #java_DAOClass.empty?
|
377
|
+
update.java_code=<<ENDMETH
|
378
|
+
throw new RuntimeException("method #{update.java_Name} is only available for persistent elements");
|
379
|
+
ENDMETH
|
380
|
+
else
|
381
|
+
update.java_code=<<ENDMETH
|
382
|
+
//update persistent object from html form.
|
383
|
+
#{struts_formCastJavaCode}
|
384
|
+
form.copyToReference();
|
385
|
+
form.setReference(form.getReference().merge());
|
386
|
+
form.set#{STRUTS_SGBD_STATE_PROP}("#{STRUTS_UPDATE_ACTION}");
|
387
|
+
form.initFromReference();
|
388
|
+
return #{STRUTS_RETURN_ACTION}(mapping,form,request,response);
|
389
|
+
ENDMETH
|
390
|
+
end
|
391
|
+
end
|
392
|
+
def struts_addDeleteAction!(action)
|
393
|
+
update=action.struts_createAndAddExecuteOperation(STRUTS_DELETE_ACTION)
|
394
|
+
if false #java_DAOClass.empty?
|
395
|
+
update.java_code=<<ENDMETH
|
396
|
+
throw new RuntimeException("method #{update.java_Name} is only available for persistent elements");
|
397
|
+
ENDMETH
|
398
|
+
else
|
399
|
+
update.java_code= <<ENDCODE
|
400
|
+
#{struts_formCastJavaCode}
|
401
|
+
form.copyToReference();
|
402
|
+
form.set#{STRUTS_SGBD_STATE_PROP}("#{STRUTS_NEW_ACTION}");
|
403
|
+
form.initFromReference();
|
404
|
+
return #{STRUTS_RETURN_ACTION}(mapping,form,request,response);
|
405
|
+
ENDCODE
|
406
|
+
end
|
407
|
+
end
|
408
|
+
|
409
|
+
def struts_addBusinessMethods!(action)
|
410
|
+
umlx_ownedAndInheritedOperation.each { |op|
|
411
|
+
# private and protected methods are not published
|
412
|
+
next if op.uml_visibility_one.isPrivate?
|
413
|
+
next if op.uml_isAbstract?
|
414
|
+
next if op.uml_visibility_one.isProtected?
|
415
|
+
next unless op.umlx_businessMethod?
|
416
|
+
next if op.struts_bizOperationReverse.empty?
|
417
|
+
|
418
|
+
biz=action.struts_createAndAddExecuteOperation("#{op.java_Name}")
|
419
|
+
biz.java_code=<<ENDCODE
|
420
|
+
#{struts_formCastJavaCode}
|
421
|
+
form.copyToReference();
|
422
|
+
form.setReference(form.getReference().merge());
|
423
|
+
#{op.struts_bizOperationReverse_one.java_qualifiedName} newElt=new #{op.struts_bizOperationReverse_one.java_qualifiedName}();
|
424
|
+
newElt.set#{STRUTS_APPLY_TO_PROP}(form.getReference());
|
425
|
+
return #{struts_getActionHelper.java_qualifiedName}.transferToStartEditAction(mapping,request,newElt,"#{self.java_Name}");
|
426
|
+
ENDCODE
|
427
|
+
}
|
428
|
+
end
|
429
|
+
|
430
|
+
def struts_addCreateAndAddActions!(action)
|
431
|
+
struts_formAttribute.each { |a|
|
432
|
+
next unless a.umlx_isComposite?
|
433
|
+
if a.umlx_oneSide?
|
434
|
+
struts_addCreateAndAddOneAction!(action,a)
|
435
|
+
else
|
436
|
+
struts_addCreateAndAddManyAction!(action,a)
|
437
|
+
end
|
438
|
+
}
|
439
|
+
struts_formAttribute.each { |a|
|
440
|
+
next if a.umlx_isAttribute?
|
441
|
+
if a.umlx_oneSide?
|
442
|
+
struts_addEditOneAction!(action,a)
|
443
|
+
else
|
444
|
+
struts_addEditManyAction!(action,a)
|
445
|
+
end
|
446
|
+
}
|
447
|
+
end
|
448
|
+
|
449
|
+
def struts_addCreateAndAddOneAction!(action,a)
|
450
|
+
struts_addCreateAndAddOneOrManyAction!(action,a,false)
|
451
|
+
end
|
452
|
+
def struts_addCreateAndAddManyAction!(action,a)
|
453
|
+
struts_addCreateAndAddOneOrManyAction!(action,a,true)
|
454
|
+
end
|
455
|
+
|
456
|
+
def struts_addCreateAndAddOneOrManyAction!(action,a,isMany)
|
457
|
+
cr=action.struts_createAndAddExecuteOperation("createAndAdd#{a.java_NameBean}")
|
458
|
+
cr.java_code=<<ENDCODE
|
459
|
+
#{struts_formCastJavaCode}
|
460
|
+
/* TPL:0077s*/
|
461
|
+
#{db_tx_none(%{
|
462
|
+
form.copyToReference();
|
463
|
+
#{a.uml_type_one.java_enumAssignableDataType_one.java_qualifiedName} reqType=Enum.valueOf(#{a.uml_type_one.java_enumAssignableDataType_one.java_qualifiedName}.class,form.get#{STRUTS_REQUESTED_CREATION_TYPE_FIELD_PROP}());
|
464
|
+
form.setReference(form.getReference().merge());
|
465
|
+
#{a.uml_type_one.java_qualifiedName} newElt=form.getReference().createAndAdd#{a.java_NameBean}(reqType);
|
466
|
+
form.getReference().persist();
|
467
|
+
return #{struts_getActionHelper.java_qualifiedName}.transferToStartEditAction(mapping,request,newElt,"#{self.java_Name}");
|
468
|
+
})}
|
469
|
+
ENDCODE
|
470
|
+
end
|
471
|
+
|
472
|
+
def struts_addEditManyAction!(action,a)
|
473
|
+
cr=action.struts_createAndAddExecuteOperation("edit#{a.java_NameBean}")
|
474
|
+
e=struts_getFunctionalException
|
475
|
+
cr.java_code= <<ENDCODE
|
476
|
+
#{struts_formCastJavaCode}
|
477
|
+
#{%{
|
478
|
+
long referenceId = form.getReference().getId();
|
479
|
+
#{self.java_qualifiedName} reference = #{self.java_qualifiedName}.find(referenceId);
|
480
|
+
form.setReference(reference);
|
481
|
+
} unless java_DAOClass.empty? }
|
482
|
+
|
483
|
+
form.copyToReference();
|
484
|
+
String sid=request.getParameter("#{STRUTS_REQUESTED_TAB}");
|
485
|
+
long id=Long.parseLong(sid);
|
486
|
+
|
487
|
+
#{a.uml_type_one.java_qualifiedName} elt=null;
|
488
|
+
|
489
|
+
{
|
490
|
+
java.util.Iterator<?> iter=form.getReference().get#{a.java_NameBean}().iterator();
|
491
|
+
while(iter.hasNext()) {
|
492
|
+
elt=(#{a.uml_type_one.java_qualifiedName})iter.next();
|
493
|
+
if (elt.getId()!=id) continue;
|
494
|
+
break;
|
495
|
+
}
|
496
|
+
#{e.java_qualifiedName} exceptionToFire = new #{e.java_qualifiedName}("/pages/#{java_InternalFilePath}form/#{java_Name}all.jsp","Internal error. #{cr.java_qualifiedName} called on null element");
|
497
|
+
#{struts_getActionHelper.java_qualifiedName}.checkNotNull(elt,exceptionToFire);
|
498
|
+
|
499
|
+
}
|
500
|
+
return #{struts_getActionHelper.java_qualifiedName}.transferToStartEditAction(mapping,request,elt,"#{self.java_Name}");
|
501
|
+
ENDCODE
|
502
|
+
end
|
503
|
+
|
504
|
+
def struts_addEditOneAction!(action,a)
|
505
|
+
cr=action.struts_createAndAddExecuteOperation("edit#{a.java_NameBean}")
|
506
|
+
e=struts_getFunctionalException
|
507
|
+
cr.java_code= <<ENDCODE
|
508
|
+
#{struts_formCastJavaCode}
|
509
|
+
#{%{
|
510
|
+
long referenceId = form.getReference().getId();
|
511
|
+
#{self.java_qualifiedName} reference = #{self.java_qualifiedName}.find(referenceId);
|
512
|
+
form.setReference(reference);
|
513
|
+
} unless java_DAOClass.empty?}
|
514
|
+
|
515
|
+
form.copyToReference();
|
516
|
+
//form.setReference(form.getReference().merge());
|
517
|
+
|
518
|
+
#{a.uml_type_one.java_qualifiedName} elt=form.getReference().get#{a.java_NameBean}();
|
519
|
+
|
520
|
+
#{e.java_qualifiedName} exceptionToFire = new #{e.java_qualifiedName}("/pages/#{java_InternalFilePath}form/#{java_Name}all.jsp","Internal error. #{cr.java_qualifiedName} called on null element");
|
521
|
+
#{struts_getActionHelper.java_qualifiedName}.checkNotNull(elt,exceptionToFire);
|
522
|
+
|
523
|
+
return #{struts_getActionHelper.java_qualifiedName}.transferToStartEditAction(mapping,request,elt,"#{self.java_Name}");
|
524
|
+
ENDCODE
|
525
|
+
end
|
526
|
+
|
527
|
+
def struts_addRemoveAndDeleteActions!(action)
|
528
|
+
struts_formAttribute.each { |a|
|
529
|
+
#next unless a.umlx_isComposite?
|
530
|
+
#next unless a.umlx_isAssociation?
|
531
|
+
next if a.umlx_isAttribute?
|
532
|
+
if a.umlx_oneSide?
|
533
|
+
struts_addRemoveAndDeleteOneAction!(action,a)
|
534
|
+
else
|
535
|
+
struts_addRemoveAndDeleteManyAction!(action,a)
|
536
|
+
end
|
537
|
+
struts_addOneOrManyAction!(action,a)
|
538
|
+
}
|
539
|
+
end
|
540
|
+
|
541
|
+
def struts_addOneOrManyAction!(action,a)
|
542
|
+
return if a.uml_isReadOnly?
|
543
|
+
meth=action.struts_createAndAddExecuteOperation("add#{a.java_NameBean}")
|
544
|
+
if false #java_DAOClass.empty?
|
545
|
+
meth.java_code=<<ENDMETH
|
546
|
+
throw new RuntimeException("method #{meth.java_Name} is only available for persistent elements");
|
547
|
+
ENDMETH
|
548
|
+
else
|
549
|
+
meth.java_code= <<ENDMETH
|
550
|
+
/* TPL: ACTION-004 */
|
551
|
+
#{struts_formCastJavaCode}
|
552
|
+
String sid=request.getParameter("#{STRUTS_REQUESTED_TAB}");
|
553
|
+
long id=Long.parseLong(sid);
|
554
|
+
|
555
|
+
form.copyToReference();
|
556
|
+
form.setReference(form.getReference().merge());
|
557
|
+
#{struts_findElt(a,true)}
|
558
|
+
if(elt!=null) {
|
559
|
+
form.getReference().#{a.umlx_oneSide? ? "set":"add"}#{a.java_NameBean}(elt);
|
560
|
+
//TODO: delete element
|
561
|
+
}
|
562
|
+
form.initFromReference();
|
563
|
+
return mapping.findForward("#{STRUTS_INPUT_FWD}");
|
564
|
+
ENDMETH
|
565
|
+
end
|
566
|
+
end
|
567
|
+
|
568
|
+
def struts_addRemoveAndDeleteOneAction!(action,a)
|
569
|
+
return if a.uml_isReadOnly?
|
570
|
+
del=action.struts_createAndAddExecuteOperation("removeAndDelete#{a.java_NameBean}")
|
571
|
+
del.java_code= <<END_DEL_CODE
|
572
|
+
#{struts_formCastJavaCode}
|
573
|
+
#{db_tx_none(%{
|
574
|
+
//String sid=request.getParameter("#{STRUTS_REQUESTED_TAB}");
|
575
|
+
//long id=Long.parseLong(sid);
|
576
|
+
//#{a.uml_type_one.java_qualifiedName} elt=null;
|
577
|
+
form.copyToReference();
|
578
|
+
form.setReference(form.getReference().merge());
|
579
|
+
form.getReference().set#{a.java_NameBean}(null);
|
580
|
+
//TODO: delete element
|
581
|
+
form.initFromReference();
|
582
|
+
})}
|
583
|
+
return mapping.findForward("#{STRUTS_INPUT_FWD}");
|
584
|
+
END_DEL_CODE
|
585
|
+
end
|
586
|
+
|
587
|
+
def struts_findElt(a,findFromSug=false)
|
588
|
+
sug=findFromSug ? "Sug" : ""
|
589
|
+
cr=a
|
590
|
+
e=struts_getFunctionalException
|
591
|
+
return <<ENDCODE
|
592
|
+
#{a.uml_type_one.java_qualifiedName} elt=null;
|
593
|
+
{
|
594
|
+
java.util.Iterator<?> iter=form.getReference().get#{a.java_NameBean}#{sug}().iterator();
|
595
|
+
while(iter.hasNext()) {
|
596
|
+
elt=(#{a.uml_type_one.java_qualifiedName})iter.next();
|
597
|
+
if(elt.getId()!=id) continue;
|
598
|
+
break;
|
599
|
+
}
|
600
|
+
}
|
601
|
+
#{e.java_qualifiedName} exceptionToFire = new #{e.java_qualifiedName}("/pages/#{java_InternalFilePath}form/#{java_Name}#{STRUTS_RESULTS_FWD}.jsp","Internal error. #{cr.java_qualifiedName} called on null element");
|
602
|
+
#{struts_getActionHelper.java_qualifiedName}.checkNotNull(elt,exceptionToFire);
|
603
|
+
ENDCODE
|
604
|
+
end
|
605
|
+
|
606
|
+
|
607
|
+
|
608
|
+
def struts_addRemoveAndDeleteManyAction!(action,a)
|
609
|
+
return if a.uml_isReadOnly?
|
610
|
+
del=action.struts_createAndAddExecuteOperation("removeAndDelete#{a.java_NameBean}")
|
611
|
+
del.java_code= <<ENDJCODE
|
612
|
+
#{struts_formCastJavaCode}
|
613
|
+
#{db_tx_none(%{
|
614
|
+
String sid=request.getParameter("#{STRUTS_REQUESTED_TAB}");
|
615
|
+
long id=Long.parseLong(sid);
|
616
|
+
|
617
|
+
form.copyToReference();
|
618
|
+
form.setReference(form.getReference().merge());
|
619
|
+
#{struts_findElt(a)}
|
620
|
+
if(elt!=null) {
|
621
|
+
form.getReference().remove#{a.java_NameBean}(elt);
|
622
|
+
//TODO: delete element
|
623
|
+
}
|
624
|
+
form.initFromReference();
|
625
|
+
|
626
|
+
})}
|
627
|
+
return mapping.findForward("#{STRUTS_INPUT_FWD}");
|
628
|
+
ENDJCODE
|
629
|
+
end
|
630
|
+
|
631
|
+
def struts_addSwitchToFlexAction!(action)
|
632
|
+
return unless context[:generateXMLStrutsForm]
|
633
|
+
create=action.struts_createAndAddExecuteOperation(::Muml_Class::STRUTS_SWITH_TO_FLEX_ACTION)
|
634
|
+
create.java_code= <<JCODE
|
635
|
+
#{struts_formCastJavaCode}
|
636
|
+
String z="#{Muml_Class::STRUTS_SWITCH_TO_FLEX_FORWARD}";
|
637
|
+
#{STRUTS_ACTION_FORWARD} am=mapping.findForward(z);
|
638
|
+
#{db_tx_none(%{
|
639
|
+
form.copyToReference();
|
640
|
+
form.setReference(form.getReference().merge());
|
641
|
+
if(am==null) {
|
642
|
+
#{java_error(%{"ActionMapping not found for '"+z+"'"})}
|
643
|
+
return mapping.findForward("#{STRUTS_INPUT_FWD}");
|
644
|
+
}
|
645
|
+
})}
|
646
|
+
request.getSession().setAttribute("flex_action",request.getRequestURI());
|
647
|
+
request.getSession().setAttribute("flex_locale",getLocale(request).getLanguage());
|
648
|
+
return am;
|
649
|
+
JCODE
|
650
|
+
end
|
651
|
+
|
652
|
+
def struts_addRefreshAction!(action)
|
653
|
+
meth=action.struts_createAndAddExecuteOperation(STRUTS_REFRESH_ACTION)
|
654
|
+
meth.java_code=<<ENDMETH
|
655
|
+
#{struts_formCastJavaCode}
|
656
|
+
String z=request.getParameter("#{STRUTS_REQUESTED_TAB}");
|
657
|
+
#{STRUTS_ACTION_FORWARD} am=mapping.findForward(z);
|
658
|
+
form.copyToReference();
|
659
|
+
form.setReference(form.getReference().merge());
|
660
|
+
if(am==null) {
|
661
|
+
#{java_error(%{"ActionMapping not found for '"+z+"'"})}
|
662
|
+
return mapping.findForward("#{STRUTS_INPUT_FWD}");
|
663
|
+
}
|
664
|
+
return am;
|
665
|
+
ENDMETH
|
666
|
+
end
|
667
|
+
def struts_addFieldMethods!(action)
|
668
|
+
form=struts_actionForm_one
|
669
|
+
uml_ownedAttribute.each {|a|
|
670
|
+
tpl=JavaMapping.instance.getTemplate(a.uml_type_one)
|
671
|
+
tpl.addActionFieldMethod!(a,action,form)
|
672
|
+
}
|
673
|
+
end
|
674
|
+
|
675
|
+
STRUTS_SETSKIN_ACTION="setSkin"
|
676
|
+
STRUTS_SETTIMEZONE_ACTION="setTimeZone"
|
677
|
+
STRUTS_SETLOCALE_ACTION="setLocale"
|
678
|
+
def struts_addsetTimeZoneAction!(action)
|
679
|
+
mpc=self
|
680
|
+
cpt=action.struts_createAndAddExecuteOperation(STRUTS_SETTIMEZONE_ACTION)
|
681
|
+
cpt.java_code=<<ENDCODE
|
682
|
+
#{struts_formCastJavaCode}
|
683
|
+
//form.copyToReference();
|
684
|
+
String newTimeZoneId = form.getStruts_tz();
|
685
|
+
#{struts_getActionHelper.java_qualifiedName}.changeTimeZoneAction_s1(form,mapping,request, newTimeZoneId);
|
686
|
+
form.setReference(form.getReference().merge());
|
687
|
+
return #{struts_getActionHelper.java_qualifiedName}.changeTimeZoneAction_s2(form,mapping,request, newTimeZoneId);
|
688
|
+
ENDCODE
|
689
|
+
end
|
690
|
+
def struts_addsetSkinAction!(action)
|
691
|
+
mpc=self
|
692
|
+
cpt=action.struts_createAndAddExecuteOperation(STRUTS_SETSKIN_ACTION)
|
693
|
+
#TODO cpt.java_code=
|
694
|
+
end
|
695
|
+
def struts_addsetLocaleAction!(action)
|
696
|
+
mpc=self
|
697
|
+
cpt=action.struts_createAndAddExecuteOperation(STRUTS_SETLOCALE_ACTION)
|
698
|
+
cpt.java_code=%{
|
699
|
+
#{struts_formCastJavaCode}
|
700
|
+
form.copyToReference();
|
701
|
+
return #{struts_getActionHelper.java_qualifiedName}.changeLocaleAction(mapping,getLocale(request),request,form.getStrutsLanguage(),form.getStrutsCountry());
|
702
|
+
}
|
703
|
+
end
|
704
|
+
end
|
705
|
+
module Muml_Element
|
706
|
+
def db_tx_none(java_code)
|
707
|
+
return java_code
|
708
|
+
end
|
709
|
+
|
710
|
+
STRUTS_ACTION_HELPER="xmda.struts.ActionHelper"
|
711
|
+
|
712
|
+
def struts_getActionHelper
|
713
|
+
helper=umlx_getOrCreateClass(STRUTS_ACTION_HELPER)
|
714
|
+
if(helper.java_customCode.empty?)
|
715
|
+
helper.apaCom_addLogger!
|
716
|
+
helper.umlx_external=RDF_FALSE
|
717
|
+
#helper.java_import_add(STRUTS_LVB)
|
718
|
+
helper.db_isTransient=RDF_TRUE
|
719
|
+
helper.struts_isForm=RDF_FALSE
|
720
|
+
helper.java_customCode= <<ENDCODE
|
721
|
+
|
722
|
+
public static final String STRUTS_INPUT_FWD="#{::Muml_Classifier::STRUTS_INPUT_FWD}";
|
723
|
+
|
724
|
+
public static void changeTimeZoneAction_s1(final #{::Muml_Classifier::STRUTS_FORM_INTERFACE} form,final org.apache.struts.action.ActionMapping mapping,final javax.servlet.http.HttpServletRequest request,final String newTimeZoneId) {
|
725
|
+
String oldTimeZoneId = xmda.tags.helpers.XMDARequestUtils.getUserTimeZone(request, null).getID();
|
726
|
+
//String newTimeZoneId = form.get#{Muml_Classifier::STRUTS_SETTIMEZONE_BEAN}();
|
727
|
+
|
728
|
+
// we change the the timezone.
|
729
|
+
xmda.struts.ActionHelper.changeTimeZone(mapping, java.util.TimeZone.getDefault(),request,newTimeZoneId);
|
730
|
+
|
731
|
+
// We transform the current timestamp dates in the form to the GMT
|
732
|
+
// format
|
733
|
+
// using the old time zone id in the method "copyToReference".
|
734
|
+
form.set#{Muml_Classifier::STRUTS_SETTIMEZONE_BEAN}(oldTimeZoneId);
|
735
|
+
form.copyToReference();
|
736
|
+
}
|
737
|
+
|
738
|
+
public static org.apache.struts.action.ActionForward changeTimeZoneAction_s2(final #{::Muml_Classifier::STRUTS_FORM_INTERFACE} form,final org.apache.struts.action.ActionMapping mapping,final javax.servlet.http.HttpServletRequest request,final String newTimeZoneId) {
|
739
|
+
//String newTimeZoneId = form.get#{Muml_Classifier::STRUTS_SETTIMEZONE_BEAN}();
|
740
|
+
form.set#{Muml_Classifier::STRUTS_SETTIMEZONE_BEAN}(newTimeZoneId);
|
741
|
+
form.initFromReference();
|
742
|
+
|
743
|
+
return mapping.findForward(STRUTS_INPUT_FWD);
|
744
|
+
}
|
745
|
+
|
746
|
+
|
747
|
+
public static void changeTimeZone(
|
748
|
+
final org.apache.struts.action.ActionMapping mapping, java.util.TimeZone timeZone,
|
749
|
+
final javax.servlet.http.HttpServletRequest request, final String timeZoneDisplayName) {
|
750
|
+
|
751
|
+
boolean isTimeZone = ((timeZoneDisplayName != null) && (timeZoneDisplayName.length() > 0));
|
752
|
+
|
753
|
+
if (isTimeZone) {
|
754
|
+
timeZone = java.util.TimeZone.getTimeZone(timeZoneDisplayName);
|
755
|
+
}
|
756
|
+
request.getSession().setAttribute(xmda.tags.helpers.XMDAStrutsGlobals.TIMEZONE_KEY,
|
757
|
+
timeZone);
|
758
|
+
|
759
|
+
log.debug("selected timeZone = " + timeZone.getDisplayName());
|
760
|
+
// return mapping.findForward("inputfw");
|
761
|
+
}
|
762
|
+
|
763
|
+
public static String getCurrentTab(final org.apache.struts.action.ActionMapping mapping,final String bizClassName) {
|
764
|
+
String path=mapping.findForward(STRUTS_INPUT_FWD).getPath();
|
765
|
+
// path=/pages/comftpass/application/form/Applicationall.jsp
|
766
|
+
String s=bizClassName;
|
767
|
+
//int i=path.indexOf(s);
|
768
|
+
int bi=path.indexOf(s)+s.length();
|
769
|
+
int ei=path.indexOf(".jsp");
|
770
|
+
|
771
|
+
String currentTab=path.substring(bi,ei);
|
772
|
+
#{java_debug(%{"currentTab= >"+currentTab+"< path="+path})}
|
773
|
+
return currentTab;
|
774
|
+
}
|
775
|
+
|
776
|
+
public static org.apache.struts.action.ActionForward changeLocaleAction(final org.apache.struts.action.ActionMapping mapping,java.util.Locale locale,final javax.servlet.http.HttpServletRequest request,final String language,final String country) {
|
777
|
+
|
778
|
+
boolean isLanguage = ((language != null) && (language.length() > 0));
|
779
|
+
boolean isCountry = ((country != null) && (country.length() > 0));
|
780
|
+
|
781
|
+
if ((isLanguage) && (isCountry)) {
|
782
|
+
locale = new java.util.Locale(language, country);
|
783
|
+
} else if (isLanguage) {
|
784
|
+
locale = new java.util.Locale(language, "");
|
785
|
+
}
|
786
|
+
request.getSession().setAttribute(org.apache.struts.Globals.LOCALE_KEY, locale);
|
787
|
+
return mapping.findForward("#{Muml_Classifier::STRUTS_INPUT_FWD}");
|
788
|
+
}
|
789
|
+
|
790
|
+
public static org.apache.struts.action.ActionForward transferToStartEditAction(final org.apache.struts.action.ActionMapping mapping,final javax.servlet.http.HttpServletRequest request,final Object alienElement,final String parentFwd) {
|
791
|
+
javax.servlet.http.HttpSession session = request.getSession();
|
792
|
+
String currentTab = getCurrentTab(mapping, parentFwd);
|
793
|
+
// an extraneous "/" is added for forward (not needed for redirect)
|
794
|
+
String returnTo = "/"+parentFwd + currentTab
|
795
|
+
+ "-submit.do?doWhat=#{Muml_Classifier::STRUTS_RESUME_ACTION}";
|
796
|
+
|
797
|
+
session.setAttribute("#{Muml_Classifier::STRUTS_SESSION_KEY_EditAction}", alienElement);
|
798
|
+
session.setAttribute( alienElement.getClass().getName() + "_returnTo", returnTo);
|
799
|
+
return mapping.findForward(alienElement.getClass().getSimpleName()+"#{Muml_Class::STRUTS_EDIT_FWD_POSTFIX}");
|
800
|
+
}
|
801
|
+
|
802
|
+
public static void checkNotNull(final Object elt, #{struts_getFunctionalException.java_qualifiedName} exceptionToFire) {
|
803
|
+
if (elt == null) {
|
804
|
+
throw exceptionToFire;
|
805
|
+
}
|
806
|
+
}
|
807
|
+
/*
|
808
|
+
* dump image contained in image variable to web browser.
|
809
|
+
* Forward to #{Muml_Class::NOGIF_FORWARD} if image is null.
|
810
|
+
*/
|
811
|
+
public static org.apache.struts.action.ActionForward writeGif(final org.apache.struts.action.ActionMapping mapping,final javax.servlet.http.HttpServletResponse response, byte image[]) {
|
812
|
+
if (image != null) {
|
813
|
+
response.setContentType("image/gif");
|
814
|
+
try {
|
815
|
+
response.getOutputStream().write(image);
|
816
|
+
} catch (java.io.IOException ioe) {
|
817
|
+
throw new RuntimeException(ioe);
|
818
|
+
}
|
819
|
+
return null;
|
820
|
+
} else {
|
821
|
+
// image will display as text if loaded directly
|
822
|
+
// ie: not trough <img src=>
|
823
|
+
response.setContentType("image/gif");
|
824
|
+
return mapping.findForward("#{Muml_Class::NOGIF_FORWARD}");
|
825
|
+
}
|
826
|
+
}
|
827
|
+
|
828
|
+
/*
|
829
|
+
* dump image contained in image variable to web browser.
|
830
|
+
* Forward to #{Muml_Class::NOGIF_FORWARD} if image is null.
|
831
|
+
*/
|
832
|
+
public static org.apache.struts.action.ActionForward writeGraphviz(final org.apache.struts.action.ActionMapping mapping,final javax.servlet.http.HttpServletResponse response,final String graphvizDotFile) {
|
833
|
+
if (graphvizDotFile!= null) {
|
834
|
+
response.setContentType("image/gif");
|
835
|
+
try {
|
836
|
+
com.ft.cil.graphe.Graphe graphe=new com.ft.cil.graphe.Graphe(graphvizDotFile);
|
837
|
+
//note: function renaming : (Stream is a byte array)
|
838
|
+
response.getOutputStream().write(graphe.getImageStream());
|
839
|
+
} catch (java.io.IOException ioe) {
|
840
|
+
throw new RuntimeException(ioe);
|
841
|
+
}
|
842
|
+
return null;
|
843
|
+
} else {
|
844
|
+
// image will display as text if loaded directly
|
845
|
+
// ie: not trough <img src=>
|
846
|
+
response.setContentType("image/gif");
|
847
|
+
return mapping.findForward("#{Muml_Class::NOGIF_FORWARD}");
|
848
|
+
}
|
849
|
+
}
|
850
|
+
|
851
|
+
/*
|
852
|
+
* dump image contained in image variable to web browser.
|
853
|
+
* Forward to #{Muml_Class::NOGIF_FORWARD} if image is null.
|
854
|
+
*/
|
855
|
+
|
856
|
+
public static org.apache.struts.action.ActionForward writeGraphvizMap(final org.apache.struts.action.ActionMapping mapping,final javax.servlet.http.HttpServletResponse response,final String graphvizDotFile) {
|
857
|
+
response.setContentType("text/html");
|
858
|
+
if (graphvizDotFile!= null) {
|
859
|
+
|
860
|
+
try {
|
861
|
+
com.ft.cil.graphe.Graphe graphe=new com.ft.cil.graphe.Graphe(graphvizDotFile);
|
862
|
+
//note: function renaming : (Stream is a byte array)
|
863
|
+
javax.servlet.ServletOutputStream out=response.getOutputStream();
|
864
|
+
out.write("<html><head><title>usemap</title></head><body><map name=\\"myMap\\">\\n".getBytes());
|
865
|
+
out.write(graphe.getImageMap());
|
866
|
+
out.write("</map></body></html>\\n".getBytes());
|
867
|
+
} catch (java.io.IOException ioe) {
|
868
|
+
throw new RuntimeException(ioe);
|
869
|
+
}
|
870
|
+
} else {
|
871
|
+
|
872
|
+
// image will display as text if loaded directly
|
873
|
+
// ie: not trough <img src=>
|
874
|
+
|
875
|
+
}
|
876
|
+
// do not forward to a jsp, output has already been written.
|
877
|
+
return null;
|
878
|
+
}
|
879
|
+
|
880
|
+
ENDCODE
|
881
|
+
|
882
|
+
end
|
883
|
+
return helper;
|
884
|
+
end
|
885
|
+
end
|
886
|
+
|