Module: Muml_Classifier
- Defined in:
- lib/ontomde-uml2-struts/form.rb,
lib/ontomde-uml2-struts/form.rb,
lib/ontomde-uml2-struts/action.rb,
lib/ontomde-uml2-struts/jsp_edit.rb,
lib/ontomde-uml2-struts/localeAction.rb,
lib/ontomde-uml2-struts/localeAction.rb
Constant Summary collapse
- STRUTS_REQUESTED_CREATION_TYPE_FIELD_NAME =
"reqType"
- STRUTS_REQUESTED_CREATION_TYPE_FIELD_PROP =
"ReqType"
- STRUTS_DISPATCH_FIELD_NAME =
"doWhat"
- STRUTS_DISPATCH_FIELD_METH =
"DoWhat"
- STRUTS_REQUESTED_TAB =
"reqtab"
- STRUTS_FORM_INTERFACE =
"xmda.struts.Form"
- STRUTS_ACCEPT_NULL_FIELD_IN_FORMS =
true
- STRUTS_NEW_ACTION =
"newa"
- STRUTS_CREATE_ACTION =
"sgbd_create"
- STRUTS_UPDATE_ACTION =
"sgbd_update"
- STRUTS_READ_ACTION =
"sgbd_read"
- STRUTS_DELETE_ACTION =
"sgbd_delete"
- STRUTS_PROCEED_ACTION =
"biz_proceed"
- STRUTS_INPUT_FWD =
"inputfw"
- STRUTS_RESULTS_FWD =
TODO
"retour"
- STRUTS_RETURN_ACTION =
terminate local treatment and return control to calling controller.
"returnTo"
- STRUTS_RESUME_ACTION =
Resume local treatment avect geting control back from another controler.
"resume"
- STRUTS_REFRESH_ACTION =
"executeRefresh"
- STRUTS_SGBD_STATE =
"sgbd_state"
- STRUTS_SGBD_STATE_PROP =
"Sgbd_state"
- STRUTS_ACTION_MAPPING =
STRUTS_RETURN_TO_FIELD=“jsp_return_to” STRUTS_RETURN_TO_PROP=“Jsp_return_to”
"org.apache.struts.action.ActionMapping"
- STRUTS_ACTION_FORWARD =
"org.apache.struts.action.ActionForward"
- STRUTS_ACTION_STARTEDIT =
"startEditAction"
- STRUTS_SESSION_KEY_EditAction =
"objToEdit"
- STRUTS_SETSKIN_ACTION =
"setSkin"
- STRUTS_SETTIMEZONE_ACTION =
"setTimeZone"
- STRUTS_SETLOCALE_ACTION =
"setLocale"
- STRUTS_SETSKIN_FIELD =
"skin"
- STRUTS_SETTIMEZONE_FIELD =
"struts_tz"
- STRUTS_SETTIMEZONE_BEAN =
"Struts_tz"
- STRUTS_SETLOCALE_LANGUAGE_FIELD =
"strutsLanguage"
- STRUTS_SETCOUNTRY_FIELD =
'strutsCountry'
Instance Method Summary collapse
- #struts_addAction! ⇒ Object
- #struts_addActionBiz! ⇒ Object
- #struts_addActionCRUD! ⇒ Object
-
#struts_addActionForm! ⇒ Object
Creates and add an action form corresponding to this class.
- #struts_addActionFormAttribute!(form) ⇒ Object
- #struts_addActionLocaleFormFields! ⇒ Object
- #struts_addBusinessMethods!(action) ⇒ Object
- #struts_addCopyTo! ⇒ Object
- #struts_addCreateAction!(action) ⇒ Object
- #struts_addCreateAndAddActions!(action) ⇒ Object
- #struts_addCreateAndAddManyAction!(action, a) ⇒ Object
- #struts_addCreateAndAddOneAction!(action, a) ⇒ Object
- #struts_addCreateAndAddOneOrManyAction!(action, a, isMany) ⇒ Object
- #struts_addDeleteAction!(action) ⇒ Object
- #struts_addEditManyAction!(action, a) ⇒ Object
- #struts_addEditOneAction!(action, a) ⇒ Object
- #struts_addFieldMethods!(action) ⇒ Object
- #struts_addInitAndCopyToReference! ⇒ Object
- #struts_addInitFrom! ⇒ Object
- #struts_addNewAction!(action) ⇒ Object
- #struts_addNewActionAvailable!(action) ⇒ Object
- #struts_addNewActionNotAvailable!(action) ⇒ Object
- #struts_addNewBizAction!(action) ⇒ Object
- #struts_addOneOrManyAction!(action, a) ⇒ Object
- #struts_addProceedAction!(action) ⇒ Object
- #struts_addProceedBizAction!(action) ⇒ Object
- #struts_addReadAction!(action) ⇒ Object
- #struts_addRefreshAction!(action) ⇒ Object
- #struts_addRemoveAndDeleteActions!(action) ⇒ Object
- #struts_addRemoveAndDeleteManyAction!(action, a) ⇒ Object
- #struts_addRemoveAndDeleteOneAction!(action, a) ⇒ Object
- #struts_addReset! ⇒ Object
- #struts_addResumeAction!(action) ⇒ Object
- #struts_addReturnAction!(action) ⇒ Object
-
#struts_addsetLocaleAction!(action) ⇒ Object
TODO cpt.java_code=.
- #struts_addsetSkinAction!(action) ⇒ Object
- #struts_addsetTimeZoneAction!(action) ⇒ Object
- #struts_addStartEditAction!(action) ⇒ Object
- #struts_addSwitchToFlexAction!(action) ⇒ Object
-
#struts_addTabAll!(action) ⇒ Object
adds a tab with all attributes.
- #struts_addTabFromInterface!(action) ⇒ Object
- #struts_addTabReturnParameter!(action) ⇒ Object
- #struts_addTabs!(action) ⇒ Object
- #struts_addTabsBiz!(action) ⇒ Object
- #struts_addUpdateAction!(action) ⇒ Object
- #struts_createAndAddActionBase! ⇒ Object
-
#struts_createAndAddExecuteOperation(name) ⇒ Object
Creates an add a struts “execute” method of an action bean Names needs not be “execute” thanks to struts dispatch feature.
- #struts_eachFormAttribute_deprec ⇒ Object
- #struts_edit_writeField(field, owner) ⇒ Object
- #struts_edit_writeFieldCompo(field, owner, isMany) ⇒ Object
- #struts_edit_writeFieldGeneric(field, owner, isMany, isCompo) ⇒ Object
- #struts_edit_writeFieldGeneric_DisplayTable(field, owner, isMany, isCompo) ⇒ Object
- #struts_edit_writeFieldGeneric_DisplayTable_displayTag(field, owner, isMany, isCompo) ⇒ Object
- #struts_edit_writeFieldGeneric_DisplayTable_strutsOnly(field, owner, isMany, isCompo) ⇒ Object
- #struts_edit_writeFieldGenericIsCompo(field, owner, isMany, isCompo) ⇒ Object
- #struts_edit_writeFieldMany(field, owner) ⇒ Object
- #struts_edit_writeFieldManyCompo(field, owner) ⇒ Object
- #struts_edit_writeFieldOne(field, owner) ⇒ Object
- #struts_edit_writeFieldOneCompo(field, owner) ⇒ Object
- #struts_edit_writeSelectAndAdd(field, owner) ⇒ Object
-
#struts_editWriteSelectAndAddLabel(field, elt, withLabelOnly = true) ⇒ Object
add label use every property stereotpyed Label.
- #struts_findElt(a, findFromSug = false) ⇒ Object
-
#struts_formAttribute(ignoreDbId = false) ⇒ Object
every attribute meant to appear in the form.
-
#struts_formCastJavaCode(action = nil) ⇒ Object
Return java code to be included at the begining of every action execute method.
-
#struts_formOperation ⇒ Object
every method meant to appear in the form.
- #struts_getFormInterface ⇒ Object
- #struts_typeIsUsed?(type) ⇒ Boolean
Instance Method Details
#struts_addAction! ⇒ Object
67 68 69 70 71 72 73 74 |
# File 'lib/ontomde-uml2-struts/action.rb', line 67 def struts_addAction! #log.debug { "struts_addAction! #{self}::#{self.class.name}" } if struts_bizOperation.empty? struts_addActionCRUD! else struts_addActionBiz! end end |
#struts_addActionBiz! ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/ontomde-uml2-struts/action.rb', line 76 def struts_addActionBiz! action=struts_createAndAddActionBase! struts_addStartEditAction!(action) struts_addsetTimeZoneAction!(action) struts_addsetSkinAction!(action) struts_addsetLocaleAction!(action) struts_addRefreshAction!(action) struts_addNewBizAction!(action) struts_addProceedBizAction!(action) struts_addTabsBiz!(action) struts_addSwitchToFlexAction!(action) struts_addReturnAction!(action) #struts_addProceedAction!(action) struts_addResumeAction!(action) #struts_addNewAction!(action) #struts_addCreateAction!(action) struts_addReadAction!(action) #struts_addUpdateAction!(action) #struts_addDeleteAction!(action) #struts_addBusinessMethods!(action) struts_addCreateAndAddActions!(action) struts_addRemoveAndDeleteActions!(action) struts_addFieldMethods!(action) end |
#struts_addActionCRUD! ⇒ Object
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/ontomde-uml2-struts/action.rb', line 172 def struts_addActionCRUD! action=struts_createAndAddActionBase! struts_addStartEditAction!(action) struts_addsetTimeZoneAction!(action) struts_addsetSkinAction!(action) struts_addsetLocaleAction!(action) struts_addReturnAction!(action) struts_addProceedAction!(action) struts_addResumeAction!(action) struts_addRefreshAction!(action) struts_addNewAction!(action) struts_addCreateAction!(action) struts_addReadAction!(action) struts_addUpdateAction!(action) struts_addDeleteAction!(action) struts_addCreateAndAddActions!(action) struts_addRemoveAndDeleteActions!(action) struts_addTabs!(action) struts_addSwitchToFlexAction!(action) struts_addFieldMethods!(action) return if db_isTransient? struts_addBusinessMethods!(action) end |
#struts_addActionForm! ⇒ Object
Creates and add an action form corresponding to this class.
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/ontomde-uml2-struts/form.rb', line 104 def struts_addActionForm! #log.debug { "struts_addActionForm! for #{self}:#{self.class}" } p=umlx_owner_one p=p.umlx_getOrCreatePackage(context[:strutsFormPackage,context[:strutsActionFormPackage,"struts"]],p) form=p.umlx_createAndAddClass(rdf_uri+"_ActionFormClass") form.umlx_createAndAddImplementation(struts_getFormInterface) form.struts_addInitAndCopyToReference! form.struts_isForm=RDF_TRUE form.db_isTransient=RDF_TRUE form.struts_actionFormSrc=self self.struts_actionForm=form form.uml_name="#{uml_name}StrutsForm" #af=umlx_getOrCreateClass("org.apache.struts.action.ActionForm") #if (uml_generalization.empty?) #NOTE: Forms inheritance DO NOT follow class inheritance. # (to allow exact typing in redefined methods) af=umlx_getOrCreateClass("org.apache.struts.validator.ValidatorForm") form.umlx_createAndAddGeneralization(af) form.java_makeSerializable! #ag=umlx_getOrCreateClass("java.io.Serializable") #form.umlx_createAndAddImplementation(ag) #TODO ajouter implements interface struts_addActionFormAttribute!(form) struts_create_getXMLFormOperations!(form) struts_addInitFrom! struts_addCopyTo! struts_addReset! ref=form.umlx_createAndAddProperty(form.rdf_uri+"__ref","reference") ref.uml_type=self [STRUTS_DISPATCH_FIELD_NAME,STRUTS_SGBD_STATE,STRUTS_REQUESTED_CREATION_TYPE_FIELD_NAME].each {|p| act=form.umlx_createAndAddProperty(form.rdf_uri+p) act.uml_name=p act.uml_type=umlx_dataType_string } form.struts_addActionLocaleFormFields! form.java_addAccessors! #ajouter getter/setter form.apaCom_addLogger! end |
#struts_addActionFormAttribute!(form) ⇒ Object
175 176 177 178 179 180 |
# File 'lib/ontomde-uml2-struts/form.rb', line 175 def struts_addActionFormAttribute!(form) struts_formAttribute.each { |a| a.struts_addActionFormAttribute!(form) } #struts_addDateFormater!(form) end |
#struts_addActionLocaleFormFields! ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/ontomde-uml2-struts/localeAction.rb', line 75 def struts_addActionLocaleFormFields! form=self [STRUTS_SETSKIN_FIELD,STRUTS_SETTIMEZONE_FIELD,STRUTS_SETLOCALE_LANGUAGE_FIELD,STRUTS_SETCOUNTRY_FIELD].each { |an| ems=form.umlx_createAndAddProperty(form.rdf_uri+an,an); ems.uml_type=form.umlx_dataType_string ems.uml_upperValue=form.umlx_literal(1) ems.uml_lowerValue=form.umlx_literal(0) #ems.uml_isStatic=RDF_TRUE ems.db_isTransient=RDF_TRUE ems.uml_visibility=::Cuml_VisibilityKind::Public #form.java_addGlobalSetter!(ems) #g=form.java_addGlobalGetter!(ems) } end |
#struts_addBusinessMethods!(action) ⇒ Object
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 |
# File 'lib/ontomde-uml2-struts/action.rb', line 409 def struts_addBusinessMethods!(action) umlx_ownedAndInheritedOperation.each { |op| # private and protected methods are not published next if op.uml_visibility_one.isPrivate? next if op.uml_isAbstract? next if op.uml_visibility_one.isProtected? next unless op.umlx_businessMethod? next if op.struts_bizOperationReverse.empty? biz=action.struts_createAndAddExecuteOperation("#{op.java_Name}") biz.java_code=<<ENDCODE #{struts_formCastJavaCode} form.copyToReference(); form.setReference(form.getReference().merge()); #{op.struts_bizOperationReverse_one.java_qualifiedName} newElt=new #{op.struts_bizOperationReverse_one.java_qualifiedName}(); newElt.set#{STRUTS_APPLY_TO_PROP}(form.getReference()); return #{struts_getActionHelper.java_qualifiedName}.transferToStartEditAction(mapping,request,newElt,"#{self.java_Name}"); ENDCODE } end |
#struts_addCopyTo! ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/ontomde-uml2-struts/form.rb', line 157 def struts_addCopyTo! #log.debug{ "addCopyTo #{self}" } form=struts_actionForm_one cpt=form.umlx_createAndAddOperation(form.rdf_uri+"_copyTo","copyTo") cpt.java_annotation_add(%{@SuppressWarnings("unused")}) pcpt=cpt.umlx_createAndAddParameter(cpt.rdf_uri+"_to","_to") pcpt.uml_direction=Cuml_ParameterDirectionKind::Inout pcpt.uml_type=self code="java.util.TimeZone currentTimeZone = java.util.TimeZone.getTimeZone(get#{STRUTS_SETTIMEZONE_BEAN}());" struts_formAttribute.each { |a| code=code+"if(this.get#{a.java_NameBean}()!=null) {\n " if(STRUTS_ACCEPT_NULL_FIELD_IN_FORMS) code=code+"#{JavaMapping.instance.getTemplate(a.uml_type_one).getFormCopyTo(a)}" code=code+" }//test !=null\n" if(STRUTS_ACCEPT_NULL_FIELD_IN_FORMS) } cpt.java_code=code end |
#struts_addCreateAction!(action) ⇒ Object
343 344 345 346 347 348 349 350 351 352 353 354 |
# File 'lib/ontomde-uml2-struts/action.rb', line 343 def struts_addCreateAction!(action) create=action.struts_createAndAddExecuteOperation(STRUTS_CREATE_ACTION) #note: persist must be before copyTo create.java_code=<<ENDMETH #{struts_formCastJavaCode} form.copyToReference(); form.setReference(form.getReference().merge()); form.initFromReference(); form.set#{STRUTS_SGBD_STATE_PROP}("#{STRUTS_UPDATE_ACTION}"); return #{STRUTS_RETURN_ACTION}(mapping,form,request,response); ENDMETH end |
#struts_addCreateAndAddActions!(action) ⇒ Object
430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 |
# File 'lib/ontomde-uml2-struts/action.rb', line 430 def struts_addCreateAndAddActions!(action) struts_formAttribute.each { |a| next unless a.umlx_isComposite? if a.umlx_oneSide? struts_addCreateAndAddOneAction!(action,a) else struts_addCreateAndAddManyAction!(action,a) end } struts_formAttribute.each { |a| next if a.umlx_isAttribute? if a.umlx_oneSide? struts_addEditOneAction!(action,a) else struts_addEditManyAction!(action,a) end } end |
#struts_addCreateAndAddManyAction!(action, a) ⇒ Object
452 453 454 |
# File 'lib/ontomde-uml2-struts/action.rb', line 452 def struts_addCreateAndAddManyAction!(action,a) struts_addCreateAndAddOneOrManyAction!(action,a,true) end |
#struts_addCreateAndAddOneAction!(action, a) ⇒ Object
449 450 451 |
# File 'lib/ontomde-uml2-struts/action.rb', line 449 def struts_addCreateAndAddOneAction!(action,a) struts_addCreateAndAddOneOrManyAction!(action,a,false) end |
#struts_addCreateAndAddOneOrManyAction!(action, a, isMany) ⇒ Object
456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 |
# File 'lib/ontomde-uml2-struts/action.rb', line 456 def struts_addCreateAndAddOneOrManyAction!(action,a,isMany) cr=action.struts_createAndAddExecuteOperation("createAndAdd#{a.java_NameBean}") cr.java_code=<<ENDCODE #{struts_formCastJavaCode} /* TPL:0077s*/ #{db_tx_none(%{ form.copyToReference(); #{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}()); form.setReference(form.getReference().merge()); #{a.uml_type_one.java_qualifiedName} newElt=form.getReference().createAndAdd#{a.java_NameBean}(reqType); form.getReference().persist(); return #{struts_getActionHelper.java_qualifiedName}.transferToStartEditAction(mapping,request,newElt,"#{self.java_Name}"); })} ENDCODE end |
#struts_addDeleteAction!(action) ⇒ Object
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 |
# File 'lib/ontomde-uml2-struts/action.rb', line 392 def struts_addDeleteAction!(action) update=action.struts_createAndAddExecuteOperation(STRUTS_DELETE_ACTION) if false #java_DAOClass.empty? update.java_code=<<ENDMETH throw new RuntimeException("method #{update.java_Name} is only available for persistent elements"); ENDMETH else update.java_code= <<ENDCODE #{struts_formCastJavaCode} form.copyToReference(); form.set#{STRUTS_SGBD_STATE_PROP}("#{STRUTS_NEW_ACTION}"); form.initFromReference(); return #{STRUTS_RETURN_ACTION}(mapping,form,request,response); ENDCODE end end |
#struts_addEditManyAction!(action, a) ⇒ Object
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 |
# File 'lib/ontomde-uml2-struts/action.rb', line 472 def struts_addEditManyAction!(action,a) cr=action.struts_createAndAddExecuteOperation("edit#{a.java_NameBean}") e=struts_getFunctionalException cr.java_code= <<ENDCODE #{struts_formCastJavaCode} #{%{ long referenceId = form.getReference().getId(); #{self.java_qualifiedName} reference = #{self.java_qualifiedName}.find(referenceId); form.setReference(reference); } unless java_DAOClass.empty? } form.copyToReference(); String sid=request.getParameter("#{STRUTS_REQUESTED_TAB}"); long id=Long.parseLong(sid); #{a.uml_type_one.java_qualifiedName} elt=null; { java.util.Iterator<?> iter=form.getReference().get#{a.java_NameBean}().iterator(); while(iter.hasNext()) { elt=(#{a.uml_type_one.java_qualifiedName})iter.next(); if (elt.getId()!=id) continue; break; } #{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"); #{struts_getActionHelper.java_qualifiedName}.checkNotNull(elt,exceptionToFire); } return #{struts_getActionHelper.java_qualifiedName}.transferToStartEditAction(mapping,request,elt,"#{self.java_Name}"); ENDCODE end |
#struts_addEditOneAction!(action, a) ⇒ Object
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 |
# File 'lib/ontomde-uml2-struts/action.rb', line 504 def struts_addEditOneAction!(action,a) cr=action.struts_createAndAddExecuteOperation("edit#{a.java_NameBean}") e=struts_getFunctionalException cr.java_code= <<ENDCODE #{struts_formCastJavaCode} #{%{ long referenceId = form.getReference().getId(); #{self.java_qualifiedName} reference = #{self.java_qualifiedName}.find(referenceId); form.setReference(reference); } unless java_DAOClass.empty?} form.copyToReference(); //form.setReference(form.getReference().merge()); #{a.uml_type_one.java_qualifiedName} elt=form.getReference().get#{a.java_NameBean}(); #{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"); #{struts_getActionHelper.java_qualifiedName}.checkNotNull(elt,exceptionToFire); return #{struts_getActionHelper.java_qualifiedName}.transferToStartEditAction(mapping,request,elt,"#{self.java_Name}"); ENDCODE end |
#struts_addFieldMethods!(action) ⇒ Object
667 668 669 670 671 672 673 |
# File 'lib/ontomde-uml2-struts/action.rb', line 667 def struts_addFieldMethods!(action) form=struts_actionForm_one uml_ownedAttribute.each {|a| tpl=JavaMapping.instance.getTemplate(a.uml_type_one) tpl.addActionFieldMethod!(a,action,form) } end |
#struts_addInitAndCopyToReference! ⇒ Object
95 96 97 98 99 100 101 |
# File 'lib/ontomde-uml2-struts/form.rb', line 95 def struts_addInitAndCopyToReference! i=umlx_createAndAddOperation(rdf_uri+"initFromReference","initFromReference"); i.java_code="initFrom(getReference());" c=umlx_createAndAddOperation(rdf_uri+"copyToReference","copyToReference"); c.java_code="copyTo(getReference());" end |
#struts_addInitFrom! ⇒ Object
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/ontomde-uml2-struts/form.rb', line 193 def struts_addInitFrom! form=struts_actionForm_one inf=form.umlx_createAndAddOperation(form.rdf_uri+"_initFrom","initFrom") inf.java_annotation_add(%{@SuppressWarnings("unused")}) pinf=inf.umlx_createAndAddParameter(inf.rdf_uri+"_from","_from") pinf.uml_type=self pinf.uml_direction=Cuml_ParameterDirectionKind::In code="java.util.TimeZone currentTimeZone = java.util.TimeZone.getTimeZone(get#{STRUTS_SETTIMEZONE_BEAN}());\n" struts_formAttribute.each { |a| code=code+"#{JavaMapping.instance.getTemplate(a.uml_type_one).getFormInitFrom(a)}" } inf.java_code=code end |
#struts_addNewAction!(action) ⇒ Object
311 312 313 314 315 316 317 |
# File 'lib/ontomde-uml2-struts/action.rb', line 311 def struts_addNewAction!(action) if uml_isAbstract? || kind_of?(Muml_Interface) struts_addNewActionNotAvailable!(action) else struts_addNewActionAvailable!(action) end end |
#struts_addNewActionAvailable!(action) ⇒ Object
327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
# File 'lib/ontomde-uml2-struts/action.rb', line 327 def struts_addNewActionAvailable!(action) create=action.struts_createAndAddExecuteOperation(STRUTS_NEW_ACTION) create.java_code= <<ENDMETH // Creates a new transient object instance and forwards to an edit page. #{struts_formCastJavaCode} form.setReference(new #{java_qualifiedName}()); #{%{ form.getReference().initData();\nform.getReference().persist(); } if self.java_isATestFile? } form.initFromReference(); //form.getReference().persist(); form.set#{STRUTS_SGBD_STATE_PROP}("#{STRUTS_CREATE_ACTION}"); #{java_debug(%{"STATE="+form.get#{STRUTS_SGBD_STATE_PROP}()})} return mapping.findForward("#{STRUTS_INPUT_FWD}"); ENDMETH end |
#struts_addNewActionNotAvailable!(action) ⇒ Object
319 320 321 322 323 324 |
# File 'lib/ontomde-uml2-struts/action.rb', line 319 def struts_addNewActionNotAvailable!(action) create=action.struts_createAndAddExecuteOperation(STRUTS_NEW_ACTION) create.java_code=%{ throw new java.lang.RuntimeException("new not available for abstract class #{self.java_qualifiedName}"); } end |
#struts_addNewBizAction!(action) ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/ontomde-uml2-struts/action.rb', line 105 def struts_addNewBizAction!(action) create=action.struts_createAndAddExecuteOperation(STRUTS_NEW_ACTION) create.java_code=<<ENDMETH #{struts_formCastJavaCode} /* TPL: ACTION-001 */ form.setReference(new #{java_qualifiedName}()); form.initFromReference(); form.set#{STRUTS_DISPATCH_FIELD_METH}("#{STRUTS_CREATE_ACTION}"); return mapping.findForward("#{STRUTS_INPUT_FWD}"); ENDMETH end |
#struts_addOneOrManyAction!(action, a) ⇒ Object
541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 |
# File 'lib/ontomde-uml2-struts/action.rb', line 541 def struts_addOneOrManyAction!(action,a) return if a.uml_isReadOnly? meth=action.struts_createAndAddExecuteOperation("add#{a.java_NameBean}") if false #java_DAOClass.empty? meth.java_code=<<ENDMETH throw new RuntimeException("method #{meth.java_Name} is only available for persistent elements"); ENDMETH else meth.java_code= <<ENDMETH /* TPL: ACTION-004 */ #{struts_formCastJavaCode} String sid=request.getParameter("#{STRUTS_REQUESTED_TAB}"); long id=Long.parseLong(sid); form.copyToReference(); form.setReference(form.getReference().merge()); #{struts_findElt(a,true)} if(elt!=null) { form.getReference().#{a.umlx_oneSide? ? "set":"add"}#{a.java_NameBean}(elt); //TODO: delete element } form.initFromReference(); return mapping.findForward("#{STRUTS_INPUT_FWD}"); ENDMETH end end |
#struts_addProceedAction!(action) ⇒ Object
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
# File 'lib/ontomde-uml2-struts/action.rb', line 255 def struts_addProceedAction!(action) proca=action.struts_createAndAddExecuteOperation(STRUTS_PROCEED_ACTION) j=%{ #{struts_formCastJavaCode} String s=form.get#{STRUTS_SGBD_STATE_PROP}(); } [STRUTS_NEW_ACTION,STRUTS_CREATE_ACTION,STRUTS_UPDATE_ACTION,STRUTS_READ_ACTION,STRUTS_DELETE_ACTION].each {|m| j=j+%{if(s.compareTo("#{m}")==0) { return #{m}(mapping,form,request,response); }\n} } j=j+%{ String msg="unexpected value for #{STRUTS_SGBD_STATE_PROP} in #{STRUTS_PROCEED_ACTION}"; log.error(msg); org.apache.struts.action.ActionErrors ae=new org.apache.struts.action.ActionErrors(); ae.add("Error processing request",new org.apache.struts.action.ActionMessage("errors.ioException",msg)); saveErrors(request, ae); return mapping.findForward("#{STRUTS_INPUT_FWD}"); } proca.java_code=j end |
#struts_addProceedBizAction!(action) ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/ontomde-uml2-struts/action.rb', line 117 def struts_addProceedBizAction!(action) proceed=action.struts_createAndAddExecuteOperation(STRUTS_PROCEED_ACTION) proceed.java_code=<<ENDMETH #{struts_formCastJavaCode} form.copyToReference(); form.getReference().proceed(); form.initFromReference(); form.set#{STRUTS_DISPATCH_FIELD_METH}("#{STRUTS_CREATE_ACTION}"); return new org.apache.struts.action.ActionForward("/pages/#{java_InternalFilePath}form/#{java_Name}#{STRUTS_RESULTS_FWD}.jsp",false); ENDMETH end |
#struts_addReadAction!(action) ⇒ Object
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 |
# File 'lib/ontomde-uml2-struts/action.rb', line 356 def struts_addReadAction!(action) update=action.struts_createAndAddExecuteOperation(STRUTS_READ_ACTION) if java_DAOClass.empty? update.java_code=<<ENDMETH throw new RuntimeException("method #{update.java_Name} is only available for persistent elements"); ENDMETH else update.java_code=<<ENDMETH //loads object from database using id and forwards to edit page #{struts_formCastJavaCode} form.setReference(#{java_DAOClass_one.java_qualifiedName}.find(Long.parseLong(form.getId()))); form.initFromReference(); form.set#{STRUTS_SGBD_STATE_PROP}("#{STRUTS_UPDATE_ACTION}"); return mapping.findForward("#{STRUTS_INPUT_FWD}"); ENDMETH end end |
#struts_addRefreshAction!(action) ⇒ Object
652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 |
# File 'lib/ontomde-uml2-struts/action.rb', line 652 def struts_addRefreshAction!(action) meth=action.struts_createAndAddExecuteOperation(STRUTS_REFRESH_ACTION) meth.java_code=<<ENDMETH #{struts_formCastJavaCode} String z=request.getParameter("#{STRUTS_REQUESTED_TAB}"); #{STRUTS_ACTION_FORWARD} am=mapping.findForward(z); form.copyToReference(); form.setReference(form.getReference().merge()); if(am==null) { #{java_error(%{"ActionMapping not found for '"+z+"'"})} return mapping.findForward("#{STRUTS_INPUT_FWD}"); } return am; ENDMETH end |
#struts_addRemoveAndDeleteActions!(action) ⇒ Object
527 528 529 530 531 532 533 534 535 536 537 538 539 |
# File 'lib/ontomde-uml2-struts/action.rb', line 527 def struts_addRemoveAndDeleteActions!(action) struts_formAttribute.each { |a| #next unless a.umlx_isComposite? #next unless a.umlx_isAssociation? next if a.umlx_isAttribute? if a.umlx_oneSide? struts_addRemoveAndDeleteOneAction!(action,a) else struts_addRemoveAndDeleteManyAction!(action,a) end struts_addOneOrManyAction!(action,a) } end |
#struts_addRemoveAndDeleteManyAction!(action, a) ⇒ Object
608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 |
# File 'lib/ontomde-uml2-struts/action.rb', line 608 def struts_addRemoveAndDeleteManyAction!(action,a) return if a.uml_isReadOnly? del=action.struts_createAndAddExecuteOperation("removeAndDelete#{a.java_NameBean}") del.java_code= <<ENDJCODE #{struts_formCastJavaCode} #{db_tx_none(%{ String sid=request.getParameter("#{STRUTS_REQUESTED_TAB}"); long id=Long.parseLong(sid); form.copyToReference(); form.setReference(form.getReference().merge()); #{struts_findElt(a)} if(elt!=null) { form.getReference().remove#{a.java_NameBean}(elt); //TODO: delete element } form.initFromReference(); })} return mapping.findForward("#{STRUTS_INPUT_FWD}"); ENDJCODE end |
#struts_addRemoveAndDeleteOneAction!(action, a) ⇒ Object
568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 |
# File 'lib/ontomde-uml2-struts/action.rb', line 568 def struts_addRemoveAndDeleteOneAction!(action,a) return if a.uml_isReadOnly? del=action.struts_createAndAddExecuteOperation("removeAndDelete#{a.java_NameBean}") del.java_code= <<END_DEL_CODE #{struts_formCastJavaCode} #{db_tx_none(%{ //String sid=request.getParameter("#{STRUTS_REQUESTED_TAB}"); //long id=Long.parseLong(sid); //#{a.uml_type_one.java_qualifiedName} elt=null; form.copyToReference(); form.setReference(form.getReference().merge()); form.getReference().set#{a.java_NameBean}(null); //TODO: delete element form.initFromReference(); })} return mapping.findForward("#{STRUTS_INPUT_FWD}"); END_DEL_CODE end |
#struts_addReset! ⇒ Object
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/ontomde-uml2-struts/form.rb', line 210 def struts_addReset! form=struts_actionForm_one o=form.umlx_createAndAddOperation(form.rdf_uri+"_reset","reset") o.java_annotation_add("@Override") o.java_code= <<END // if the time zone is not set yet in the session // we set the default value ("Europe/Paris") else // we get the timezone saved in the user session. this.set#{Muml_Classifier::STRUTS_SETTIMEZONE_BEAN}(xmda.tags.helpers.XMDARequestUtils.getUserTimeZone(request, null).getID()); END p=o.umlx_createAndAddParameter(o.rdf_uri+"_mapping","mapping") p.uml_type=o.umlx_getOrCreateClass("org.apache.struts.action.ActionMapping") p=o.umlx_createAndAddParameter(o.rdf_uri+"_request","request") p.uml_type=o.umlx_getOrCreateClass("javax.servlet.http.HttpServletRequest") end |
#struts_addResumeAction!(action) ⇒ Object
296 297 298 299 300 301 302 303 304 305 306 307 308 309 |
# File 'lib/ontomde-uml2-struts/action.rb', line 296 def struts_addResumeAction!(action) resume=action.struts_createAndAddExecuteOperation(STRUTS_RESUME_ACTION) resume.java_code=<<ENDRESCODE #{struts_formCastJavaCode} #{%{ long referenceId = form.getReference().getId(); #{self.java_qualifiedName} reference = #{self.java_qualifiedName}.find(referenceId); form.setReference(reference); } unless java_DAOClass.empty? } form.setSgbd_state("#{STRUTS_UPDATE_ACTION}"); form.initFromReference(); return mapping.findForward("#{STRUTS_INPUT_FWD}"); ENDRESCODE end |
#struts_addReturnAction!(action) ⇒ Object
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
# File 'lib/ontomde-uml2-struts/action.rb', line 276 def struts_addReturnAction!(action) reta=action.struts_createAndAddExecuteOperation(STRUTS_RETURN_ACTION) reta.java_code=%{ #{struts_formCastJavaCode} javax.servlet.http.HttpSession session=request.getSession(); String key=form.getReference().getClass().getName()+"_returnTo"; String url=(String)session.getAttribute(key); session.removeAttribute(key); if(url==null) { // loop on self when reach top of returnTo stack. return mapping.findForward("#{STRUTS_INPUT_FWD}"); } //external redirect is not supported nor desired when FLEX. // FLEX: redirect = false , not FLEX: redirected= true boolean redirect = request.getParameter("FLEX")==null ; return new org.apache.struts.action.ActionForward(url,redirect); } end |
#struts_addsetLocaleAction!(action) ⇒ Object
TODO cpt.java_code=
695 696 697 698 699 700 701 702 703 |
# File 'lib/ontomde-uml2-struts/action.rb', line 695 def struts_addsetLocaleAction!(action) mpc=self cpt=action.struts_createAndAddExecuteOperation(STRUTS_SETLOCALE_ACTION) cpt.java_code=%{ #{struts_formCastJavaCode} form.copyToReference(); return #{struts_getActionHelper.java_qualifiedName}.changeLocaleAction(mapping,getLocale(request),request,form.getStrutsLanguage(),form.getStrutsCountry()); } end |
#struts_addsetSkinAction!(action) ⇒ Object
690 691 692 693 694 |
# File 'lib/ontomde-uml2-struts/action.rb', line 690 def struts_addsetSkinAction!(action) mpc=self cpt=action.struts_createAndAddExecuteOperation(STRUTS_SETSKIN_ACTION) #TODO cpt.java_code= end |
#struts_addsetTimeZoneAction!(action) ⇒ Object
678 679 680 681 682 683 684 685 686 687 688 689 |
# File 'lib/ontomde-uml2-struts/action.rb', line 678 def struts_addsetTimeZoneAction!(action) mpc=self cpt=action.struts_createAndAddExecuteOperation(STRUTS_SETTIMEZONE_ACTION) cpt.java_code=<<ENDCODE #{struts_formCastJavaCode} //form.copyToReference(); String newTimeZoneId = form.getStruts_tz(); #{struts_getActionHelper.java_qualifiedName}.changeTimeZoneAction_s1(form,mapping,request, newTimeZoneId); form.setReference(form.getReference().merge()); return #{struts_getActionHelper.java_qualifiedName}.changeTimeZoneAction_s2(form,mapping,request, newTimeZoneId); ENDCODE end |
#struts_addStartEditAction!(action) ⇒ Object
131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/ontomde-uml2-struts/action.rb', line 131 def struts_addStartEditAction!(action) edit=action.struts_createAndAddExecuteOperation(STRUTS_ACTION_STARTEDIT) edit.java_code= <<ENDCODE #{struts_formCastJavaCode} javax.servlet.http.HttpSession session=request.getSession(); #{self.java_qualifiedName} obj=(#{self.java_qualifiedName}) session.getAttribute("#{STRUTS_SESSION_KEY_EditAction}"); session.removeAttribute("#{STRUTS_SESSION_KEY_EditAction}"); form.setReference(obj); form.initFromReference(); form.setSgbd_state("#{STRUTS_UPDATE_ACTION}"); return mapping.findForward("#{STRUTS_INPUT_FWD}"); ENDCODE end |
#struts_addSwitchToFlexAction!(action) ⇒ Object
631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 |
# File 'lib/ontomde-uml2-struts/action.rb', line 631 def struts_addSwitchToFlexAction!(action) return unless context[:generateXMLStrutsForm] create=action.struts_createAndAddExecuteOperation(::Muml_Class::STRUTS_SWITH_TO_FLEX_ACTION) create.java_code= <<JCODE #{struts_formCastJavaCode} String z="#{Muml_Class::STRUTS_SWITCH_TO_FLEX_FORWARD}"; #{STRUTS_ACTION_FORWARD} am=mapping.findForward(z); #{db_tx_none(%{ form.copyToReference(); form.setReference(form.getReference().merge()); if(am==null) { #{java_error(%{"ActionMapping not found for '"+z+"'"})} return mapping.findForward("#{STRUTS_INPUT_FWD}"); } })} request.getSession().setAttribute("flex_action",request.getRequestURI()); request.getSession().setAttribute("flex_locale",getLocale(request).getLanguage()); return am; JCODE end |
#struts_addTabAll!(action) ⇒ Object
adds a tab with all attributes
238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/ontomde-uml2-struts/action.rb', line 238 def struts_addTabAll!(action) t=Cstruts_tab.new(rdf_model,self.rdf_uri+"_taball") t.java_Name="all" self.struts_ownedTab_add(t); cgi=umlx_classifier_generalization_indirect cgi.add(self) cgi.each { |c| c.uml_ownedAttribute.each { |a| next if a.struts_ignoreInForm? next if a.java_Name==STRUTS_RESULT_PARAM_NAME t.struts_ownedAttribute_add(a) } } end |
#struts_addTabFromInterface!(action) ⇒ Object
222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'lib/ontomde-uml2-struts/action.rb', line 222 def struts_addTabFromInterface!(action) return if kind_of?(Muml_Interface) uml_implementation.each {|imp| ie=imp.uml_supplier_one next if ie.java_ignoreMe? t=Cstruts_tab.new(rdf_model,self.rdf_uri+"_tab_"+ie.rdf_uri) self.struts_ownedTab_add(t); t.java_Name=ie.java_Name ie.uml_ownedAttribute.each { |a| next if a.struts_ignoreInForm? t.struts_ownedAttribute_add(a) } } end |
#struts_addTabReturnParameter!(action) ⇒ Object
209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/ontomde-uml2-struts/action.rb', line 209 def struts_addTabReturnParameter!(action) t=Cstruts_tab.new(rdf_model,self.rdf_uri+"_tab_return") self.struts_ownedTab_add(t); t.java_Name=STRUTS_RESULTS_FWD self.uml_ownedAttribute.each { |a| next if a.struts_ignoreInForm? next unless a.java_Name==STRUTS_RESULT_PARAM_NAME #next unless a.struts_sourceProperty_one.uml_direction_one.isReturn? t.struts_ownedAttribute_add(a); break # there can be only one return parameter } end |
#struts_addTabs!(action) ⇒ Object
199 200 201 202 |
# File 'lib/ontomde-uml2-struts/action.rb', line 199 def struts_addTabs!(action) struts_addTabFromInterface!(action) struts_addTabAll!(action) end |
#struts_addTabsBiz!(action) ⇒ Object
203 204 205 206 207 |
# File 'lib/ontomde-uml2-struts/action.rb', line 203 def struts_addTabsBiz!(action) struts_addTabFromInterface!(action) struts_addTabAll!(action) struts_addTabReturnParameter!(action) end |
#struts_addUpdateAction!(action) ⇒ Object
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 |
# File 'lib/ontomde-uml2-struts/action.rb', line 374 def struts_addUpdateAction!(action) update=action.struts_createAndAddExecuteOperation(STRUTS_UPDATE_ACTION) if false #java_DAOClass.empty? update.java_code=<<ENDMETH throw new RuntimeException("method #{update.java_Name} is only available for persistent elements"); ENDMETH else update.java_code=<<ENDMETH //update persistent object from html form. #{struts_formCastJavaCode} form.copyToReference(); form.setReference(form.getReference().merge()); form.set#{STRUTS_SGBD_STATE_PROP}("#{STRUTS_UPDATE_ACTION}"); form.initFromReference(); return #{STRUTS_RETURN_ACTION}(mapping,form,request,response); ENDMETH end end |
#struts_createAndAddActionBase! ⇒ Object
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/ontomde-uml2-struts/action.rb', line 145 def struts_createAndAddActionBase! p=umlx_owner_one p=p.umlx_getOrCreatePackage(context[:strutsActionPackage,context[:strutsActionFormPackage,"struts"]],p) action=p.umlx_createAndAddClass(rdf_uri+"_Action") action.db_isTransient=RDF_TRUE action.struts_actionSrc=self self.struts_action=action action.uml_name="#{uml_name}StrutsAction" #af=action.umlx_getOrCreateClass("org.apache.struts.action.Action") af=action.umlx_getOrCreateClass("org.apache.struts.actions.DispatchAction") action.umlx_createAndAddGeneralization(af) action.apaCom_addLogger! #all=action.umlx_createAndAddProperty("#{action.rdf_uri}FORWARD","FORWARD"); #mtk_context(:struts_tab=> struts_defaultTabId ){ # all.java_code=%{"/#{struts_jsp_edit_path}"} # } # all.uml_isStatic=RDF_TRUE; # all.uml_type=uml_type=umlx_dataType_string return action end |
#struts_createAndAddExecuteOperation(name) ⇒ Object
Creates an add a struts “execute” method of an action bean Names needs not be “execute” thanks to struts dispatch feature.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/ontomde-uml2-struts/action.rb', line 35 def struts_createAndAddExecuteOperation(name) action=self afo=action.umlx_createAndAddOperation(action.rdf_uri+"_"+name,name) p=afo.umlx_createAndAddParameter(afo.rdf_uri+"_to","mapping") p.uml_type=umlx_getOrCreateClass(STRUTS_ACTION_MAPPING) p=afo.umlx_createAndAddParameter(afo.rdf_uri+"_form","abstractForm") p.uml_type=umlx_getOrCreateClass("org.apache.struts.action.ActionForm") p=afo.umlx_createAndAddParameter(afo.rdf_uri+"_request","request") p.uml_type=umlx_getOrCreateClass("javax.servlet.http.HttpServletRequest") p=afo.umlx_createAndAddParameter(afo.rdf_uri+"_response","response") p.uml_type=umlx_getOrCreateClass("javax.servlet.http.HttpServletResponse") p=afo.umlx_createAndAddReturnParameter(afo.rdf_uri+"_return","return") p.uml_type=umlx_getOrCreateClass("org.apache.struts.action.ActionForward") return afo end |
#struts_eachFormAttribute_deprec ⇒ Object
43 44 45 46 47 |
# File 'lib/ontomde-uml2-struts/form.rb', line 43 def struts_eachFormAttribute_deprec() struts_formAttribute.each { |a| yield(a) } end |
#struts_edit_writeField(field, owner) ⇒ Object
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 |
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 479 def struts_edit_writeField(field,owner) if field.nil? log.error { "nil field in #{self}" } return end os=field.umlx_oneSide? ic=field.umlx_isComposite? if os && !ic # OAS (Object Association Single) struts_edit_writeFieldOne(field,owner) elsif (!os) && (!ic) # OAM (Object Association Multiple) struts_edit_writeFieldMany(field,owner) elsif os && ic # OCS (Object Composition Single) struts_edit_writeFieldOneCompo(field,owner) elsif (!os) && ic # OCM (Object Composition Multiple) struts_edit_writeFieldManyCompo(field,owner) end end |
#struts_edit_writeFieldCompo(field, owner, isMany) ⇒ Object
538 539 540 |
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 538 def struts_edit_writeFieldCompo(field,owner,isMany) struts_edit_writeFieldGeneric(field,owner,isMany,true) end |
#struts_edit_writeFieldGeneric(field, owner, isMany, isCompo) ⇒ Object
626 627 628 629 630 631 632 |
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 626 def struts_edit_writeFieldGeneric(field,owner,isMany,isCompo) #adds create and add section struts_edit_writeFieldGenericIsCompo(field,owner,isMany,isCompo) #adds table displaying already selected elements struts_edit_writeFieldGeneric_DisplayTable(field,owner,isMany,isCompo) end |
#struts_edit_writeFieldGeneric_DisplayTable(field, owner, isMany, isCompo) ⇒ Object
634 635 636 637 638 639 640 641 642 643 |
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 634 def struts_edit_writeFieldGeneric_DisplayTable(field,owner,isMany,isCompo) elt="elt_#{field.java_Name}" struts_encloseWrite(%{<logic:notEmpty name="#{owner.java_Name}StrutsForm" property="reference.#{field.java_Name}">\n},'</logic:notEmpty>') { if field.context[:jspUseXmdaTaglib] struts_edit_writeFieldGeneric_DisplayTable_displayTag(field,owner,isMany,isCompo) else struts_edit_writeFieldGeneric_DisplayTable_strutsOnly(field,owner,isMany,isCompo) end } end |
#struts_edit_writeFieldGeneric_DisplayTable_displayTag(field, owner, isMany, isCompo) ⇒ Object
645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 |
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 645 def struts_edit_writeFieldGeneric_DisplayTable_displayTag(field,owner,isMany,isCompo) elt="elt_#{field.java_Name}" struts_encloseWrite(%{ <div class="blockScroll"> <%-- You can specify the column to sort by adding sortable="true" By default this is the first column --%> <display:table id="#{elt}" name="sessionScope.#{owner.java_Name}StrutsForm.reference.#{field.java_Name}" defaultorder="descending" defaultsort="1" class="CWTable"> <display:column class='action'> <a onclick='removeAndDelete#{field.java_NameBean}("<c:out value="${#{elt}.id}"/>");return false;' > <img src="#{css_path_model}/#{css_color_class}/image/btnDelete.gif" alt="" border="0" height="16" width="16"/> </a> </display:column> <display:column class='action'> <a onclick='edit#{field.java_NameBean}("<c:out value="${#{elt}.id}"/>");return false;' > <img src="#{css_path_model}/#{css_color_class}/image/btnCreate.gif" alt="" border="0" height="16" width="16"/> </a> </display:column> }, %{</display:table>\n </div> }) { field.uml_type_one.struts_formAttribute.each { |a| next if a.uml_name_one=="id" next if a.uml_name_one=="owner" t=a.uml_type_one next unless a.uml_type_one.kind_of?(Muml_Enumeration) || a.uml_type_one.kind_of?(Muml_DataType) tpl=JavaMapping.instance.getTemplate(t) tpl.struts_edit_writeFieldGeneric_DisplayTable_displayTag_column(a) } } end |
#struts_edit_writeFieldGeneric_DisplayTable_strutsOnly(field, owner, isMany, isCompo) ⇒ Object
680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 |
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 680 def struts_edit_writeFieldGeneric_DisplayTable_strutsOnly(field,owner,isMany,isCompo) struts_encloseWrite( %{ <table class="proprietes"><%-- T:1006 --%> <thead><tr> #{field.uml_isReadOnly? ? "" : "<th> </th>"} <th> </th> }, %{</table>\n}) { field.uml_type_one.struts_formAttribute.each { |a| next if a.uml_name_one=="id" next if a.uml_name_one=="owner" next unless a.uml_type_one.kind_of?(Muml_Enumeration) || a.uml_type_one.kind_of?(Muml_DataType) write(%{<th><b>#{struts_writeMsg("#{a.umlx_owner_one.java_qualifiedName}.#{a.java_Name}")}</b></th>\n}) } write %{</tr></thead>\n} before=isMany ? %{<logic:iterate id="#{elt}" name="#{owner.java_Name}StrutsForm" property="reference.#{field.java_Name}" >\n} : %{<bean:define id="#{elt}" name="#{owner.java_Name}StrutsForm" property="reference.#{field.java_Name}" />\n} after=isMany ? '</logic:iterate>' : '</bean>' struts_encloseWrite(before,after) { write %{<tr>} write %{<td class='action'><a onclick='removeAndDelete#{field.java_NameBean}("<bean:write name="#{elt}" property="id"/>");return false;'/>#{isCompo ? "[D]" : "[R]"}</a></td>\n} unless field.uml_isReadOnly? write %{<td class='action'><a onclick='edit#{field.java_NameBean}("<bean:write name="#{elt}" property="id"/>");return false;'/>[E]</a></td>\n} field.uml_type_one.struts_formAttribute.each { |a| next if a.uml_name_one=="id" next if a.uml_name_one=="owner" next unless a.uml_type_one.kind_of?(Muml_Enumeration) || a.uml_type_one.kind_of?(Muml_DataType) if(a.uml_type_one.kind_of?(Muml_Enumeration)) write(%{ <td class='action'> <%-- enum:TODO localize (use ressource) --%> <bean:write name="#{elt}" property="#{a.java_Name}"/> </td> }) else write(%{ <td class='action'> <bean:write name="#{elt}" property="#{a.java_Name}"/> </td> }) end } write %{</tr>\n} } } end |
#struts_edit_writeFieldGenericIsCompo(field, owner, isMany, isCompo) ⇒ Object
542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 |
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 542 def struts_edit_writeFieldGenericIsCompo(field,owner,isMany,isCompo) return unless isCompo before="" after="" if !isMany # only display creater if adding one more is ok. before=%{<logic:empty name="#{owner.java_Name}StrutsForm" property="reference.#{field.java_Name}">\n} after=%{</logic:empty>\n} end struts_encloseWrite( before,after) { if context[:jspUseXmdaTaglib] write <<END <div style=' width:400px; overflow:left; display: none; ' class="dialog" id="Popup#{field.java_NameBean}"> <div class="alphacube_close" onclick="javascript:show_sel('#{field.java_Name}_createAndAdd');document.getElementById('Popup#{field.java_NameBean}').style.display='none';document.getElementById('add#{field.java_NameBean}').style.display='block';"> </div> <table class="top table_window"> <tbody> <tr> <td class="alphacube_nw"> </td> <td class="alphacube_n"> <div class="alphacube_title title_window top_draggable"> #{struts_writeMsg("#{field.umlx_owner_one.java_qualifiedName}.#{field.java_Name}")}</div></td> <td class="alphacube_ne"> </td> </tr> </tbody> </table> <table class="mid table_window"> <tbody> <tr> <td class="alphacube_w"></td> <td class="alphacube_content" valign="top"> <div class="alphacube_content"> <center><br/> <select name="#{field.java_Name}_createAndAdd" onchange="createAndAdd#{field.java_NameBean}(options[selectedIndex].value);return false;" id="#{field.java_Name}_createAndAdd"> <xmda:i18noptionsCollection name="#{owner.java_Name}StrutsForm" property="createAndAdd#{field.java_NameBean}Sug" /> </select> </center><br/> </div></td> <td class="alphacube_e"></td> </tr> </tbody> </table> <table class="bot table_window"> <tbody> <tr> <td class="alphacube_sw"> </td> <td class="alphacube_s"><div class="status_bar bottom_draggable"> </div></td> <td class="alphacube_sizer" > </td> </tr> </tbody> </table> </div> <div style="color:#FF5400;background-color:#FAFCEB;" id='add#{field.java_NameBean}'> <a onClick="javascript:hide_sel('#{field.java_Name}_createAndAdd');document.getElementById('Popup#{field.java_NameBean}').style.display='block';document.getElementById('add#{field.java_NameBean}').style.display='none';" > <img src="res//orange/image/plus.gif" alt="Add" border="0" /> </a> <bean:message key="label.helper.none"/> </div> END else write %{ <%-- begin TPL:1006 --%> <select name="#{field.java_Name}_createAndAdd" onchange="createAndAdd#{field.java_NameBean}(options[selectedIndex].value);return false;"> <logic:iterate id="_#{field.java_Name}" name="#{owner.java_Name}StrutsForm" property="createAndAdd#{field.java_NameBean}Sug" > <option value="<bean:write name="_#{field.java_Name}" property="value" />" > <bean:define id="_id"> <bean:write name="_#{field.java_Name}" property="label" /> </bean:define> <%-- TODO: eviter entrelacement balises XML --%> <bean:message key="<%= _id %>"/> </option> </logic:iterate> </select> <SCRIPT> <%-- TODO : supprimer javascript --%> document.forms[0].#{field.java_Name}_createAndAdd.value="#{::Muml_Property::NIL_LVB_KEY}"; </SCRIPT> <%-- end TPL:1006 --%> } end } end |
#struts_edit_writeFieldMany(field, owner) ⇒ Object
500 501 502 503 |
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 500 def struts_edit_writeFieldMany(field,owner) struts_edit_writeFieldGeneric(field,owner,true,false) struts_edit_writeSelectAndAdd(field,owner) end |
#struts_edit_writeFieldManyCompo(field, owner) ⇒ Object
531 532 533 |
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 531 def struts_edit_writeFieldManyCompo(field,owner) struts_edit_writeFieldCompo(field,owner,true) end |
#struts_edit_writeFieldOne(field, owner) ⇒ Object
728 729 730 731 732 733 |
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 728 def struts_edit_writeFieldOne(field,owner) struts_edit_writeFieldGeneric(field,owner,false,false) write %{<logic:empty name="#{owner.java_Name}StrutsForm" property="reference.#{field.java_Name}">\n} struts_edit_writeSelectAndAdd(field,owner) write %{</logic:empty>\n} end |
#struts_edit_writeFieldOneCompo(field, owner) ⇒ Object
534 535 536 |
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 534 def struts_edit_writeFieldOneCompo(field,owner) struts_edit_writeFieldCompo(field,owner,false) end |
#struts_edit_writeSelectAndAdd(field, owner) ⇒ Object
521 522 523 524 525 526 527 528 529 |
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 521 def struts_edit_writeSelectAndAdd(field,owner) return if field.uml_isReadOnly? elt="#{field.java_Name}_add" struts_encloseWrite( %{<select name="#{field.java_Name}_add" onchange="add#{field.java_NameBean}(value);"> \n<option>--</option>\n} ,%{</select>\n}) { struts_encloseWrite( %{<logic:iterate id="#{elt}" name="#{owner.java_Name}StrutsForm" property="reference.#{field.java_Name}Sug" >\n} ,%{</logic:iterate>}) { struts_encloseWrite( %{ <option value="<bean:write name="#{elt}" property="id"/>">\n},%{ </option> \n}) { struts_editWriteSelectAndAddLabel(field,elt) }}} end |
#struts_editWriteSelectAndAddLabel(field, elt, withLabelOnly = true) ⇒ Object
add label use every property stereotpyed Label. if none found, use every field
508 509 510 511 512 513 514 515 516 517 518 519 |
# File 'lib/ontomde-uml2-struts/jsp_edit.rb', line 508 def struts_editWriteSelectAndAddLabel(field,elt,withLabelOnly=true) emptySelection=true field.uml_type_one.struts_formAttribute.each { |a| #next if a.uml_name_one=="id" next if a.uml_name_one=="owner" next if a.uml_type_one.kind_of?(Muml_Class) next if withLabelOnly && !(a.umlx_hasStereotype?("label")) emptySelection=false write %{<bean:write name="#{elt}" property="#{a.java_Name}"/>, } } struts_editWriteSelectAndAddLabel(field,elt,false) if emptySelection && withLabelOnly end |
#struts_findElt(a, findFromSug = false) ⇒ Object
587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 |
# File 'lib/ontomde-uml2-struts/action.rb', line 587 def struts_findElt(a,findFromSug=false) sug=findFromSug ? "Sug" : "" cr=a e=struts_getFunctionalException return <<ENDCODE #{a.uml_type_one.java_qualifiedName} elt=null; { java.util.Iterator<?> iter=form.getReference().get#{a.java_NameBean}#{sug}().iterator(); while(iter.hasNext()) { elt=(#{a.uml_type_one.java_qualifiedName})iter.next(); if(elt.getId()!=id) continue; break; } } #{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"); #{struts_getActionHelper.java_qualifiedName}.checkNotNull(elt,exceptionToFire); ENDCODE end |
#struts_formAttribute(ignoreDbId = false) ⇒ Object
every attribute meant to appear in the form.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/ontomde-uml2-struts/form.rb', line 49 def struts_formAttribute(ignoreDbId=false) #tab=context[:struts_tab,nil] ret=Array.new cgi=umlx_classifier_generalization_indirect cgi.add(self) cgi.each { |c| c.uml_ownedAttribute.each { |a| next if a.struts_ignoreInForm?(ignoreDbId) ret << a } } return ret end |
#struts_formCastJavaCode(action = nil) ⇒ Object
Return java code to be included at the begining of every action execute method. Example: EffectiveFormType form=<EffectiveFormType> abstractForm;
57 58 59 60 61 62 63 |
# File 'lib/ontomde-uml2-struts/action.rb', line 57 def struts_formCastJavaCode(action=nil) action=struts_actionForm_one if action.nil? return <<ENDMETH #{action.java_qualifiedName} form=(#{action.java_qualifiedName})abstractForm; form.set#{STRUTS_DISPATCH_FIELD_METH}(""); ENDMETH end |
#struts_formOperation ⇒ Object
every method meant to appear in the form.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/ontomde-uml2-struts/form.rb', line 67 def struts_formOperation() ret=Array.new cgi=umlx_classifier_generalization_indirect cgi.add(self) cgi.each { |c| c.uml_ownedOperation.each { |a| #next if a.db_isTransient? next if a.uml_isStatic? #next if a.java_ignoreMe? ret << a } } return ret end |
#struts_getFormInterface ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/ontomde-uml2-struts/form.rb', line 82 def struts_getFormInterface iform=umlx_getOrCreateInterface(STRUTS_FORM_INTERFACE) if(iform.uml_ownedOperation.empty?) iform.umlx_external=RDF_FALSE iform.struts_addActionLocaleFormFields! ["initFromReference","copyToReference"].each {|m| iform.umlx_createAndAddOperation(iform.rdf_uri+m,m); } iform.java_addAccessors! #ajouter getter/setter end return iform end |
#struts_typeIsUsed?(type) ⇒ Boolean
182 183 184 185 186 187 188 189 190 191 |
# File 'lib/ontomde-uml2-struts/form.rb', line 182 def struts_typeIsUsed?(type) type=type.downcase struts_formAttribute.each { |a| t=a.uml_type_one next unless t.kind_of?(Muml_Property) next unless t.uml_name_one.downcase==type return true } return false end |