Module: Muml_Class
- Includes:
- DAO
- Defined in:
- lib/ontomde-java/struts/xmlForm.rb,
lib/ontomde-java/jpa/jpa.rb,
lib/ontomde-java/java/xsd.rb,
lib/ontomde-java/flex/main.rb,
lib/ontomde-java/java/java.rb,
lib/ontomde-java/jpa/finder.rb,
lib/ontomde-java/vmware/vso.rb,
lib/ontomde-java/crank/menu2.rb,
lib/ontomde-java/java/apache.rb,
lib/ontomde-java/java/security.rb,
lib/ontomde-java/jpa/redefined.rb,
lib/ontomde-java/struts/footer.rb,
lib/ontomde-java/struts/footer.rb,
lib/ontomde-java/struts/header.rb,
lib/ontomde-java/crank/crankJpa.rb,
lib/ontomde-java/ejb2/main-ejb2.rb,
lib/ontomde-java/java/component.rb,
lib/ontomde-java/struts/jsp_edit.rb,
lib/ontomde-java/flex/Editor.mxml.rb,
lib/ontomde-java/jpa/configuration.rb,
lib/ontomde-java/struts/validation.rb,
lib/ontomde-java/struts/validation.rb,
lib/ontomde-java/flex/ValueObjectAS.rb,
lib/ontomde-java/struts/header_link.rb,
lib/ontomde-java/struts/jsp_edit_js.rb,
lib/ontomde-java/flex/Editor.mxml.as.rb,
lib/ontomde-java/struts/struts-config.rb,
lib/ontomde-java/struts/struts-config.rb,
lib/ontomde-java/java/enumCompatibilityLayer.rb
Overview
xml form
adding methods to generate xml form for use by xml client such as Flex.
Constant Summary collapse
- JPA_TX_BEGIN =
""
- JPA_TX_COMMIT =
""
- JAVA_NOT_PERSISTENT_NAMESPACE =
["java","javax"]
- DB_Context =
"xmda.jpa.DbContext"
- DB_MAX_TABLE_NAME_LENGTH =
Maximum allowed length for a sgbd table name cf:
Mysql: http://dev.mysql.com/doc/refman/5.0/en/identifiers.html
64
- DB_TABLE_NAME_OVERRIDE =
table name override
Hash.new
- DB_URI_ALIAS =
Hash.new
- DB_DISCRIMINATOR =
Hash.new
- JPA_PAGINATION_QUERY =
<<END if(pageSize>0) { q.setFirstResult(pageNumber*pageSize); q.setMaxResults(pageSize); } END
- JAVA_GETSTATIC_ROLE_COMMENT =
method comment that will be generated as javadoc
<<ENDHELP This method returns a set of "static roles" that *may* *be* granted to the user based on database informations. When a "security role" (defined at runtime) is bounded(linked) to a "static role" (defined at compile time), users must - be granted the security role - and the bounded "static role" must be included in the set of role returned by this method. ENDHEL
- JAVA_GETSTATIC_ROLE_CODE =
method default implementation
<<ENDROLECODE //return empty list (every static role are denied) return new java.util.HashSet<#{Mrdf_Repository::JAVA_GLOBAL_ACCESS_CONTROL_ENUM}>(); ENDROLECODE
- STRUTS_SWITH_TO_FLEX_ACTION =
"switchToFlex"
- STRUTS_XMLFORM_HELPER =
name of the java class used to store helper methods for xml form generation.
"xmda.struts.XMLFormHelper"
- STRUTS_XML_FORM_PROPERTY =
example public StringBuffer getAsXML(StringBuffer sb) {
"xmlForm"
- STRUTS_XML_FORM_GETTER =
"getXmlForm"
- STRUTS_XML_VIEW_PREFIX =
"src."
- FLEX_NS_PREFIX =
STRUTS_XML_VIEW_PREFIX
- STRUTS_SWITCH_TO_FLEX_FORWARD =
"switchToFlexFwd"
- FLEX_SWITCH_TO_JSP_PATH =
"/flex/switchToFlex.jsp"
- NOGIF_FORWARD =
"NOGIF_FWD"
- STRUTS_EDIT_FWD_POSTFIX =
"_fwEdit"
Constants included from DAO
DAO::DAOInterface, DAO::DAOQualifiedInterface
Instance Method Summary collapse
- #apaCom_addLogger! ⇒ Object
- #as_addFormReference! ⇒ Object
- #as_formClass ⇒ Object
- #crank_class_submenu ⇒ Object
- #crank_menu_item ⇒ Object
-
#db_getFindAllCall ⇒ Object
def db_daoClassName jpa_daoClassName end def jpa_daoClassName return “#java_qualifiedNameDao” end.
-
#db_tableName ⇒ Object
Table name for this element.
-
#db_tx(java_code) ⇒ Object
returns java_code enclosed in begin/commit with catch cleanup.
- #doOnJPAAddPersistence! ⇒ Object
-
#ejb2_addOperationExceptions!(exception) ⇒ Object
adds exception to every operation.
- #ejb2_copyMethodsTo!(ejb, uri_suffix, exception) ⇒ Object
-
#ejb2_createBean! ⇒ Object
creates a bean class for this service class (this implementation just appends bean to the class name).
-
#ejb2_createHomeInterface! ⇒ Object
creates a home interface for this service class.
-
#ejb2_createRemoteInterface! ⇒ Object
creates a remote interface for this service class.
-
#ejb2_transform! ⇒ Object
process this java bean to : * generate the proper ejb interfaces, * add required exceptions, * add required interface implementations * …
-
#ejb_Name ⇒ Object
Return an alias name for this class“.
- #flex_generateMXML ⇒ Object
- #flex_generateVO ⇒ Object
- #flex_mxml_as_generateAs ⇒ Object
- #flex_mxml_as_generateAs_commun ⇒ Object
- #flex_mxml_as_generateAs_createAndAdd ⇒ Object
- #flex_mxml_as_generateAs_edit_remove_add ⇒ Object
- #flex_mxml_as_generateAs_operations ⇒ Object
- #flex_mxml_as_generateAs_validateForm ⇒ Object
- #flex_NameVO ⇒ Object
- #flex_ownedAttributeSet(ignoreId = false) ⇒ Object
- #flex_writeMXML ⇒ Object
- #flex_writeMXML_Form ⇒ Object
-
#flex_writeMXML_menu ⇒ Object
generate menu (fixed and dynamic based on object functions).
- #flex_writeMXML_MXvalidators ⇒ Object
-
#flex_writeMXML_script ⇒ Object
function editAdresse(objid) { if(“_”+objid != “_empty”) { doWhat=“editAdresse”; reqtab=objid; submit(); } else { Alert.show(“no element selected for nadresse”); } }.
-
#flex_writeMXML_vo ⇒ Object
SAMPLE: nom=“txtNomtxtNom.text” adresse=“cmbAdressecmbAdresse.selectedItemcmbAdresse.selectedItem.id”.
- #flex_writeVO ⇒ Object
- #flex_writeVO_getParameter ⇒ Object
-
#flex_writeVO_initFromXML ⇒ Object
Generates variable declaration.
-
#flex_writeVO_initItemFromXML ⇒ Object
EXAMPLES: nom = utils.DeserializeXMLUtil.getOptionAttributValue(source, ‘nom’); id= DeserializeXMLUtil.getOptionAttributValue(source, ‘id’); //recuperation de la valeur de type date de l’atribut x de l’option datedenaissance = DeserializeXMLUtil.getOptionDateAttributValue(source, ‘datedenaissance’);.
- #flex_writeVO_vars ⇒ Object
- #java_addEnumPostDeserialiseUpdate! ⇒ Object
- #java_addSerialVersionUID! ⇒ Object
-
#java_createCrudComponent! ⇒ Object
create a CRUD component associated to this class for exposing CRUD services on this object.
-
#java_hasEnumDirectProperties? ⇒ Boolean
returns true if class has at least one enum property Inherited properties are not taken into account.
-
#java_makeSerializable! ⇒ Object
Mark this java class as serializable.
-
#java_writeConstructors ⇒ Object
Adds a constructor with paramter.
-
#java_writeImplements ⇒ Object
write java implements declaration clause if needed.
-
#java_writeMetaClassName ⇒ Object
write java class keyword and class name.
-
#java_writeSuggesterBody(oa) ⇒ Object
Method redefined from ontomde-java alias :original_java_writeSuggesterBody :java_writeSuggesterBody.
- #jpa_addEntityManager! ⇒ Object
-
#jpa_addFindAll!(eao) ⇒ Object
adds a finder to eao self is supposed to be the bean and eao the “dao”.
- #jpa_addFindByPrimaryKey!(eao) ⇒ Object
- #jpa_addPersistence! ⇒ Object
-
#jpa_addPersistenceIdAnnnotation!(p) ⇒ Object
com.francetelecom.rd.cil.commons.common.CommonException com.francetelecom.rd.cil.commons.model.IdentifiedObject java_packageQualifiedName.vo.#java_NameValue java_packageQualifiedName.vo.*.
- #jpa_addPersistOperation! ⇒ Object
- #jpa_addRefreshOperation! ⇒ Object
-
#jpa_addRemoveOperation! ⇒ Object
xMDA does not generate generic DAO type remove method.
- #jpa_addStdImports! ⇒ Object
- #jpa_carryPersistence? ⇒ Boolean
- #jpa_deriveFromPersistent? ⇒ Boolean
- #jpa_hasPersistenceId? ⇒ Boolean
- #jpa_isPersistent? ⇒ Boolean
-
#jpa_tx(java_code) ⇒ Object
returns java_code enclosed in begin/commit with catch cleanup.
-
#jpa_writeConfiguration ⇒ Object
writes jpa entry for this class if this class is persistent.
- #log_error_db_tableName_too_long(tableName) ⇒ Object
-
#struts_addXmlFormField_row_type!(form, t) ⇒ Object
example: public void xmlForm_field_row_Roue(StringBuffer sb, Roue obj) {.
-
#struts_addXmlFormField_type!(form, t) ⇒ Object
Generate a xml serialization method.
- #struts_create_getXMLFormOperations!(form) ⇒ Object
-
#struts_defaultTabId ⇒ Object
return identifier of the default tab.
- #struts_edit_generate ⇒ Object
-
#struts_edit_writeBody ⇒ Object
name of the javascript openTab method used to switch to the requested tab.
- #struts_edit_writeFields ⇒ Object
- #struts_edit_writeForm ⇒ Object
- #struts_edit_writeHead(&block) ⇒ Object
- #struts_edit_writeHeader ⇒ Object
- #struts_edit_writeHTML(&block) ⇒ Object
- #struts_edit_writePage ⇒ Object
- #struts_edit_writePageXML(f) ⇒ Object
- #struts_edit_writeTitle ⇒ Object
- #struts_editForwardName ⇒ Object
- #struts_footer_generate ⇒ Object
-
#struts_formEncTypeAttribute ⇒ Object
form enctype attribute useful when form includes a field of type blob.
- #struts_formName ⇒ Object
- #struts_get_struts_config_action_mapping_actionTypeClause ⇒ Object
- #struts_getXMLFormHelper! ⇒ Object
- #struts_header_generate ⇒ Object
- #struts_header_link_generate ⇒ Object
-
#struts_jsp_edit_path ⇒ Object
Returns the internal where to generate file for this object.
-
#struts_jsp_row_path ⇒ Object
Returns the internal where to generate file for this object.
-
#struts_jsp_writeTabBar ⇒ Object
write tabs in JSP NOTE: CSS is design in such a way that active tab is the last one and its id is menuOptDivId0.
- #struts_jspEdit_generateJavascript ⇒ Object
- #struts_jspEdit_generateJavascript_commun ⇒ Object
- #struts_jspEdit_generateJavascript_edit_remove_add ⇒ Object
- #struts_jspEdit_generateJavascript_jspHeader ⇒ Object
- #struts_jspEdit_generateJavascript_operations ⇒ Object
- #struts_jspEdit_write_Operation ⇒ Object
- #struts_jspEditwriteSelfJSInclude ⇒ Object
- #struts_row_generate ⇒ Object
- #struts_validation_writeField(field) ⇒ Object
- #struts_validation_writeFields ⇒ Object
- #struts_write_struts_config_action_mapping ⇒ Object
- #struts_write_struts_config_form_bean ⇒ Object
- #struts_write_validation_config_formset ⇒ Object
-
#umlx_addGetStaticRoleOperation! ⇒ Object
Adds methods which returns computed grants to user.
- #vso_DataSourceName ⇒ Object
- #vso_ownedAttribute ⇒ Object
- #vso_ownedOperation ⇒ Object
- #vso_writeConstructors(tab) ⇒ Object
- #vso_writeFinder(tab) ⇒ Object
- #vso_writeFinderInventoryChildren(tab) ⇒ Object
- #vso_writeFinderProperties(tab) ⇒ Object
- #vso_writeFinderRelations(tab) ⇒ Object
- #vso_writeMethods(tab) ⇒ Object
- #vso_writeObjectMapping(tab) ⇒ Object
-
#xsd_makeSerializable! ⇒ Object
Mark this java class as serializable.
-
#xsd_writeConstructors ⇒ Object
Adds a constructor with paramter.
-
#xsd_writeImplements ⇒ Object
write java implements declaration clause if needed.
Methods included from DAO
#jpa_addDAO!, #jpa_addGetDao!, #jpa_addMerge!, #jpa_addNamedQuery, #jpa_addNamedQueryToAssociation!, #jpa_addPersist!, #jpa_addPersistenceContext!, #jpa_addRemove!, #super_jpa_addDAO!
Instance Method Details
#apaCom_addLogger! ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/ontomde-java/java/apache.rb', line 3 def apaCom_addLogger! log=umlx_createAndAddProperty(rdf_uri+"log","log"); log.java_noAccessors=RDF_TRUE log.uml_isStatic=RDF_TRUE #log.jpa_transient=RDF_TRUE log.db_isTransient=RDF_TRUE log.java_isTransient=RDF_TRUE log.uml_type=umlx_getOrCreateClass("org.apache.commons.logging.Log"); log.uml_type_one.db_isTransient=RDF_TRUE #log.java_code="org.apache.commons.logging.LogFactory.getFactory().getInstance(this.getClass().getName())" log.java_code=%{org.apache.commons.logging.LogFactory.getFactory().getInstance("#{java_qualifiedName}")} end |
#as_addFormReference! ⇒ Object
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 |
# File 'lib/ontomde-java/flex/main.rb', line 327 def as_addFormReference! log.error{"adding flexFormRef for #{self}:#{self.class}"} p=umlx_createAndAddProperty("#{self.rdf_uri}_flexFormRef","flexForm") p.uml_isReadOnly="true" p.uml_type=as_formClass p.umlx_owner_one.as_addAccessorsFor!(p) p.as_getter_property_inv.each {|get| log.error("maj code") get.as_code=<<END if(#{p.as_Name}==null){ #{p.as_Name} = new #{as_formClass.as_Name}(); #{p.as_Name}.setModif(this); } return #{p.as_Name}; END } end |
#as_formClass ⇒ Object
324 325 326 |
# File 'lib/ontomde-java/flex/main.rb', line 324 def as_formClass return umlx_getOrCreateClass("#{as_qualifiedName}Form") end |
#crank_class_submenu ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/ontomde-java/crank/menu2.rb', line 52 def subClazz = Set.new crank_subCrankBean(subClazz, true) if crank_isTopCrankBean && subClazz.length>1 write <<BEAN <rich:panelMenuGroup label="#{self.java_Name}" iconExpanded="triangleDown" iconCollapsed="triangleUp"> BEAN subClazz.sort { |a,b| a.uml_name.to_s <=> b.uml_name.to_s }.each{|c| c. } write <<BEAN </rich:panelMenuGroup> BEAN elsif end end |
#crank_menu_item ⇒ Object
70 71 72 73 74 75 76 |
# File 'lib/ontomde-java/crank/menu2.rb', line 70 def write <<BEAN <rich:panelMenuItem submitMode="none"> <h:commandLink action="#{self.java_Name.upcase}" value="#{self.java_Name}" styleClass="titleCommandLink"/> </rich:panelMenuItem> BEAN end |
#db_getFindAllCall ⇒ Object
def db_daoClassName jpa_daoClassName end def jpa_daoClassName return “#java_qualifiedNameDao” end
32 33 34 35 36 37 38 39 |
# File 'lib/ontomde-java/jpa/redefined.rb', line 32 def db_getFindAllCall() param=context[:db_useExtraTypeParameterForFindAll] ? "(#{self.java_qualifiedName})null" : "" tenantClause='' if context[:multiTenant] tenantClause="get#{TENANT_FIELD_BEAN_NAME}()," end return "#{java_DAOClass_one.java_qualifiedName}.findAll(#{tenantClause}#{param},0,-1)" end |
#db_tableName ⇒ Object
Table name for this element
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 |
# File 'lib/ontomde-java/jpa/jpa.rb', line 355 def db_tableName r=java_uniqueName if r.length<=DB_MAX_TABLE_NAME_LENGTH #ok. nothing to do elsif ! DB_TABLE_NAME_OVERRIDE[r].nil? #no check performed on overriden name r=DB_TABLE_NAME_OVERRIDE[r] elsif context[:silentlyTruncateTableName,false] log.debug { "silently truncating table name #{r}" } r=r[0,DB_MAX_TABLE_NAME_LENGTH] else log_error_db_tableName_too_long(r) end return r end |
#db_tx(java_code) ⇒ Object
returns java_code enclosed in begin/commit with catch cleanup
254 255 256 |
# File 'lib/ontomde-java/jpa/jpa.rb', line 254 def db_tx(java_code) jpa_tx(java_code) end |
#doOnJPAAddPersistence! ⇒ Object
374 375 376 |
# File 'lib/ontomde-java/jpa/jpa.rb', line 374 def doOnJPAAddPersistence! end |
#ejb2_addOperationExceptions!(exception) ⇒ Object
adds exception to every operation
185 186 187 188 189 |
# File 'lib/ontomde-java/ejb2/main-ejb2.rb', line 185 def ejb2_addOperationExceptions!(exception) uml_ownedOperation.each { |op| op.uml_raisedException_add(exception) } end |
#ejb2_copyMethodsTo!(ejb, uri_suffix, exception) ⇒ Object
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/ontomde-java/ejb2/main-ejb2.rb', line 167 def ejb2_copyMethodsTo!(ejb,uri_suffix,exception) uml_ownedOperation.each { |sop| op=ejb.umlx_createAndAddOperation("#{sop.rdf_uri}_#{uri_suffix}","#{sop.uml_name}") op.uml_raisedException_add(exception) sop.uml_ownedParameter.each { |sp| p=op.umlx_createAndAddParameter("#{sp.rdf_uri}_#{uri_suffix}",sp.uml_name) sp.umlx_copyToAttributeProperty(p) p.uml_type=sp.uml_type p.uml_direction=sp.uml_direction p.uml_isUnique=sp.uml_isUnique p.uml_isOrdered=sp.uml_isOrdered p.java_use_Arrays=sp.java_use_Arrays p.uml_upperValue=sp.uml_upperValue p.uml_lowerValue=sp.uml_lowerValue } } end |
#ejb2_createBean! ⇒ Object
creates a bean class for this service class (this implementation just appends bean to the class name)
138 139 140 141 142 |
# File 'lib/ontomde-java/ejb2/main-ejb2.rb', line 138 def ejb2_createBean! self.ejb_bean=self self.uml_name="#{self.uml_name}Bean" ejb2_addOperationExceptions!(umlx_getOrCreateInterface("java.rmi.RemoteException")) end |
#ejb2_createHomeInterface! ⇒ Object
creates a home interface for this service class
145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/ontomde-java/ejb2/main-ejb2.rb', line 145 def ejb2_createHomeInterface! log.debug { "creating ejb home interface for: #{self}" } h=self.umlx_owner_one.umlx_createAndAddInterface("#{self.rdf_uri}_ejbHome","#{uml_name}Home") h.umlx_createAndAddGeneralization(umlx_getOrCreateInterface("javax.ejb.EJBHome")) self.ejb_home=h cr=h.umlx_createAndAddOperation("#{h.rdf_uri}_create","create") cr.uml_raisedException_add(umlx_getOrCreateInterface("javax.ejb.CreateException")) cr.uml_raisedException_add(umlx_getOrCreateInterface("java.rmi.RemoteException")) crret=cr.umlx_createAndAddReturnParameter("#{cr.rdf_uri}_ret","return") crret.uml_type=self.ejb_remote_one end |
#ejb2_createRemoteInterface! ⇒ Object
creates a remote interface for this service class
159 160 161 162 163 164 165 |
# File 'lib/ontomde-java/ejb2/main-ejb2.rb', line 159 def ejb2_createRemoteInterface! log.debug { "creating ejb remote interface for: #{self}" } r=self.umlx_owner_one.umlx_createAndAddInterface("#{self.rdf_uri}_ejbRemote","#{uml_name}") r.umlx_createAndAddGeneralization(umlx_getOrCreateInterface("javax.ejb.EJBObject")) self.ejb_remote=r ejb2_copyMethodsTo!(ejb_remote_one,"ejbRemote",umlx_getOrCreateInterface("java.rmi.RemoteException")) end |
#ejb2_transform! ⇒ Object
process this java bean to :
-
generate the proper ejb interfaces,
-
add required exceptions,
-
add required interface implementations
-
…
124 125 126 127 128 129 |
# File 'lib/ontomde-java/ejb2/main-ejb2.rb', line 124 def ejb2_transform! log.debug { "processing ejb service: #{self}" } ejb2_createRemoteInterface! ejb2_createHomeInterface! ejb2_createBean! end |
#ejb_Name ⇒ Object
Return an alias name for this class“
132 133 134 |
# File 'lib/ontomde-java/ejb2/main-ejb2.rb', line 132 def ejb_Name return "#{java_Name}EJB" end |
#flex_generateMXML ⇒ Object
17 18 19 20 21 |
# File 'lib/ontomde-java/flex/Editor.mxml.rb', line 17 def flex_generateMXML mtk_writeSession("#{java_FileName.to_s.gsub(/\.[^.\/]*$/,"")}.mxml"){ flex_writeMXML } end |
#flex_generateVO ⇒ Object
11 12 13 14 15 |
# File 'lib/ontomde-java/flex/ValueObjectAS.rb', line 11 def flex_generateVO mtk_writeSession("#{java_FileName.to_s.gsub(/\.[^.\/]*$/,"")}VO.as") { flex_writeVO } end |
#flex_mxml_as_generateAs ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/ontomde-java/flex/Editor.mxml.as.rb', line 11 def flex_mxml_as_generateAs #flex_mxml_as_generateAs_jspHeader flex_mxml_as_generateAs_commun flex_mxml_as_generateAs_operations flex_mxml_as_generateAs_edit_remove_add flex_mxml_as_generateAs_validateForm flex_mxml_as_generateAs_createAndAdd end |
#flex_mxml_as_generateAs_commun ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/ontomde-java/flex/Editor.mxml.as.rb', line 65 def flex_mxml_as_generateAs_commun #//TODO this.#{Muml_Class::STRUTS_REQUESTED_TAB}=model.id.toString(); write <<-END_SCRIPT public function #{STRUTS_REFRESH_ACTION}() :void{ this.#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}="#{STRUTS_REFRESH_ACTION}"; submit(); } public function #{STRUTS_RETURN_ACTION}() :void{ this.#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}="#{STRUTS_RETURN_ACTION}"; submit(); } public function #{STRUTS_PROCEED_ACTION}() :void{ this.#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}="#{STRUTS_PROCEED_ACTION}"; submit(); } END_SCRIPT end |
#flex_mxml_as_generateAs_createAndAdd ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ontomde-java/flex/Editor.mxml.as.rb', line 21 def flex_mxml_as_generateAs_createAndAdd flex_ownedAttributeSet.each { |a| next unless a.umlx_isComposite? #next if a.umlx_oneSide? f="createAndAdd#{a.java_NameBean}" write %{ public function #{f}(reqTypeParam:String):void { this.#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}="#{f}"; this.#{STRUTS_REQUESTED_CREATION_TYPE_FIELD_NAME}=reqTypeParam; submit(); } }} end |
#flex_mxml_as_generateAs_edit_remove_add ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/ontomde-java/flex/Editor.mxml.as.rb', line 83 def flex_mxml_as_generateAs_edit_remove_add flex_ownedAttributeSet.each { |a| #next unless a.umlx_isComposite? #next unless a.umlx_isAssociation? #next if a.umlx_oneSide? li=a.uml_isReadOnly? ? ["edit"] : ["edit","removeAndDelete"] li.each {|meth| f="#{meth}#{a.java_NameBean}" write <<-END public function #{f}(objidParam:String) :void{ if("_"+objidParam != "_empty") { this.#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}="#{f}"; this.#{Muml_Class::STRUTS_REQUESTED_TAB}=objidParam; submit(); } else { ExtendedAlert.error("no element selected for \\n#{flex_localizeMsg("#{self.java_qualifiedName}.#{a.java_Name}")}"); } } END } li=a.uml_isReadOnly? ? [] : ["add"] li.each {|meth| f="#{meth}#{a.java_NameBean}" write <<-END public function #{f}(e:SuggestionAddedEvent) :void{ if("_"+e.idToAdd != "_empty") { this.#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}="#{f}"; this.#{Muml_Class::STRUTS_REQUESTED_TAB}=e.idToAdd; submit(); } else { ExtendedAlert.error("no element selected for \\n#{flex_localizeMsg("#{self.java_qualifiedName}.#{a.java_Name}")}"); } } END } } end |
#flex_mxml_as_generateAs_operations ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/ontomde-java/flex/Editor.mxml.as.rb', line 52 def flex_mxml_as_generateAs_operations uml_ownedOperation.each {|biz| next unless biz.umlx_businessMethod? f=biz.java_Name write <<-ENDMETH public function #{f}() :void{ this.#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}="#{f}"; submit(); } ENDMETH } end |
#flex_mxml_as_generateAs_validateForm ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/ontomde-java/flex/Editor.mxml.as.rb', line 35 def flex_mxml_as_generateAs_validateForm head=<<-ENDHEAD public function validForm():Boolean{ ENDHEAD foot=<<-ENDFOOT return true; } ENDFOOT encloseWrite(head,foot){ flex_ownedAttributeSet.each { |prop| tpl=DatatypeMapping.instance.getMapping(prop.uml_type_one) tpl.flex_writeMXML_validate(prop) }} end |
#flex_NameVO ⇒ Object
18 19 20 |
# File 'lib/ontomde-java/flex/ValueObjectAS.rb', line 18 def flex_NameVO return "#{java_Name}VO" end |
#flex_ownedAttributeSet(ignoreId = false) ⇒ Object
13 14 15 |
# File 'lib/ontomde-java/flex/Editor.mxml.rb', line 13 def flex_ownedAttributeSet(ignoreId=false) return struts_formAttribute(ignoreId) end |
#flex_writeMXML ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ontomde-java/flex/Editor.mxml.rb', line 23 def flex_writeMXML before=<<ENDHEAD <?xml version="1.0" encoding="utf-8"?> <mx:Box xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initForm()" height="100%" width="100%" xmlns:vo="#{FLEX_NS_PREFIX}#{umlx_owner_one.java_qualifiedName}.*" xmlns:utils="utils.*" xmlns:components="components.*" > ENDHEAD after=<<ENDFOOT </mx:Box> ENDFOOT encloseWrite(before,after) { flex_writeMXML_script flex_writeMXML_vo flex_writeMXML_MXvalidators flex_writeMXML_Form } end |
#flex_writeMXML_Form ⇒ Object
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
# File 'lib/ontomde-java/flex/Editor.mxml.rb', line 259 def flex_writeMXML_Form before= <<ENDHEAD <utils:ValidatorForm id="MyForm" defaultButton="{btnValidate}" validators="{validators}" valid="handleFormValidate(event)" invalid="handleFormValidate(event)" width="100%" height="100%"> <mx:FormHeading styleName="PetitTitrePose" label="{getString('#{self.struts_actionForm_one.java_qualifiedName}.title')}"/> ENDHEAD after= <<ENDFOOT </utils:ValidatorForm> <mx:ControlBar id="ControlButtons"> <mx:Text id="status" width="186"/> <mx:Button label="{getString('button.validate')}" click="biz_proceed()" id="btnValidate"/> <mx:Button label="{getString('button.reset')}" click="this.executeBindings(true)" id="button2"/> <mx:Button label="HTML" click="{HTML_Display()}" id="buttontest"/> <mx:Button label="print" click="{doPrint()}" id="buttonPrint"/> </mx:ControlBar> ENDFOOT encloseWrite(before,after) { #uml_ownedOperation.each { |operation| # next unless operation.umlx_businessMethod? # operation.flex_writeMXML_Form_item_methods # } ignoreId=true flex_ownedAttributeSet(ignoreId).each { |prop| encloseWrite(%{<mx:FormItem label="{getString('#{self.struts_actionForm_one.java_qualifiedName}.#{prop.java_Name}')}">\n} ,%{</mx:FormItem>\n}) { tpl=DatatypeMapping.instance.getMapping(prop.uml_type_one) tpl.flex_writeMXML_Form_item_property(prop) } } } end |
#flex_writeMXML_menu ⇒ Object
generate menu (fixed and dynamic based on object functions)
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
# File 'lib/ontomde-java/flex/Editor.mxml.rb', line 232 def before=<<ENDHEAD <mx:ArrayCollection id="methods" source="{buXML.businessaction}"/> <mx:Model id="buXML"> <businessactions> <businessaction label="Valider" functionName="biz_proceed" icon="@Embed('/assets/valider.gif')"/> <businessaction label="Annuler" functionName="" icon="@Embed('/assets/delete.png')"/> <businessaction label="HTML" functionName="HTML_Display" icon="@Embed('/assets/html.gif')"/> <businessaction label="Print" functionName="doPrint" icon="@Embed('/assets/printpca.gif')"/> <businessaction label="{modelGlob.fullscreen?'Normal Size':'FullScreen'}" functionName="fullScreen" icon="@Embed('/assets/fullscreen.gif')"/> ENDHEAD after=<<ENDFOOT </businessactions> </mx:Model> ENDFOOT encloseWrite(before,after) { uml_ownedOperation.each { |op| next unless op.umlx_businessMethod? write(%{<businessaction label="{getString('#{op.umlx_owner_one.java_qualifiedName}.#{op.java_Name}')}" functionName="#{op.java_Name}"/>\n}) } } end |
#flex_writeMXML_MXvalidators ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/ontomde-java/flex/Editor.mxml.rb', line 41 def flex_writeMXML_MXvalidators encloseWrite(%{<mx:Array id="validators">\n},%{</mx:Array>\n}) { flex_ownedAttributeSet.each { |prop| tpl=DatatypeMapping.instance.getMapping(prop.uml_type_one) tpl.flex_writeMXML_MXvalidator(prop) } } end |
#flex_writeMXML_script ⇒ Object
function editAdresse(objid) { if(“_”+objid != “_empty”) { doWhat=“editAdresse”; reqtab=objid; submit(); } else { Alert.show(“no element selected for nadresse”); } }
function removeAndDeleteAdresse(objid:String):void { if(“_”+objid != “_empty”) { doWhat=“removeAndDeleteAdresse”; reqtab=objid; submit(); } else { Alert.show(“no element selected for nadresse”); } }
function createAndAddAdresse(reqType):void { doWhat=“createAndAddAdresse”; this.reqType=reqType; submit(); }
function editFavoris(objid) { if(“_”+objid != “_empty”) { doWhat=“editFavoris”; reqtab=objid; submit(); } else { Alert.show(“no element selected for nfavoris”); } }
function removeAndDeleteFavoris(objid) { if(“_”+objid != “_empty”) { doWhat=“removeAndDeleteFavoris”; reqtab=objid; submit(); } else { Alert.show(“no element selected for nfavoris”); } }
function addFavoris(objid) { if(“_”+objid != “_empty”) { doWhat=“addFavoris”; reqtab=objid; submit(); } else { Alert.show(“no element selected for nfavoris”); } }
function createAndAddContrats(reqType) { doWhat=“createAndAddContrats”; this.reqType=“package1_dot_Contrat”; submit(); }
function editContrats(objid) { if(“_”+objid != “_empty”) { doWhat=“editContrats”; reqtab=objid; submit(); } else { Alert.show(“no element selected for ncontrats”); } }
function removeAndDeleteContrats(objid) { if(“_”+objid != “_empty”) { doWhat=“removeAndDeleteContrats”; reqtab=objid; submit(); } else { Alert.show(“no element selected for ncontrats”); } }
function addDernierContrat(id) { doWhat=“addDernierContrat”; this.reqtab=id; submit(); }
function editDernierContrat(objid) { if(“_”+objid != “_empty”) { doWhat=“editDernierContrat”; reqtab=objid; submit(); } else { Alert.show(“no element selected for ncontrats”); } }
function editLastMonthContracts(objid) { if(“_”+objid != “_empty”) { doWhat=“editLastMonthContracts”; reqtab=objid; submit(); } else { Alert.show(“no element selected for nLastMonthContracts”); } }
function removeAndDeleteDernierContrat(objid) { if(“_”+objid != “_empty”) { doWhat=“removeAndDeleteDernierContrat”; reqtab=objid; submit(); } else { Alert.show(“no element selected for ncontrats”); } }
function ajoutRapideContrat() { doWhat=“ajoutRapideContrat”; submit(); }
//////////////////////////////////////////////////// debut des fonctions metiers ////////////////////////////////////////////////////
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/ontomde-java/flex/Editor.mxml.rb', line 192 def flex_writeMXML_script # (script directory is relative) before= <<ENDHEAD <mx:Script source="#{"../"*(umlx_hierarchy.length)}script/formsGlobalFunctions.as" /> <mx:Script> <![CDATA[ ENDHEAD after=<<ENDFOOT ]]> </mx:Script> ENDFOOT encloseWrite(before,after) { flex_mxml_as_generateAs } end |
#flex_writeMXML_vo ⇒ Object
SAMPLE: nom=“Muml_Class.txtNomtxtNom.text” adresse=“Muml_Class.cmbAdressecmbAdresse.selectedItemcmbAdresse.selectedItem.id”
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
# File 'lib/ontomde-java/flex/Editor.mxml.rb', line 214 def flex_writeMXML_vo before=<<ENDHEAD <vo:#{flex_NameVO} id="model" ENDHEAD after=<<ENDFOOT /> ENDFOOT encloseWrite(before,after) { noId=true flex_ownedAttributeSet(noId).each { |prop| tpl=DatatypeMapping.instance.getMapping(prop.uml_type_one) tpl.flex_writeMXML_vo_mapping(prop) }} end |
#flex_writeVO ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/ontomde-java/flex/ValueObjectAS.rb', line 22 def flex_writeVO importSet=Set.new flex_ownedAttributeSet.each { |c| t=c.uml_type_one next if t.kind_of?(Muml_DataType) importSet.add(t) } importString="" importSet.each { |t| importString="#{importString}\n import #{FLEX_NS_PREFIX}#{t.java_qualifiedName}VO;" } before= <<ENDHEAD package #{FLEX_NS_PREFIX}#{umlx_owner_one.java_qualifiedName} { import mx.collections.ArrayCollection; import utils.DeserializeXMLUtil; #{importString} [Bindable] public class #{flex_NameVO} { ENDHEAD after= <<ENDBOTTOM } } ENDBOTTOM encloseWrite(before,after) { flex_writeVO_vars flex_writeVO_initFromXML flex_writeVO_initItemFromXML flex_writeVO_getParameter } end |
#flex_writeVO_getParameter ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/ontomde-java/flex/ValueObjectAS.rb', line 108 def flex_writeVO_getParameter before=<<ENDHEAD //parametres complementaires à passer aux requetes concernant cette objet public function getParameter():Object{ var param:Object= {}; ENDHEAD after=<<ENDBOTTOM return param; } // getParameter ENDBOTTOM encloseWrite(before,after) { flex_ownedAttributeSet.each { |prop| tpl=DatatypeMapping.instance.getMapping(prop.uml_type_one) tpl.flex_writeVO_getParameter(prop) }} end |
#flex_writeVO_initFromXML ⇒ Object
Generates variable declaration
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/ontomde-java/flex/ValueObjectAS.rb', line 67 def flex_writeVO_initFromXML before= <<ENDHEAD //initialisation du formulaire a partir du XML recu de l'application Struts public function initFromXML(source:XML):void{ ENDHEAD after= <<ENDBOTTOM } // end initFromXML ENDBOTTOM encloseWrite(before,after) { flex_ownedAttributeSet.each { |prop| tpl=DatatypeMapping.instance.getMapping(prop.uml_type_one) tpl.flex_writeVO_initFromXML_mapping(prop) } } end |
#flex_writeVO_initItemFromXML ⇒ Object
EXAMPLES:
nom = utils.DeserializeXMLUtil.getOptionAttributValue(source, 'nom');
id= DeserializeXMLUtil.getOptionAttributValue(source, 'id');
//recuperation de la valeur de type date de l'atribut x de l'option
datedenaissance = DeserializeXMLUtil.getOptionDateAttributValue(source, 'datedenaissance');
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/ontomde-java/flex/ValueObjectAS.rb', line 91 def flex_writeVO_initItemFromXML before= <<ENDHEAD //initialisation d'un item du type de la class pour etre referencer dans les VOs a partir des options du XML public function initItemFromXML(source:XMLList):void{ ENDHEAD after=<<ENDBOTTOM } // initItemFromXML ENDBOTTOM encloseWrite(before,after) { flex_ownedAttributeSet.each { |prop| tpl=DatatypeMapping.instance.getMapping(prop.uml_type_one) tpl.flex_writeVO_initItemFromXML_mapping(prop) } } end |
#flex_writeVO_vars ⇒ Object
59 60 61 62 63 64 |
# File 'lib/ontomde-java/flex/ValueObjectAS.rb', line 59 def flex_writeVO_vars flex_ownedAttributeSet.each { |prop| tpl=DatatypeMapping.instance.getMapping(prop.uml_type_one) tpl.flex_writeVO_vars_datatype(prop) } end |
#java_addEnumPostDeserialiseUpdate! ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/ontomde-java/java/enumCompatibilityLayer.rb', line 94 def java_addEnumPostDeserialiseUpdate! #TODO optimize #return unless java_hasEnumDirectProperties? #rr=umlx_createAndAddOperation(self.rdf_uri+"_"+"readResolve","readResolve") #rr.uml_raisedException_add(umlx_getOrCreateClass("java.io.ObjectStreamException")) #rr.uml_visibility=::Cuml_VisibilityKind::Private #rr.java_code="updateEnumFromEnumAsString();\nreturn this;\n" #rp=rr.umlx_createAndAddReturnParameter(rr.rdf_uri+"_ret") #rp.uml_type=umlx_getOrCreateClass("java.lang.Object") #u=umlx_createAndAddOperation(self.rdf_uri+"_"+"upd_Enum","updateEnumFromEnumAsString") #code=%{Sy stem.out.println("readResolve #{java_qualifiedName}");\n} #code=code+(uml_generalization.empty? ? "//" : "")+"super.#{u.java_Name}();\n" uml_ownedAttribute.each { |a| next unless a.uml_type_one.kind_of?(Muml_Enumeration) a.java_setter_property_inv.each { |g| g.java_code=g.java_code_one+<<END \n#{a.umlx_stringMappingForEnum_one.java_Name}=#{a.java_Name}.name(); END } a.umlx_stringMappingForEnum_one.java_getter_property_inv.each { |g| #asString is not updated when loaded from base g.java_code=%{#{a.umlx_stringMappingForEnum_one.java_Name}= #{a.java_Name}==null ? null : #{a.java_Name}.name();\n}+g.java_code_one } a.umlx_stringMappingForEnum_one.java_setter_property_inv.each { |g| g.java_code=g.java_code_one+<<END \n#{a.java_Name}=Enum.valueOf(#{a.uml_type_one.java_qualifiedName}.class,#{a.umlx_stringMappingForEnum_one.java_Name}); END } #code=code+<<END #if(#{a.umlx_stringMappingForEnum_one.java_Name}!=null) { # #{a.java_Name}=Enum.valueOf(#{a.uml_type_one.java_qualifiedName}.class,#{a.umlx_stringMappingForEnum_one.java_Name}); #} else { # #{a.java_Name}=null; #} #END } #u.java_code=code; return end |
#java_addSerialVersionUID! ⇒ Object
581 582 583 584 585 586 587 588 589 590 |
# File 'lib/ontomde-java/java/java.rb', line 581 def java_addSerialVersionUID! p=umlx_createAndAddProperty(rdf_uri+"_serialVersionUID","serialVersionUID"); p.uml_visibility=::Cuml_VisibilityKind::Private p.uml_isStatic=RDF_TRUE p.java_isFinal=RDF_TRUE p.java_isTransient=RDF_TRUE p.uml_type=umlx_dataType_long p.java_code="1L" p.java_noAccessors=RDF_TRUE end |
#java_createCrudComponent! ⇒ Object
create a CRUD component associated to this class for exposing CRUD services on this object.
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/ontomde-java/java/component.rb', line 137 def java_createCrudComponent! return if umlx_hasStereotype?('DTO') return if db_isDAO? return unless umlx_businessMethod? base=self p=base.umlx_owner_one p=p.umlx_getOrCreatePackage(base.context[:crudComponentPackage,"ws"],p) c=p.umlx_createAndAddComponent("#{self.rdf_uri}_crudc","#{uml_name} CRUD") #puts "component created: #{c}" #struts_addCreateAndAddActions! create=c.umlx_createAndAddOperation("#{c.rdf_uri}_create","create") ret=create.umlx_createAndAddReturnParameter("#{create.rdf_uri}") ret.uml_type=base ret.soa_requestedMode="ID" update=c.umlx_createAndAddOperation("#{c.rdf_uri}_update","update") p1=update.umlx_createAndAddParameter("#{update.rdf_uri}","updateData") p1.uml_type=base p1.soa_requestedMode="FULL" end |
#java_hasEnumDirectProperties? ⇒ Boolean
returns true if class has at least one enum property Inherited properties are not taken into account.
87 88 89 90 91 92 |
# File 'lib/ontomde-java/java/enumCompatibilityLayer.rb', line 87 def java_hasEnumDirectProperties? uml_ownedAttribute.each { |a| return true if a.uml_type_one.kind_of?(Muml_Enumeration) } return false end |
#java_makeSerializable! ⇒ Object
Mark this java class as serializable.
-
adds implements java.io.Serializable
-
adds serialVersionUID variable
Example:
private static final long serialVersionUID = 1L;
575 576 577 578 579 580 |
# File 'lib/ontomde-java/java/java.rb', line 575 def java_makeSerializable! #java_implements_add("java.io.Serializable"); s=umlx_getOrCreateClass("java.io.Serializable") umlx_createAndAddImplementation(s) java_addSerialVersionUID! end |
#java_writeConstructors ⇒ Object
Adds a constructor with paramter
NOTE:
-
EXPERIMENTAL
TODO: associations, et filtrer attributs static
632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 |
# File 'lib/ontomde-java/java/java.rb', line 632 def java_writeConstructors write("public #{java_Name}() {\n") write("}\n") #TODO: associations ??, filtrer static if (!uml_ownedAttribute.empty?) parameters = "" uml_ownedAttribute.each { |o| if o.umlx_isAttribute? parameters << ", " parameters << o.java_propertyRoleType.to_s parameters << " " parameters << o.java_NameProperty end } if (!parameters.empty?) write("\n") parameters = parameters.slice(1, parameters.length) write("public #{java_Name}(#{parameters}) {\n") uml_ownedAttribute.each { |o| if o.umlx_isAttribute? write(" set#{o.java_NameBean}(#{o.java_NameProperty});\n") end } write("\t}\n") end end end |
#java_writeImplements ⇒ Object
write java implements declaration clause if needed.
Example:
-
implements interface1, interface2
608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 |
# File 'lib/ontomde-java/java/java.rb', line 608 def java_writeImplements imp=Set.new uml_implementation.each { |g| next if (g.umlx_hasStereotype?("private") ) imp.add(g.uml_supplier_one.java_qualifiedName) } java_implements.each { |g| imp.add(g) } sep="\nimplements " imp.sort{ |a,b| a <=> b}.each { |g| write(sep) write(g) sep="," } end |
#java_writeMetaClassName ⇒ Object
write java class keyword and class name
Example:
-
classe Class1
596 597 598 599 600 601 602 |
# File 'lib/ontomde-java/java/java.rb', line 596 def java_writeMetaClassName if umlx_hasStereotype?('JavaAnnotation') write(" @interface #{java_Name}") return end write(" class #{java_Name}") end |
#java_writeSuggesterBody(oa) ⇒ Object
Method redefined from ontomde-java alias :original_java_writeSuggesterBody :java_writeSuggesterBody
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/ontomde-java/jpa/redefined.rb', line 43 def java_writeSuggesterBody(oa) #log.debug {"adding suggester to #{self} for #{oa}"} if oa.uml_type_one.jpa_isPersistent? #TODO: recherche du composite commun #TODO: transient object do not have a valid uniq id # When otherSide has cardinality 1, we do not # suggest an element if it is already assigned. # Feature is only available when other side is navigable # because we don't want a big overhead. oe=oa.umlx_otherEnd filterOut=!oe.nil? && oe.umlx_isNavigable? && oe.umlx_oneSide? if !oa.umlx_manySide? write( %{ java.util.List<#{oa.uml_type_one.java_qualifiedName}> ret=#{oa.uml_type_one.db_getFindAllCall}; #{oa.uml_type_one.java_qualifiedName} elt=get#{oa.java_NameBean}(); if(elt!=null && !ret.contains(elt)) { ret.add(elt); } #{%{java.util.Iterator<?> iter=ret.iterator(); #{oa.uml_type_one.java_qualifiedName} item=null; while(iter.hasNext()){ item=(#{oa.uml_type_one.java_qualifiedName}) iter.next(); if(item.get#{oe.java_NameBean}()!=null && item.get#{oe.java_NameBean}()!=this) { iter.remove(); } }} if filterOut} return ret;\n}) else write( %{ java.util.List<#{oa.uml_type_one.java_qualifiedName}> ret=#{oa.uml_type_one.db_getFindAllCall}; #{oa.uml_type_one.java_qualifiedName} item=null; java.util.Iterator<?> iter=get#{oa.java_NameBean}().iterator(); while(iter.hasNext()){ item=(#{oa.uml_type_one.java_qualifiedName}) iter.next(); if(!ret.contains(item) #{"&& (item.get#{oe.java_NameBean}()==null || item.get#{oe.java_NameBean}()==this)" if filterOut} ) { ret.add(item); } } return ret;\n}) end else super(oa)#original_java_writeSuggesterBody(oa) end end |
#jpa_addEntityManager! ⇒ Object
268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/ontomde-java/jpa/jpa.rb', line 268 def jpa_addEntityManager! gem=umlx_createAndAddOperation(rdf_uri+"getEntityManager","getEntityManager") gem.uml_isStatic=RDF_TRUE ret=gem.umlx_createAndAddReturnParameter(DB_Context+"_ret") ret.uml_upperValue=umlx_literal(1) ret.uml_lowerValue=umlx_literal(0) ret.uml_type=umlx_getOrCreateClass(DB::EntityManager) gem.java_code="return #{DB_Context}.getEntityManager();" end |
#jpa_addFindAll!(eao) ⇒ Object
adds a finder to eao self is supposed to be the bean and eao the “dao”.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 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 |
# File 'lib/ontomde-java/jpa/finder.rb', line 13 def jpa_addFindAll!(eao) [false,true].each { |paginated| # java_NameBean is added to avoid name clash with inheritance m=eao.umlx_createAndAddOperation(rdf_uri+"_findAll"+(paginated ? '_pag':''),"findAll")#+self.java_NameBean) m.uml_isStatic=RDF_TRUE #m.uml_class=self m.uml_visibility=Cuml_VisibilityKind::Public #m.uml_isStatic=RDF_TRUE #em=m.umlx_createAndAddParameter(m.rdf_uri+"_entityManager","entityManager") #em.uml_type=umlx_getOrCreateClass(JPA::EntityManager) #em.uml_direction=Cuml_ParameterDirectionKind::In #em.uml_upperValue=umlx_literal(1) #em.uml_lowerValue=umlx_literal(1) rp=m.umlx_createAndAddParameter(m.rdf_uri+"_ret_param","return") rp.uml_direction=Cuml_ParameterDirectionKind::Return rp.uml_upperValue=umlx_literal(-1) rp.uml_lowerValue=umlx_literal(0) rp.uml_type=self rp.uml_isOrdered=RDF_TRUE #m.java_code="return (#{self.java_qualifiedName})entityManager.find( #{self.java_qualifiedName}.class, #{ip.uml_name});" if !context[:crank] basicQuery=<<END javax.persistence.Query q=getEntityManager().createQuery( "select Object(c) from #{java_Name} as c"); #{JPA_PAGINATION_QUERY if paginated} return (java.util.List<#{self.java_qualifiedName}>) q.getResultList(); END if !context[:multiTenant] m.java_code=basicQuery else ip=m.umlx_createAndAddParameter(m.rdf_uri+"_tenant","tenant") ip.uml_type=rdf_Repository.java_getTenantClass ip.umlx_createAndAddComment(ip.rdf_uri+"comment","Restrict query to this tenant") m.java_code=<<END if(#{ip.java_Name}!=null) { javax.persistence.Query q=getEntityManager().createQuery( "select Object(c) from #{java_Name} as c where c.#{TENANT_FIELD_NAME}= :tenantQP"); q.setParameter("tenantQP",#{ip.java_Name}); #{JPA_PAGINATION_QUERY if paginated} return (java.util.List<#{self.java_qualifiedName}>) q.getResultList(); } else { //TODO: disable in production code System.out.println("DEBUG MODE"); #{basicQuery} } END end else paginatedParams="" if paginated paginatedParams="pageNumber * pageSize, pageSize" end basicQuery=<<END return get#{self.java_Name}DAO().find(#{paginatedParams}); END m.java_code=basicQuery end m.java_annotation_add(%{@SuppressWarnings("unchecked")}) # because A<-B is not Set<A> <- Set<B> # we need to have an extra parameter # so method overloading is OK. # (this is not necessary when A is return) if context[:db_useExtraTypeParameterForFindAll] t=m.umlx_createAndAddParameter(m.rdf_uri+"_class","nullCast") t.uml_type=self end if paginated pageN=m.umlx_createAndAddParameter(m.rdf_uri+"_pageN","pageNumber") pageN.uml_type=umlx_dataType_integer pageS=m.umlx_createAndAddParameter(m.rdf_uri+"_pageS","pageSize") pageS.uml_type=umlx_dataType_integer pageS.umlx_createAndAddComment(pageS.rdf_uri+"comment","use -1 to retreive all results ") end } return nil # m end |
#jpa_addFindByPrimaryKey!(eao) ⇒ Object
102 103 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 |
# File 'lib/ontomde-java/jpa/finder.rb', line 102 def jpa_addFindByPrimaryKey!(eao) m=eao.umlx_createAndAddOperation(rdf_uri+"_finderop","find") m.uml_isStatic=RDF_TRUE #m.uml_class=self m.uml_visibility=Cuml_VisibilityKind::Public #m.uml_isStatic=RDF_TRUE #em=m.umlx_createAndAddParameter(m.rdf_uri+"_entityManager","entityManager") #em.uml_type=umlx_getOrCreateClass(JPA::EntityManager) #em.uml_direction=Cuml_ParameterDirectionKind::In #em.uml_upperValue=umlx_literal(1) #em.uml_lowerValue=umlx_literal(1) ip=m.umlx_createAndAddParameter(m.rdf_uri+"_id_param","primaryKey") ip.uml_direction=Cuml_ParameterDirectionKind::In ip.uml_upperValue=umlx_literal(1) ip.uml_lowerValue=umlx_literal(1) ip.uml_type=umlx_dataType_long #ip.uml_isOrdered=RDF_FALSE rp=m.umlx_createAndAddParameter(m.rdf_uri+"_ret_param","return") rp.uml_direction=Cuml_ParameterDirectionKind::Return rp.uml_upperValue=umlx_literal(1) rp.uml_lowerValue=umlx_literal(0) rp.uml_type=self #rp.uml_isOrdered=RDF_FALSE if !context[:crank] m.java_code="\t\treturn (#{self.java_qualifiedName})getEntityManager().find( #{self.java_qualifiedName}.class, #{ip.uml_name});" else m.java_code="\t\treturn get#{self.java_Name}DAO().read(#{ip.uml_name});" end return m end |
#jpa_addPersistence! ⇒ Object
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 |
# File 'lib/ontomde-java/jpa/jpa.rb', line 377 def jpa_addPersistence! #jpa_addDAO! #Ajout l'interface XmdaEntity ent=umlx_getOrCreateGeneric(DB::EntityGenericInterface,DB::EntityGenericParameter) umlx_createAndAddImplementation(ent) jpa_addEntityManager! # required for query, persist,... uml_ownedOperation.each { |o| o.jpa_addPersistence! } java_makeSerializable! java_annotation_add("@Entity") java_import_add("javax.persistence.Entity") java_uniqueName # this call enforces uniqueness if jpa_hasPersistenceId? java_annotation_add("@Table (name=\"#{db_tableName}\")") java_import_add("javax.persistence.Table") end if context[:dbTypeDiscriminator]==:int k=rdf_uri.to_s disc=DB_DISCRIMINATOR[k] if disc.nil? disc=0 DB_DISCRIMINATOR.each { |kx,v| disc=v+1 if disc<=v } DB_DISCRIMINATOR[k]=disc end #TODO: generate only when necessary java_annotation_add(%{@DiscriminatorColumn(discriminatorType = DiscriminatorType.INTEGER)}) java_import_add("javax.persistence.DiscriminatorColumn") java_import_add("javax.persistence.DiscriminatorType") java_annotation_add(%{@DiscriminatorValue(value = "#{disc}" )}) java_import_add("javax.persistence.DiscriminatorValue") end jpa_addStdImports! doOnJPAAddPersistence!() end |
#jpa_addPersistenceIdAnnnotation!(p) ⇒ Object
com.francetelecom.rd.cil.commons.common.CommonException com.francetelecom.rd.cil.commons.model.IdentifiedObject java_packageQualifiedName.vo.#java_NameValue java_packageQualifiedName.vo.*
452 453 454 455 456 457 |
# File 'lib/ontomde-java/jpa/jpa.rb', line 452 def jpa_addPersistenceIdAnnnotation!(p) p.java_annotation_add("@Id") java_import_add("javax.persistence.Id") p.java_annotation_add("@GeneratedValue") java_import_add("javax.persistence.GeneratedValue") end |
#jpa_addPersistOperation! ⇒ Object
264 265 |
# File 'lib/ontomde-java/jpa/jpa.rb', line 264 def jpa_addPersistOperation! end |
#jpa_addRefreshOperation! ⇒ Object
289 290 |
# File 'lib/ontomde-java/jpa/jpa.rb', line 289 def jpa_addRefreshOperation! end |
#jpa_addRemoveOperation! ⇒ Object
xMDA does not generate generic DAO type remove method. object should be removed using their composite object
283 284 285 286 287 |
# File 'lib/ontomde-java/jpa/jpa.rb', line 283 def jpa_addRemoveOperation! # Possible implementation # get container # call remove method end |
#jpa_addStdImports! ⇒ Object
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 |
# File 'lib/ontomde-java/jpa/jpa.rb', line 418 def jpa_addStdImports! #java_import_add("java.util.ArrayList") #java_import_add("java.util.Set") #java_import_add("java.util.List") #java_import_add("javax.persistence.*") # java_import_add("javax.persistence.Entity") # java_import_add("javax.persistence.Table") # java_import_add("javax.persistence.DiscriminatorColumn") # java_import_add("javax.persistence.DiscriminatorValue") # java_import_add("javax.persistence.DiscriminatorType") # java_import_add("javax.persistence.Version") # java_import_add("javax.persistence.Basic") # java_import_add("javax.persistence.Column") # java_import_add("javax.persistence.Lob") # java_import_add("javax.persistence.Id") # java_import_add("javax.persistence.GeneratedValue") # java_import_add("javax.persistence.JoinTable") # java_import_add("javax.persistence.OneToMany") # java_import_add("javax.persistence.ManyToOne") # java_import_add("javax.persistence.ManyToMany") # java_import_add("javax.persistence.Temporal") # java_import_add("javax.persistence.CascadeType") # java_import_add("javax.persistence.FetchType") # #java_import_add("javax.persistence.OneToOne") # java_import_add("javax.persistence.JoinColumn") # java_import_add("javax.persistence.TemporalType") #com.francetelecom.rd.cil.commons.common.CommonException #com.francetelecom.rd.cil.commons.model.IdentifiedObject ##{java_packageQualifiedName}.vo.#{java_Name}Value ##{java_packageQualifiedName}.vo.* end |
#jpa_carryPersistence? ⇒ Boolean
311 312 313 314 315 316 317 318 319 |
# File 'lib/ontomde-java/jpa/jpa.rb', line 311 def jpa_carryPersistence? qn=java_qualifiedName JAVA_NOT_PERSISTENT_NAMESPACE.each { |ns| return false if qn.index(ns)==0 } #external is supposed not to carry persistence #return false if umlx_external? return true; end |
#jpa_deriveFromPersistent? ⇒ Boolean
295 296 297 298 299 300 |
# File 'lib/ontomde-java/jpa/jpa.rb', line 295 def jpa_deriveFromPersistent? uml_generalization.each { |c| return true if c.uml_general_one.jpa_isPersistent? } return false end |
#jpa_hasPersistenceId? ⇒ Boolean
321 322 323 324 325 |
# File 'lib/ontomde-java/jpa/jpa.rb', line 321 def jpa_hasPersistenceId? return false if jpa_deriveFromPersistent? return false unless jpa_carryPersistence? return true end |
#jpa_isPersistent? ⇒ Boolean
301 302 303 304 305 306 307 308 309 310 |
# File 'lib/ontomde-java/jpa/jpa.rb', line 301 def jpa_isPersistent? #an external class is supposed to be not persistent #if umlx_external? # return false #end return false if db_isTransient? || db_isDAO? return true if jpa_deriveFromPersistent? #return false unless uml_generalization.empty? return jpa_carryPersistence? end |
#jpa_tx(java_code) ⇒ Object
returns java_code enclosed in begin/commit with catch cleanup
258 259 260 |
# File 'lib/ontomde-java/jpa/jpa.rb', line 258 def jpa_tx(java_code) return "#{JPA_TX_BEGIN}#{java_code}#{JPA_TX_COMMIT}" end |
#jpa_writeConfiguration ⇒ Object
writes jpa entry for this class if this class is persistent.
191 192 193 194 195 196 197 198 |
# File 'lib/ontomde-java/jpa/configuration.rb', line 191 def jpa_writeConfiguration() ignoreExternal=false return if java_ignoreMe?(ignoreExternal) return unless umlx_owner_one.kind_of?(Muml_Package) return unless jpa_isPersistent? return if db_isTransient? write %{<class>#{java_qualifiedName}</class>\n} end |
#log_error_db_tableName_too_long(tableName) ⇒ Object
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 |
# File 'lib/ontomde-java/jpa/jpa.rb', line 326 def log_error_db_tableName_too_long(tableName) return if log_already_displayed?("#{rdf_uri}__tableName") log.error { <<END ********* SGBD TABLE NAME TOO LONG ********** ** This software has detected a table name exceeding 63 character ** ( tableName(#{tableName.length})="#{tableName}" ) ** ** This table name is related to element: ** #{} ** ** Default Table name can be overidden using method call: ** db_addTableNameOverride("#{tableName}","MYSHORTTABLENAME") ** ** This model element is related to these other model elements: #{}********* SGBD TABLE NAME TOO LONG ********** END } end |
#struts_addXmlFormField_row_type!(form, t) ⇒ Object
example: public void xmlForm_field_row_Roue(StringBuffer sb, Roue obj) {
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
# File 'lib/ontomde-java/struts/xmlForm.rb', line 239 def struts_addXmlFormField_row_type!(form,t) helper=struts_getXMLFormHelper!.java_Name m=form.umlx_createAndAddOperation("#{rdf_uri}_fft_#{t.java_Name}","xmlForm_field_row_#{t.java_Name}") p=m.umlx_createAndAddParameter("#{m.rdf_uri}_p1","sb") p.uml_type=umlx_getOrCreateClass("java.lang.StringBuffer") p=m.umlx_createAndAddParameter("#{m.rdf_uri}_p2","obj") p.uml_type=t code="" t.struts_formAttribute.each { |a| code=code+%{#{helper}.xmlForm_field(sb,"#{a.java_Name}",obj.get#{a.java_NameBean}());\n} } m.java_code=code end |
#struts_addXmlFormField_type!(form, t) ⇒ Object
Generate a xml serialization method. Example signature: public void xmlForm_field_type_Roue(StringBuffer sb, String label, String[] currentValue, List<Roue> suggestion) …
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
# File 'lib/ontomde-java/struts/xmlForm.rb', line 191 def struts_addXmlFormField_type!(form,t) m=form.umlx_createAndAddOperation("#{rdf_uri}_fft_#{t.java_Name}","xmlForm_field_type_#{t.java_Name}") p=m.umlx_createAndAddParameter("#{m.rdf_uri}_p1","sb") p.uml_type=umlx_getOrCreateClass("java.lang.StringBuffer") p=m.umlx_createAndAddParameter("#{m.rdf_uri}_p2","label") p.uml_type=umlx_dataType_string p=m.umlx_createAndAddParameter("#{m.rdf_uri}_p3","currentValueMany") p.uml_type=umlx_dataType_string #p.uml_isOrdered=RDF_TRUE #force collection type to Collection. p.uml_isUnique=RDF_FALSE p.uml_upperValue=umlx_literal(-1) p.java_use_Arrays=RDF_TRUE p=m.umlx_createAndAddParameter("#{m.rdf_uri}_p4","currentValueOne") p.uml_type=umlx_dataType_string #p.uml_upperValue=umlx_literal(-1) #p.java_use_Arrays=RDF_TRUE p=m.umlx_createAndAddParameter("#{m.rdf_uri}_p5","suggestion") p.uml_upperValue=umlx_literal(-1) p.uml_isOrdered=RDF_TRUE p.uml_type=t p=m.umlx_createAndAddParameter("#{m.rdf_uri}_p6","createSug") p.uml_upperValue=umlx_literal(-1) p.uml_isOrdered=RDF_TRUE p.uml_type=t.java_enumAssignableDataType_one helper=struts_getXMLFormHelper!.java_Name m.java_code=<<END #{helper}.xmlForm_field_head(sb, label, currentValueMany,currentValueOne); for (#{t.java_qualifiedName} item : suggestion) { if (#{helper}.xmlForm_field_sug_ifNull(sb,item)) { #{helper}.xmlFormSugOpen(sb,Long.toString(item.getId())); xmlForm_field_row_#{t.java_Name}(sb, item); #{helper}.xmlFormSugClose(sb); } } XMLFormHelper.xmlForm_field_create(sb,createSug); #{helper}.xmlForm_field_tail(sb, label); END end |
#struts_create_getXMLFormOperations!(form) ⇒ Object
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 |
# File 'lib/ontomde-java/struts/xmlForm.rb', line 258 def struts_create_getXMLFormOperations!(form) return unless context[:generateXMLStrutsForm,false] t=form helper=struts_getXMLFormHelper!.java_Name form.java_import_add(struts_getXMLFormHelper!.java_qualifiedName) form.java_import_add("org.apache.struts.util.LabelValueBean") m=form.umlx_createAndAddOperation("#{rdf_uri}_fft_#{t.java_Name}",STRUTS_XML_FORM_GETTER) #p=m.umlx_createAndAddParameter("#{m.rdf_uri}_p1","sb") #p.uml_type=umlx_getOrCreateClass("java.lang.StringBuffer") p=m.umlx_createAndAddReturnParameter("#{m.rdf_uri}_p2","obj") p.uml_type=m.umlx_owner_one.umlx_dataType_string code=<<END StringBuffer sb = new StringBuffer(); END usedTypes=Set.new self.struts_formAttribute.each { |a| next if a.uml_isReadOnly? if a.uml_type_one.kind_of?(Muml_Enumeration) code=code+%{#{helper}.xmlForm_field_type_Enum(sb, "#{a.java_Name}", get#{a.java_NameBean}(), get#{a.java_NameBean}Sug());\n} elsif a.uml_type_one.kind_of?(Muml_DataType) code=code+%{#{helper}.xmlForm_field_type_Lit(sb, "#{a.java_Name}", getReference().get#{a.java_NameBean}());\n} elsif a.umlx_manySide? code=code+%{xmlForm_field_type_#{a.uml_type_one.java_Name}(sb, "#{a.java_Name}", get#{a.java_NameBean}(),null, getReference().get#{a.java_NameBean}Sug(),#{ a.umlx_isComposite? ? "getReference().getCreateAndAdd#{a.java_NameBean}Sug()":"null"});\n} usedTypes.add(a.uml_type_one) else code=code+%{xmlForm_field_type_#{a.uml_type_one.java_Name}(sb, "#{a.java_Name}", null,get#{a.java_NameBean}(), getReference().get#{a.java_NameBean}Sug(),#{ a.umlx_isComposite? ? "getReference().getCreateAndAdd#{a.java_NameBean}Sug()":"null"});\n} usedTypes.add(a.uml_type_one) end } usedTypes.each { |t| struts_addXmlFormField_type!(form,t) struts_addXmlFormField_row_type!(form,t) } code=code+<<END //StrutsHelper.xmlForm_field_type_Lit(sb, "marque", getMarque()); //xmlForm_field_type_Roue(sb, "roues", getRoues(), getReference().getRouesSug()); //xmlForm_field_type_Moteur(sb, "moteur", getMoteur(), getReference().getMoteurSug()); END code=code+<<END return sb.toString(); END m.java_code=code end |
#struts_defaultTabId ⇒ Object
return identifier of the default tab
132 133 134 |
# File 'lib/ontomde-java/struts/jsp_edit.rb', line 132 def struts_defaultTabId return "all" end |
#struts_edit_generate ⇒ Object
164 165 166 167 168 169 170 171 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 |
# File 'lib/ontomde-java/struts/jsp_edit.rb', line 164 def struts_edit_generate return if java_ignoreMe? #path=context[:jspEditMode] ? "form_item" : "view_item" struts_ownedTab.each { |i| label="#{i}" f=self.struts_actionForm_one mtk_context(:struts_tab => i ) { mtk_writeSession( %{#{context[:webContentDir]}/#{struts_jsp_edit_path}} ) { #log.debug { %{#{context[:webContentDir]}/{struts_jsp_edit_path}} } struts_edit_writeHeader before="" after="" if(context[:generateXMLStrutsForm]) before=%{<logic:notPresent parameter="FLEX">\n} after=%{</logic:notPresent>\n} end struts_encloseWrite(before,after) { mtk_context( :struts_curClass => self) { struts_edit_writePage }} before="" after="" if(context[:generateXMLStrutsForm]) before=%{<logic:present parameter="FLEX">\n} after=%{</logic:present>\n} end struts_encloseWrite(before,after) { struts_edit_writePageXML(f) } }}} end |
#struts_edit_writeBody ⇒ Object
name of the javascript openTab method used to switch to the requested tab.
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 |
# File 'lib/ontomde-java/struts/jsp_edit.rb', line 328 def struts_edit_writeBody mtk_context(:strutsActionName => "/#{java_Name}#{context[:struts_tab].java_Name}-submit" ) { struts_encloseWrite(%{<body >\n<html:form #{struts_formEncTypeAttribute} action="#{context[:strutsActionName]}">\n<center>},"</center>\n</html:form></body>\n") { if(context[:generateXMLStrutsForm]) write <<END <!-- DEBUG SWITCH --> <input type="checkbox" name="FLEX"/> END end struts_header_generate write <<END <%-- ********* CORPS DE PAGE ********** --%> <logic:messagesPresent> <div> <table class="tableForm"> <tr> <td class="attributeIcons"> <img src="#{css_path_model}/#{css_color_class}/image/btnWarning.gif" alt="" width="25" height="25" border="0" /> </td> <td> <h1> #{struts_writeMsg("errors.header")} </h1> </td> </tr> </table> <html:messages id="error"> <p class="attributeError"> <bean:write name="error"/> </p> </html:messages> </div> </logic:messagesPresent> END struts_jsp_writeTabBar write "<SCRIPT>\n" context[:struts_tab].struts_ownedAttribute.each { |a| next unless a.umlx_isComposite? #next if a.umlx_oneSide? f="createAndAdd#{a.java_NameBean}" write %{ function #{f}(reqType) { document.forms[0].#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}.value="#{f}"; document.forms[0].#{STRUTS_REQUESTED_CREATION_TYPE_FIELD_NAME}.value=reqType; document.forms[0].submit(); } } } write "<!-- THERE -->\n" write <<END_SCRIPT </SCRIPT> END_SCRIPT write <<END <div class="body"> <div class="bodyTop"/><div class="bodyContent"> END write <<END <h1>#{struts_writeMsg("#{java_qualifiedName}.title")}</h1> #{mtk_stss{struts_jspEdit_write_Operation}} END struts_edit_writeForm write <<END </div> <div class="bodyBottom"></div> END write <<END </div> END }} end |
#struts_edit_writeFields ⇒ Object
473 474 475 476 477 478 479 |
# File 'lib/ontomde-java/struts/jsp_edit.rb', line 473 def struts_edit_writeFields context[:struts_tab].struts_ownedAttribute.each { |a| next if a.uml_name_one=="id" next if a.uml_name_one=="isLogicallyDeleted" a.struts_edit_writeFieldProp(self) } end |
#struts_edit_writeForm ⇒ Object
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 |
# File 'lib/ontomde-java/struts/jsp_edit.rb', line 414 def struts_edit_writeForm #<html:text property="xmda_action"/> struts_edit_writeFields write <<END <%-- ****** --%> <%-- SUBMIT --%> <%-- ****** --%> <div> <input type="hidden" name="#{STRUTS_REQUESTED_CREATION_TYPE_FIELD_NAME}"/> <html:hidden property="#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}"/> <input type="hidden" name="#{Muml_Class::STRUTS_REQUESTED_TAB}"/> <html:hidden property="#{Muml_Class::STRUTS_SGBD_STATE}"/> <SCRIPT>function sel(target) {document.forms[0].#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}.value=target;}</SCRIPT> </div><br/> <div class="boutons" align="right"> <html:submit styleClass="boutonForm" onclick="#{STRUTS_RETURN_ACTION}();return false;">#{struts_writeMsg("button.return")}</html:submit> <html:submit styleClass="boutonForm" onclick="#{STRUTS_PROCEED_ACTION}();return false;">#{struts_writeMsg("button.validate")}</html:submit> <%-- <html:submit onclick="sel('delete');" styleClass="boutonForm">#{struts_writeMsg("button.delete")}</html:submit> --%> <html:reset styleClass="boutonForm">#{struts_writeMsg("button.reset")}</html:reset> <%-- <html:cancel styleClass="boutonForm">#{struts_writeMsg("button.cancel")}</html:cancel> --%> </div> END end |
#struts_edit_writeHead(&block) ⇒ Object
272 273 274 275 276 |
# File 'lib/ontomde-java/struts/jsp_edit.rb', line 272 def struts_edit_writeHead(&block) write "<head>" yield write "</head>" end |
#struts_edit_writeHeader ⇒ Object
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
# File 'lib/ontomde-java/struts/jsp_edit.rb', line 240 def struts_edit_writeHeader # encoding must be ISO8859-1 to avoid bug with forms and accentuated characters. write <<END <?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <%@ page contentType="text/html;charset=ISO8859-1" %> <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %> <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %> <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %> END if context[:jspUseXmdaTaglib] write <<END <%@ taglib uri="http://orange.fr/2007/xmda/struts-tags" prefix="xmda" %> <%@ taglib uri="http://displaytag.sf.net" prefix="display" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> END if context[:security] write <<END <%@ taglib uri="http://orange.fr/2007/xmda/struts-security-tags" prefix="xmdas" %> END end if context[:statemachine] write <<END <%@ taglib uri="http://orange.fr/2007/xmda/fsm-tags" prefix="xmdafsm" %> END end end end |
#struts_edit_writeHTML(&block) ⇒ Object
234 235 236 237 238 |
# File 'lib/ontomde-java/struts/jsp_edit.rb', line 234 def struts_edit_writeHTML(&block) write("<html:html><%-- T:1004 --%>") yield write("</html:html><%-- T:1004 --%>") end |
#struts_edit_writePage ⇒ Object
221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/ontomde-java/struts/jsp_edit.rb', line 221 def struts_edit_writePage struts_edit_writeHTML { struts_edit_writeHead { struts_jspEdit_generateJavascript struts_header_link_generate struts_jspEditwriteSelfJSInclude struts_edit_writeTitle } struts_edit_writeBody } end |
#struts_edit_writePageXML(f) ⇒ Object
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
# File 'lib/ontomde-java/struts/jsp_edit.rb', line 200 def struts_edit_writePageXML(f) return unless context[:generateXMLStrutsForm] write( %{ <message> <meta> <html:link action="/#{java_Name}#{context[:struts_tab].java_Name}-submit"/> <timeout_ms><%= 3*60*60*1000 %></timeout_ms> <timezone><bean:write name="#{struts_actionForm_one.java_Name}" property="#{::Muml_Classifier::STRUTS_SETTIMEZONE_FIELD}"/></timezone> <sessionId><%=session.getId()%></sessionId> <view>#{STRUTS_XML_VIEW_PREFIX}#{java_qualifiedName}</view><logic:messagesPresent> <html:messages id="error"><errors> <error><bean:write name="error"/></error></html:messages> </errors> </logic:messagesPresent></meta> <form> <bean:write name="#{f.java_Name}" property="#{::Muml_Class::STRUTS_XML_FORM_PROPERTY}" filter="false" /> </form> </message> }) end |
#struts_edit_writeTitle ⇒ Object
278 279 280 |
# File 'lib/ontomde-java/struts/jsp_edit.rb', line 278 def struts_edit_writeTitle write %{<title>#{struts_writeMsg("#{self.java_qualifiedName}.title")}</title>} end |
#struts_editForwardName ⇒ Object
163 164 165 |
# File 'lib/ontomde-java/struts/struts-config.rb', line 163 def struts_editForwardName return "#{java_Name}#{STRUTS_EDIT_FWD_POSTFIX}" end |
#struts_footer_generate ⇒ Object
125 126 127 |
# File 'lib/ontomde-java/struts/footer.rb', line 125 def rdf_Repository. end |
#struts_formEncTypeAttribute ⇒ Object
form enctype attribute useful when form includes a field of type blob
321 322 323 324 |
# File 'lib/ontomde-java/struts/jsp_edit.rb', line 321 def struts_formEncTypeAttribute #TODO: add enctype *only* if form has a blob field return %{ enctype="multipart/form-data"} end |
#struts_formName ⇒ Object
3 4 5 |
# File 'lib/ontomde-java/struts/struts-config.rb', line 3 def struts_formName return "#{java_qualifiedName.tr('.','_')}" end |
#struts_get_struts_config_action_mapping_actionTypeClause ⇒ Object
176 177 178 179 180 181 182 |
# File 'lib/ontomde-java/struts/struts-config.rb', line 176 def struts_get_struts_config_action_mapping_actionTypeClause # if context[:struts_useSpring] # return %{type="defined in spring"} #else return %{type="#{struts_action_one.java_qualifiedName}"} #end end |
#struts_getXMLFormHelper! ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 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 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 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/ontomde-java/struts/xmlForm.rb', line 14 def struts_getXMLFormHelper! helper=umlx_getOrCreateClass(STRUTS_XMLFORM_HELPER) if(helper.java_customCode.empty?) helper.umlx_external=RDF_FALSE helper.java_import_add("org.apache.struts.util.LabelValueBean") helper.db_isTransient=RDF_TRUE helper.struts_isForm=RDF_FALSE helper.java_customCode= %{ public static void xmlForm_field(StringBuffer sb, String label, Object value) { //Default behavior is to call toString. //Customization should be coded in StrutsForm when using Struts. xmlForm_field(sb,label,value==null ? null : value.toString()); } //static java.text.SimpleDateFormat dfDate=new java.text.SimpleDateFormat("yyyy/MM/dd",java.util.Locale.ENGLISH); //static java.text.SimpleDateFormat dfTimestamp=new java.text.SimpleDateFormat("yyyy/MM/dd HH:mm:ss",java.util.Locale.ENGLISH); public static void xmlForm_field(StringBuffer sb, String label, java.util.Date value) { xmlForm_field(sb,label,value==null ? null : #{STRUTS_TIMESTAMP_FORMATER_INSTANCE}.format(value)); } public static void xmlForm_field(StringBuffer sb, String label, Enum<?> value) { xmlForm_field(sb,label,value==null ? null : value.getClass().getCanonicalName()+"."+value.toString()); } public static void xmlForm_field(StringBuffer sb, String label, int value) { xmlForm_field(sb,label,Integer.toString(value)); } public static void xmlForm_field(StringBuffer sb, String label, long value) { xmlForm_field(sb,label,Long.toString(value)); } public static void xmlForm_field(StringBuffer sb, String label, boolean value) { xmlForm_field(sb,label,Boolean.toString(value)); } public static void xmlForm_field(StringBuffer sb, String label, String value) { sb.append(" <v n=\\""); sb.append(label); sb.append("\\">"); sb.append(value==null ? "<nil/>" : value ); sb.append("</v>\\n"); } public static void xmlForm_field_type_Lit(StringBuffer sb, String label, byte[] currentValue) { //TODO } public static void xmlForm_field_type_Lit(StringBuffer sb, String label, String currentValue) { sb.append(" <f n=\\""); sb.append(label); sb.append("\\">"); sb.append(currentValue==null ? "<nil/>" :currentValue); sb.append("</f>\\n"); } public static void xmlForm_field_type_Lit(StringBuffer sb, String label, java.util.Date currentValue) { sb.append(" <f n=\\""); sb.append(label); sb.append("\\">"); sb.append(currentValue==null ? "<nil/>" : #{STRUTS_TIMESTAMP_FORMATER_INSTANCE}.format(currentValue)); sb.append("</f>\\n"); } public static void xmlForm_field_type_Lit(StringBuffer sb, String label, boolean currentValue) { sb.append(" <f n=\\""); sb.append(label); sb.append("\\">"); sb.append(currentValue ? "true" : "false"); sb.append("</f>\\n"); } public static void xmlForm_field_type_Lit(StringBuffer sb, String label, long currentValue) { sb.append(" <f n=\\""); sb.append(label); sb.append("\\">"); sb.append(currentValue); sb.append("</f>\\n"); } public static void xmlForm_field_type_Lit(StringBuffer sb, String label, int currentValue) { sb.append(" <f n=\\""); sb.append(label); sb.append("\\">"); sb.append(currentValue); sb.append("</f>\\n"); } public static boolean xmlForm_field_sug_ifNull(StringBuffer sb, Object item) { if (item == null) { sb.append(" <o k=\\"nill\\"/>\\n"); } return item != null; } public static void xmlForm_field_head(StringBuffer sb, String label, String currentValue) { sb.append(" <f n=\\""); sb.append(label); sb.append("\\" k=\\""); sb.append(currentValue); sb.append("\\">\\n"); } public static void xmlForm_field_head(StringBuffer sb, String label, String[] currentValueMany,String currentValueOne) { sb.append(" <f n=\\""); sb.append(label); sb.append("\\">\\n"); if (currentValueMany!=null) { for (int i = 0; i < currentValueMany.length; i++) { String s = currentValueMany[i]; sb.append(" <s>"); sb.append(s==null ? "<nil/>" : s); sb.append("</s>\\n"); } } if (currentValueOne!=null) { sb.append(" <s>"); sb.append(currentValueOne==null ? "<nil/>" : currentValueOne); sb.append("</s>\\n"); } } public static void xmlForm_field_tail(StringBuffer sb, String label) { sb.append(" </f>\\n"); } public static void xmlForm_field_type_Enum(StringBuffer sb, String label, String currentValue, java.util.List<LabelValueBean> suggestions) { xmlForm_field_head(sb, label, currentValue); for (LabelValueBean i : suggestions) { sb.append(" <o k=\\""); sb.append(i.getValue()); sb.append("\\">"); sb.append(i.getLabel()); sb.append("</o>\\n"); } xmlForm_field_tail(sb, label); } public static void xmlFormSugOpen(StringBuffer sb, String k) { sb.append(" <o k=\\""); sb.append(k); sb.append("\\">\\n"); } public static void xmlFormSugClose(StringBuffer sb) { sb.append(" </o>\\n"); } //generates list of valid types for createAndAdd operation public static void xmlForm_field_create(java.lang.StringBuffer sb,java.util.List<?> createSug){ if(createSug!=null) { for(Object itemObj : createSug) { #{::Muml_Classifier::JAVA_ENUM_INTERFACE_QNAME} item=(#{::Muml_Classifier::JAVA_ENUM_INTERFACE_QNAME})itemObj; int i=0; if(item!=null) { sb.append(" <c k=\\""); sb.append(item.name()); sb.append("\\">"); sb.append(item.getClass().getCanonicalName()); sb.append("."); sb.append(item.name()); sb.append("</c>\\n"); //} else { //i=i+1; //log.error("!!! null enum"+i); } } } } } end return helper end |
#struts_header_generate ⇒ Object
37 38 39 40 |
# File 'lib/ontomde-java/struts/header.rb', line 37 def struts_header_generate self.rdf_Repository.struts_header_generate(self); return end |
#struts_header_link_generate ⇒ Object
4 5 6 |
# File 'lib/ontomde-java/struts/header_link.rb', line 4 def struts_header_link_generate rdf_Repository.struts_header_link_generate(struts_jsp_edit_path.to_s) end |
#struts_jsp_edit_path ⇒ Object
Returns the internal where to generate file for this object.
137 138 139 140 |
# File 'lib/ontomde-java/struts/jsp_edit.rb', line 137 def struts_jsp_edit_path path="form" return "pages/#{java_InternalFilePath}/#{path}/#{java_Name}#{context[:struts_tab].java_Name}.jsp" end |
#struts_jsp_row_path ⇒ Object
Returns the internal where to generate file for this object.
142 143 144 145 |
# File 'lib/ontomde-java/struts/jsp_edit.rb', line 142 def struts_jsp_row_path path="form" return "pages/#{java_InternalFilePath}/#{path}/#{java_Name}-row.jsp" end |
#struts_jsp_writeTabBar ⇒ Object
write tabs in JSP NOTE: CSS is design in such a way that active tab is the last one and its id is menuOptDivId0
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
# File 'lib/ontomde-java/struts/jsp_edit.rb', line 286 def struts_jsp_writeTabBar return if struts_ownedTab.size <= 1 write %{<div class="menu" id="menuDivId">\n} #cmpt =1; onglet_actif=context[:struts_tab] struts_ownedTab.each { |tab| id=tab.java_Name label="#{self.java_qualifiedName}.#{id}.tab" if tab==onglet_actif write %{\n<div class="menuOptnSelect" id="menuOptDivId0"> <div class="menuOptnSelectLink"><html:link onclick="#{STRUTS_REFRESH_ACTION}('#{id}');return false;" page="">#{struts_writeMsg(label)}</html:link></div> </div> \n} else # if cmpt==1 # write %{\n<div class="menuOptn" id="menuOptDivId#{id}" style="display:none;"> #<div class="menuLink"><html:link onclick="#{STRUTS_REFRESH_ACTION}('#{id}');return false;" page="">#{struts_writeMsg(label)}</html:link></div> #</div>} # else write %{\n<div class="menuOptn" id="menuOptDivId#{id}"> <div class="menuLink"><html:link onclick="#{STRUTS_REFRESH_ACTION}('#{id}');return false;" page="">#{struts_writeMsg(label)}</html:link></div> </div>} # end # # cmpt=cmpt+1; end } write %{</div>\n} end |
#struts_jspEdit_generateJavascript ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/ontomde-java/struts/jsp_edit_js.rb', line 7 def struts_jspEdit_generateJavascript js_include=context[:mtk_fileName].gsub(/\.[^\/]*$/,".js.jsp") mtk_writeSession("#{js_include}") { struts_jspEdit_generateJavascript_jspHeader #write("<SCRIPT>\n") struts_jspEdit_generateJavascript_commun struts_jspEdit_generateJavascript_operations struts_jspEdit_generateJavascript_edit_remove_add #write "</SCRIPT>\n" } end |
#struts_jspEdit_generateJavascript_commun ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/ontomde-java/struts/jsp_edit_js.rb', line 41 def struts_jspEdit_generateJavascript_commun write <<END_SCRIPT function #{STRUTS_REFRESH_ACTION}(tabid) { document.forms[0].#{Muml_Class::STRUTS_REQUESTED_TAB}.value=tabid; document.forms[0].#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}.value="#{STRUTS_REFRESH_ACTION}"; document.forms[0].submit(); } function #{STRUTS_RETURN_ACTION}() { document.forms[0].#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}.value="#{STRUTS_RETURN_ACTION}"; document.forms[0].submit(); } function #{STRUTS_PROCEED_ACTION}() { document.forms[0].#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}.value="#{STRUTS_PROCEED_ACTION}"; document.forms[0].submit(); } function transformToServerFormat(date, field, locale) { var time = date.getTime() var date2 = new Date(time); return date2.print("%Y/%m/%d %H:%M:%S", locale); } function hide_sel(id){ var s = document.getElementsByTagName('select'); var len = s.length; for (i = 0; i<len; i++){ s[i].style.visibility = 'hidden'; } document.getElementById(id).style.visibility = 'visible'; } function show_sel(id){ var s = document.getElementsByTagName('select'); var len = s.length; for (i = 0; i<len; i++){ s[i].style.visibility = 'visible'; } document.getElementById(id).style.visibility = 'hidden'; } END_SCRIPT end |
#struts_jspEdit_generateJavascript_edit_remove_add ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/ontomde-java/struts/jsp_edit_js.rb', line 85 def struts_jspEdit_generateJavascript_edit_remove_add context[:struts_tab].struts_ownedAttribute.each { |a| #next unless a.umlx_isComposite? #next unless a.umlx_isAssociation? #next if a.umlx_oneSide? ["edit","add"].each {|meth| f="#{meth}#{a.java_NameBean}" write <<END function #{f}(objid) { if("_"+objid != "_empty") { document.forms[0].#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}.value="#{f}"; document.forms[0].#{Muml_Class::STRUTS_REQUESTED_TAB}.value=objid; document.forms[0].submit(); } else { alert("no element selected for \\n#{struts_writeMsg("#{self.java_qualifiedName}.#{a.java_Name}")}"); } } END } write <<END function removeAndDelete#{a.java_NameBean}(objid) { if (window.confirm('<bean:message key="userMessage.deleteItem"/>')) { if("_"+objid != "_empty") { document.forms[0].#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}.value="removeAndDelete#{a.java_NameBean}"; document.forms[0].#{Muml_Class::STRUTS_REQUESTED_TAB}.value=objid; document.forms[0].submit(); } else { alert("no element selected for \\n#{struts_writeMsg("#{self.java_qualifiedName}.#{a.java_Name}")}"); } } } END } end |
#struts_jspEdit_generateJavascript_jspHeader ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/ontomde-java/struts/jsp_edit_js.rb', line 19 def struts_jspEdit_generateJavascript_jspHeader write <<END <%@ page contentType="text/javascript;charset=UTF-8" %> <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %> <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %> <%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %> END end |
#struts_jspEdit_generateJavascript_operations ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ontomde-java/struts/jsp_edit_js.rb', line 28 def struts_jspEdit_generateJavascript_operations umlx_ownedAndInheritedOperation.each {|biz| next unless biz.umlx_businessMethod? f=biz.java_Name write(%{ function #{biz.js_Name}() { document.forms[0].#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}.value="#{f}"; document.forms[0].submit(); } }) } end |
#struts_jspEdit_write_Operation ⇒ Object
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 |
# File 'lib/ontomde-java/struts/jsp_edit.rb', line 440 def struts_jspEdit_write_Operation uml_ownedOperation.each {|biz| next unless biz.uml_visibility_one.isPublic? next unless biz.umlx_businessMethod? next if biz.struts_bizOperationReverse.empty? #TODO:recuperer le nom MPC par navigation! #<html:form action="/#{self.java_Name}#{biz.java_Name}MPC-new.do"> #<html:id> #<html:submit name="[#{biz.uml_name}]"/> #</html:form> # write %{ # <a href="" onclick="#{biz.java_Name}();return false;"> # [#{biz.java_Name}] # </a> # } if context[:statemachine] && biz.java_isFsmOperation write(%{<xmdafsm:FsmZoneTag methodName="#{biz.java_Name}" state="$\{#{self.struts_actionForm_one.java_Name}.reference.persistedState\}">\n}) end write %{ <html:submit styleClass="boutonForm" onclick="#{biz.js_Name}();return false;">#{struts_writeMsg("#{biz.umlx_owner_one.java_qualifiedName}.#{biz.java_Name}")}</html:submit> } if context[:statemachine] && biz.java_isFsmOperation write(%{</xmdafsm:FsmZoneTag>\n}) end } end |
#struts_jspEditwriteSelfJSInclude ⇒ Object
3 4 5 6 |
# File 'lib/ontomde-java/struts/jsp_edit_js.rb', line 3 def struts_jspEditwriteSelfJSInclude js_include=struts_jsp_edit_path.gsub(/\.[^\/]*$/,".js.jsp") write(%{<script language="Javascript" src="#{js_include}" ></script>\n}) end |
#struts_row_generate ⇒ Object
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/ontomde-java/struts/jsp_edit.rb', line 147 def struts_row_generate mtk_writeSession( %{#{context[:webContentDir]}/#{struts_jsp_row_path}} ) { mtk_context( :struts_curClass => self) { struts_edit_writeHeader write("<%-- TPL:2 BEGIN --%>\n<tr>") struts_formAttribute.each { |a| next if a.uml_name_one=="id" next if a.uml_name_one=="isLogicallyDeleted" write("<%-- UML PROPERTY: #{a.uml_name}--%>\n") write("<td>"); write("</td>"); } write("</tr>\n<%-- TPL:2 END --%>\n") } } end |
#struts_validation_writeField(field) ⇒ Object
108 109 110 |
# File 'lib/ontomde-java/struts/validation.rb', line 108 def struts_validation_writeField(field) write "<!-- TODO -->" end |
#struts_validation_writeFields ⇒ Object
51 52 53 54 55 |
# File 'lib/ontomde-java/struts/validation.rb', line 51 def struts_validation_writeFields struts_formAttribute.each { |a| a.struts_validation_writeField } end |
#struts_write_struts_config_action_mapping ⇒ Object
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
# File 'lib/ontomde-java/struts/struts-config.rb', line 186 def struts_write_struts_config_action_mapping return if struts_action.empty? fwd="" struts_ownedTab.each{ |tab| idOnglet=tab.java_Name_one fwd=fwd+%{\n <forward name="#{idOnglet}" path="/pages/#{java_InternalFilePath}form/#{java_Name}#{idOnglet}.jsp" />} } mtk_protected { write <<END <action path="/#{java_Name}-new" #{struts_get_struts_config_action_mapping_actionTypeClause} name="#{self.struts_actionForm_one.java_Name}" scope="session" validate="false" cancellable="true" parameter="#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}" input="/pages/#{java_InternalFilePath}form/#{java_Name}#{struts_defaultTabId}.jsp" >#{fwd} <forward name="cancel" path="/Welcome.do" /> <forward name="#{STRUTS_INPUT_FWD}" path="/pages/#{java_InternalFilePath}form/#{java_Name}#{struts_defaultTabId}.jsp"/> </action> END struts_ownedTab.each{ |tab| idOnglet=tab.java_Name_one #struts_tabs.each{|idOnglet| write <<END <action path="/#{java_Name}#{idOnglet}-submit" #{struts_get_struts_config_action_mapping_actionTypeClause} name="#{self.struts_actionForm_one.java_Name}" scope="session" validate="true" cancellable="true" parameter="#{Muml_Class::STRUTS_DISPATCH_FIELD_NAME}" input="/pages/#{java_InternalFilePath}form/#{java_Name}#{idOnglet}.jsp" >#{fwd} <forward name="cancel" path="/Welcome.do" /> <forward name="#{STRUTS_INPUT_FWD}" path="/pages/#{java_InternalFilePath}form/#{java_Name}#{idOnglet}.jsp"/> </action> END } } end |
#struts_write_struts_config_form_bean ⇒ Object
166 167 168 169 170 171 172 173 |
# File 'lib/ontomde-java/struts/struts-config.rb', line 166 def struts_write_struts_config_form_bean return if struts_actionForm.empty? write <<END <form-bean name="#{self.struts_actionForm_one.java_uniqueName}" type="#{struts_actionForm_one.java_qualifiedName}"/> END #<!-- set-property property="example" value="EXAMPLE"/ --> end |
#struts_write_validation_config_formset ⇒ Object
44 45 46 47 48 49 |
# File 'lib/ontomde-java/struts/validation.rb', line 44 def struts_write_validation_config_formset return if struts_actionForm.empty? write %{<form name="#{self.struts_actionForm_one.java_uniqueName}">\n} struts_validation_writeFields write %{</form>\n} end |
#umlx_addGetStaticRoleOperation! ⇒ Object
Adds methods which returns computed grants to user. This methods returns an list of granted rights (which are stored as java enums)
Example:
-
public List<SecurityRole> getComputedAccessControlGrant(org.acegi.security.UserDetails userName
254 255 256 257 258 259 260 261 262 263 264 265 266 |
# File 'lib/ontomde-java/java/security.rb', line 254 def umlx_addGetStaticRoleOperation! m=self.umlx_createAndAddOperation("#{rdf_uri}_getComputedAccessControlGrant","getComputedAccessControlGrant") r=m.umlx_createAndAddReturnParameter("#{m.rdf_uri}_return") r.uml_type=umlx_reserved_model.umlx_getOrCreateEnumeration(Mrdf_Repository::JAVA_GLOBAL_ACCESS_CONTROL_ENUM,Muml_Classifier::UMLX_SEARCH_EVERY_MODEL) r.uml_upperValue=umlx_literal(-1) r.umlx_createAndAddComment("#{r.rdf_uri}_c1",JAVA_GETSTATIC_ROLE_COMMENT) p=m.umlx_createAndAddParameter("#{m.rdf_uri}_p1","user") p.uml_type=umlx_reserved_model.umlx_getOrCreateEnumeration("org.springframework.security.userdetails.UserDetails",Muml_Classifier::UMLX_SEARCH_EVERY_MODEL) m.java_code=JAVA_GETSTATIC_ROLE_CODE end |
#vso_DataSourceName ⇒ Object
255 256 257 |
# File 'lib/ontomde-java/vmware/vso.rb', line 255 def vso_DataSourceName return "DS-DRASS" end |
#vso_ownedAttribute ⇒ Object
163 164 165 166 167 168 169 |
# File 'lib/ontomde-java/vmware/vso.rb', line 163 def vso_ownedAttribute s=Set.new umlx_ownedAttributeHierarchical.each { |op| s.add(op) } return s end |
#vso_ownedOperation ⇒ Object
155 156 157 158 159 160 161 |
# File 'lib/ontomde-java/vmware/vso.rb', line 155 def vso_ownedOperation s=Set.new umlx_ownedOperationHierarchical.each { |op| s.add(op) } return s end |
#vso_writeConstructors(tab) ⇒ Object
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/ontomde-java/vmware/vso.rb', line 177 def vso_writeConstructors(tab) found=false java_ownedOperation.sort { |a,b| a.java_qualifiedName.to_s <=> b.java_qualifiedName.to_s }.each { |o| next unless o.umlx_isConstructor? found=true } return unless found tab2=tab.tab tab3=tab2.tab before="#{tab}<constructors>\n" after="#{tab}</constructors>\n" encloseWrite(before,after) { java_ownedOperation.sort { |a,b| a.java_qualifiedName.to_s <=> b.java_qualifiedName.to_s }.each { |o| next unless o.umlx_isConstructor? encloseWrite("#{tab2}<constructor>\n","#{tab2}</constructor>\n") { o.vso_writeJavadoc(tab3) o.vso_writeOperationParameters(tab3) } } } end |
#vso_writeFinder(tab) ⇒ Object
209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/ontomde-java/vmware/vso.rb', line 209 def vso_writeFinder(tab) tab2=tab.tab isInventoryRoot=umlx_hasStereotype?('TROOT') before=%{#{tab}<finder type="#{java_Name}" image="images/#{java_Name}.png" datasource="#{vso_DataSourceName}" script-object="#{java_Name}" hidden="#{isInventoryRoot ? 'true' : 'false'}">\n} after="#{tab}</finder>\n" encloseWrite(before,after) { write(%{#{tab2}<id accessor="getId()"/>\n}) unless isInventoryRoot vso_writeFinderInventoryChildren(tab2) vso_writeFinderRelations(tab2) vso_writeFinderProperties(tab2) } end |
#vso_writeFinderInventoryChildren(tab) ⇒ Object
222 223 224 225 226 227 228 229 230 231 232 |
# File 'lib/ontomde-java/vmware/vso.rb', line 222 def vso_writeFinderInventoryChildren(tab) tab2=tab.tab before=%{#{tab}<inventory-children>\n} after=%{#{tab}</inventory-children>\n} encloseWrite(before,after,true) { vso_ownedAttribute.each {|p| next unless p.umlx_hasStereotype?("TCHILD") write(%{#{tab2}<relation-link name="#{p.java_Name}"/>\n}) } } end |
#vso_writeFinderProperties(tab) ⇒ Object
244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/ontomde-java/vmware/vso.rb', line 244 def vso_writeFinderProperties(tab) tab2=tab.tab before=%{#{tab}<properties>\n} after=%{#{tab}</properties>\n} encloseWrite(before,after,true) { vso_ownedAttribute.each {|p| next unless p.umlx_hasStereotype?("TLABEL") write(%{#{tab2}<property name="#{p.java_Name}" display-name="#{p.uml_name}" bean-property="#{p.java_Name}"/>\n}) } } end |
#vso_writeFinderRelations(tab) ⇒ Object
233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/ontomde-java/vmware/vso.rb', line 233 def vso_writeFinderRelations(tab) tab2=tab.tab before=%{#{tab}<relations>\n} after=%{#{tab}</relations>\n} encloseWrite(before,after,true) { vso_ownedAttribute.each {|p| next unless p.umlx_hasStereotype?("TCHILD") write(%{#{tab2}<relation name="#{p.java_Name}" type="#{p.uml_type_one.java_Name}"/>\n}) } } end |
#vso_writeMethods(tab) ⇒ Object
198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/ontomde-java/vmware/vso.rb', line 198 def vso_writeMethods(tab) tab2=tab.tab before="#{tab}<methods>\n" after="#{tab}</methods>\n" encloseWrite(before,after) { java_ownedOperation.sort { |a,b| a.java_qualifiedName.to_s <=> b.java_qualifiedName.to_s }.each { |o| next if o.umlx_isConstructor? o.java_writeOperationMapping(tab2) } } end |
#vso_writeObjectMapping(tab) ⇒ Object
171 172 173 174 175 176 |
# File 'lib/ontomde-java/vmware/vso.rb', line 171 def vso_writeObjectMapping(tab) vso_writeObject(tab,"") { |tab2| vso_writeConstructors(tab2) vso_writeMethods(tab2) } end |
#xsd_makeSerializable! ⇒ Object
Mark this java class as serializable.
-
adds implements java.io.Serializable
-
adds serialVersionUID variable
Example:
private static final long serialVersionUID = 1L;
655 656 657 658 659 660 661 662 663 664 665 666 667 668 |
# File 'lib/ontomde-java/java/xsd.rb', line 655 def xsd_makeSerializable! #xsd_implements_add("java.io.Serializable"); s=umlx_getOrCreateClass("java.io.Serializable") umlx_createAndAddImplementation(s) p=umlx_createAndAddProperty(rdf_uri+"_serialVersionUID","serialVersionUID"); p.uml_visibility=::Cuml_VisibilityKind::Private p.uml_isStatic=RDF_TRUE p.xsd_isFinal=RDF_TRUE p.xsd_isTransient=RDF_TRUE p.uml_type=umlx_dataType_long p.xsd_code="1L" p.xsd_noAccessors=RDF_TRUE end |
#xsd_writeConstructors ⇒ Object
Adds a constructor with paramter
NOTE:
-
EXPERIMENTAL
TODO: associations, et filtrer attributs static
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 727 728 |
# File 'lib/ontomde-java/java/xsd.rb', line 702 def xsd_writeConstructors write(" public #{xsd_Name}() {\n") write(" }\n") #TODO: associations ??, filtrer static if (!uml_ownedAttribute.empty?) parameters = "" uml_ownedAttribute.each { |o| if o.umlx_isAttribute? parameters << ", " parameters << o.xsd_propertyRoleType.to_s parameters << " " parameters << o.xsd_NameProperty end } if (!parameters.empty?) write("\n") parameters = parameters.slice(1, parameters.length) write(" public #{xsd_Name}(#{parameters}) {\n") uml_ownedAttribute.each { |o| if o.umlx_isAttribute? write(" set#{o.xsd_NameBean}(#{o.xsd_NameProperty});\n") end } write(" }\n") end end end |
#xsd_writeImplements ⇒ Object
write java implements declaration clause if needed.
Example:
-
implements interface1, interface2
676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 |
# File 'lib/ontomde-java/java/xsd.rb', line 676 def xsd_writeImplements imp=Set.new uml_implementation.each { |g| imp.add(g.uml_supplier_one.xsd_qualifiedName) } xsd_implements.each { |g| imp.add(g) } # sep=""# \n<!-- implements " # e="" # imp.sort{ |a,b| a <=> b}.each { |g| # write(sep) # write(g) # sep="," # e=" -->" # } # write(e) end |