Module: Muml_Classifier
- Defined in:
- lib/ontomde-uml2-crank/equals.rb,
lib/ontomde-uml2-crank/helper.rb,
lib/ontomde-uml2-crank/facelets.rb,
lib/ontomde-uml2-crank/validation.rb
Instance Method Summary collapse
- #crank_crud_relationship ⇒ Object
- #crank_editSimpleProperties ⇒ Object
- #crank_generate_form ⇒ Object
- #crank_generate_listing ⇒ Object
- #crank_generate_validation ⇒ Object
- #crank_hasCrankBeanChild? ⇒ Boolean
- #crank_isTopCrankBean ⇒ Object
- #crank_listingProperties ⇒ Object
- #crank_masterDetailRelationHelper(a) ⇒ Object
- #crank_readOnlyProperties ⇒ Object
- #crank_simpleRelationHelper(a) ⇒ Object
-
#crank_subCrankBean(ret = Set.new, abstractIncluded = false) ⇒ Object
Include the class too.
- #java_generate_equalsAndHash ⇒ Object
- #java_generateEquals(ret, callSuperEquals) ⇒ Object
- #java_generateHashCode(ret) ⇒ Object
-
#umlx_ownedAndInheritedAttribute(ret = Set.new) ⇒ Object
returns every type assignable to this classifier (this includes self and any class deriving from it).
Instance Method Details
#crank_crud_relationship ⇒ Object
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-crank/facelets.rb', line 115 def crank_crud_relationship rel = "" rels = eachCrankBeanRelations rels.each { |a| if !a.umlx_isComposite? && !a.java_isManyAssociation? rel << crank_simpleRelationHelper(a) end } bManyAsociation = false rels.each { |a| if !a.umlx_isComposite? && a.java_isManyAssociation? if !bManyAsociation rel << "<rich:tabPanel width=\"100%\">\n" bManyAsociation = true end rel << " <rich:tab label=\"${crud:createLabel('#{a.java_Name}')}\">\n" rel << crank_simpleRelationHelper(a) rel << " </rich:tab>\n" end } if bManyAsociation rel << "</rich:tabPanel>\n" end bManyAsociation = false rels.each { |a| if a.crank_isMasterFromMasterDetail? if !bManyAsociation rel << "<rich:tabPanel width=\"100%\">\n" bManyAsociation = true end rel << " <rich:tab label=\"${crud:createLabel('#{a.java_Name}')}\">\n" rel << crank_masterDetailRelationHelper(a) rel << " </rich:tab>\n" end } if bManyAsociation rel << "</rich:tabPanel>\n" end return rel end |
#crank_editSimpleProperties ⇒ Object
239 240 241 |
# File 'lib/ontomde-uml2-crank/facelets.rb', line 239 def crank_editSimpleProperties return crank_listingProperties end |
#crank_generate_form ⇒ Object
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 |
# File 'lib/ontomde-uml2-crank/facelets.rb', line 70 def crank_generate_form mtk_writeSession("#{context[:webContentDir]}/pages/crud/#{self.java_Name}/Form.xhtml") { write <<END <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:a4j="https://ajax4jsf.dev.java.net/ajax" xmlns:rich="http://richfaces.ajax4jsf.org/rich" xmlns:c="http://java.sun.com/jstl/core" xmlns:crank="http://www.googlecode.com/crank" xmlns:validation="http://code.google.com/p/krank/validation" > <ui:composition template="/templates/layout.xhtml"> <ui:define name="content"> <c:set var="adapter" value="${#{self.java_Name.downcase}Crud}" /> <c:set var="crud" value="${adapter.controller}" /> <span class="pageTitle">#{self.java_Name} Entry Form</span> <a4j:region renderRegionOnly="false"> <a4j:form id="#{self.java_Name.downcase}Form"> <crank:form crud="${crud}" parentForm="#{self.java_Name.downcase}Form" propertyNames="#{self.crank_editSimpleProperties}" readOnlyProperties="#{self.crank_readOnlyProperties}"> #{crank_crud_relationship} </crank:form> </a4j:form> </a4j:region> </ui:define> </ui:composition> </html> END } end |
#crank_generate_listing ⇒ Object
5 6 7 8 9 10 11 12 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 |
# File 'lib/ontomde-uml2-crank/facelets.rb', line 5 def crank_generate_listing mtk_writeSession("#{context[:webContentDir]}/pages/crud/#{self.java_Name}/Listing.xhtml") { write <<END <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:a4j="https://ajax4jsf.dev.java.net/ajax" xmlns:rich="http://richfaces.ajax4jsf.org/rich" xmlns:c="http://java.sun.com/jstl/core" xmlns:crank="http://www.googlecode.com/crank" > <ui:composition template="/templates/layout.xhtml"> <ui:define name="javascript"> <script type="text/javascript" src="${request.contextPath}/js/jquery.js"/> <script type="text/javascript" src="${request.contextPath}/js/messages.js"/> <script type="text/javascript" src="${request.contextPath}/js/details.js"/> </ui:define> <ui:define name="content"> <h:outputText value="#{self.java_Name}s" styleClass="pageTitle"/> <a4j:region renderRegionOnly="false"> <a4j:form id="${daoName}ListForm"> <crank:listing paginator="${paginators['#{self.java_Name}']}" jsfCrudAdapter="${cruds['#{self.java_Name}']}" propertyNames="#{self.crank_listingProperties}" pageTitle="${daoName}" parentForm="${daoName}ListForm" reRender="${daoName}ListForm" crud="${cruds['#{self.java_Name}'].controller}" END if crank_hasCrankBeanChild? write <<END clazzs=" END isFirstSubclazz = true crank_subCrankBean.each{|c| if isFirstSubclazz isFirstSubclazz = false elsif write "," end write "#{c.java_Name}" } write "\"" end write <<END /> </a4j:form> </a4j:region> </ui:define> </ui:composition> </html> END } end |
#crank_generate_validation ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/ontomde-uml2-crank/validation.rb', line 5 def crank_generate_validation uml_ownedAttribute.each { |a| #next if a.umlx_isComposite? #next unless a.umlx_isAttribute? if a.umlx_hasStereotype?('Required') a.java_annotation_add("@org.crank.annotations.validation.Required") end if a.uml_type_one.kind_of?(Muml_DataType) && !a.uml_type_one.crank_validation_annotation.nil? a.java_annotation_add(a.uml_type_one.crank_validation_annotation) end } end |
#crank_hasCrankBeanChild? ⇒ Boolean
25 26 27 28 29 30 |
# File 'lib/ontomde-uml2-crank/helper.rb', line 25 def crank_hasCrankBeanChild? uml_general_inv.each { |g| return true } return false end |
#crank_isTopCrankBean ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/ontomde-uml2-crank/helper.rb', line 17 def crank_isTopCrankBean uml_generalization.each { |g| next if g.kind_of?(Muml_Interface) return false if !g.uml_general_one.db_isTransient? } return true; end |
#crank_listingProperties ⇒ Object
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/ontomde-uml2-crank/facelets.rb', line 195 def crank_listingProperties attributes = nil umlx_ownedAndInheritedAttribute.each { |a| next if a.umlx_isComposite? next unless a.umlx_isAttribute? #next if a.uml_type_one.db_isTransient? next if a.uml_isStatic? next if a.uml_isReadOnly? next if "id" == "#{a.java_Name}" #TODO Faire mieux next if "objectVersion" == "#{a.java_Name}" #TODO Faire mieux if attributes.nil? attributes = "#{a.java_Name}" else attributes << ",#{a.java_Name}" end } if (attributes.nil?) attributes = "" end return attributes end |
#crank_masterDetailRelationHelper(a) ⇒ Object
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/ontomde-uml2-crank/facelets.rb', line 173 def crank_masterDetailRelationHelper(a) rel=<<CODE <crank:detailListingExtended detailController="${#{a.java_Name.downcase}From#{java_Name}To#{a.uml_type_one.java_Name}Controller}" propertyNames="#{a.uml_type_one.crank_listingProperties}" editRelation="${true}" CODE if a.uml_type_one.crank_hasCrankBeanChild? rel << " clazzs=\"" isFirstSubclazz = true a.uml_type_one.crank_subCrankBean.each{|c| if isFirstSubclazz isFirstSubclazz = false elsif rel << "," end rel << "#{c.java_Name}" } rel << "\"" end rel << " />\n" return rel end |
#crank_readOnlyProperties ⇒ Object
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
# File 'lib/ontomde-uml2-crank/facelets.rb', line 217 def crank_readOnlyProperties attributes = nil umlx_ownedAndInheritedAttribute.each { |a| next if a.umlx_isComposite? next unless a.umlx_isAttribute? #next if a.uml_type_one.db_isTransient? next if a.uml_isStatic? next if !a.uml_isReadOnly? next if "id" == "#{a.java_Name}" #TODO Faire mieux next if "objectVersion" == "#{a.java_Name}" #TODO Faire mieux if attributes.nil? attributes = "#{a.java_Name}" else attributes << ",#{a.java_Name}" end } if (attributes.nil?) attributes = "" end return attributes end |
#crank_simpleRelationHelper(a) ⇒ Object
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/ontomde-uml2-crank/facelets.rb', line 156 def crank_simpleRelationHelper(a) rel="" if a.java_isManyAssociation? rel += " <crank:selectManyExtended jsfSelectManyController=" elsif rel += " <crank:selectOneListing jsfSelectOneController=" end rel +=<<CODE "${#{a.java_Name.downcase}From#{java_Name}To#{a.uml_type_one.java_Name}Controller}" propertyNames="#{a.uml_type_one.crank_listingProperties}" parentForm="#{self.java_Name.downcase}Form" editRelation="${true}" /> CODE return rel end |
#crank_subCrankBean(ret = Set.new, abstractIncluded = false) ⇒ Object
Include the class too
33 34 35 36 37 38 |
# File 'lib/ontomde-uml2-crank/helper.rb', line 33 def crank_subCrankBean(ret=Set.new, abstractIncluded=false) umlx_assignableClassifier().sort{ |a,b| a <=> b}.each{ |c| ret.add(c) if abstractIncluded || !c.uml_isAbstract? } return ret end |
#java_generate_equalsAndHash ⇒ Object
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/ontomde-uml2-crank/equals.rb', line 3 def java_generate_equalsAndHash ret=Set.new uml_ownedAttribute.each {|biz| ret << biz if biz.umlx_hasStereotype?("EqualsValue") } if !ret.empty? java_generateEquals(ret, !crank_isTopCrankBean) java_generateHashCode(ret) end end |
#java_generateEquals(ret, callSuperEquals) ⇒ Object
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 |
# File 'lib/ontomde-uml2-crank/equals.rb', line 15 def java_generateEquals(ret, callSuperEquals) me=self.umlx_createAndAddOperation(self.rdf_uri+"_equals") me.uml_name="equals" # me.uml_class=self me.uml_visibility=Cuml_VisibilityKind::Public rme=me.umlx_createAndAddReturnParameter("#{me.rdf_uri}_ret") rme.uml_type=umlx_getOrCreateDataType("boolean") rpe=me.umlx_createAndAddParameter("#{me.rdf_uri}_par", "o") rpe.uml_type=umlx_getOrCreateClass("Object") me.java_annotation_add("@Override") meCode = <<CODE if(this == o) { return true; } if(o==null || !(o instanceof #{self.java_Name})) { return false; } CODE if callSuperEquals meCode << <<CODE if !super.equals(o) { return false; } CODE end meCode << <<CODE final #{self.java_Name} _o = (#{self.java_Name}) o; CODE ret.each { |a| meCode << <<CODE if (#{a.java_Name} != null ? !#{a.java_Name}.equals(_o.#{a.java_Name}) : _o.#{a.java_Name} != null) { return false; } CODE } meCode << <<CODE return true; CODE me.java_code = meCode end |
#java_generateHashCode(ret) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/ontomde-uml2-crank/equals.rb', line 59 def java_generateHashCode(ret) me=self.umlx_createAndAddOperation(self.rdf_uri+"_hash") me.uml_name="hashCode" me.uml_class=self me.uml_visibility=Cuml_VisibilityKind::Public rme=me.umlx_createAndAddReturnParameter("#{me.rdf_uri}_ret") rme.uml_type=umlx_getOrCreateDataType("int") me.java_annotation_add("@Override") meCode = <<CODE final int prime = 31; int result = 1; CODE ret.each { |a| meCode << <<CODE result = prime * result + ((#{a.java_Name} == null) ? 0 : #{a.java_Name}.hashCode()); CODE } meCode << <<CODE return result; CODE me.java_code = meCode end |
#umlx_ownedAndInheritedAttribute(ret = Set.new) ⇒ Object
returns every type assignable to this classifier (this includes self and any class deriving from it)
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/ontomde-uml2-crank/helper.rb', line 6 def umlx_ownedAndInheritedAttribute(ret=Set.new) uml_ownedAttribute.each {|biz| ret << biz } uml_generalization.each { |g| next if g.kind_of?(Muml_Interface) g.uml_general_one.umlx_ownedAndInheritedAttribute(ret) } return ret end |