Module: Muml_Property
- Includes:
- Mjava_Annotation, Mxsd_Annotation
- Defined in:
- lib/ontomde-java/java/security.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/mapping.rb,
lib/ontomde-java/struts/form.rb,
lib/ontomde-java/java/javadoc.rb,
lib/ontomde-java/crank/crankJpa.rb,
lib/ontomde-java/struts/jsp_edit.rb,
lib/ontomde-java/struts/validation.rb,
lib/ontomde-java/java/operationAsClass.rb,
lib/ontomde-java/java/accessorSignature.rb,
lib/ontomde-java/java/enumCompatibilityLayer.rb
Overview
Authentification and security model enhancements. Used in acegi integration.
Constant Summary collapse
- DEFAULT_CASCADE =
'(cascade=CascadeType.ALL)'
- DEFAULT_CASCADE_I =
',cascade=CascadeType.ALL'
- STRUTS_ENUM_AS_STRING =
true
- CRANK_DEFAULT_CASCADE =
"(cascade={javax.persistence.CascadeType.MERGE, javax.persistence.CascadeType.PERSIST, javax.persistence.CascadeType.REFRESH})"
- CRANK_DEFAULT_CASCADE_I =
",cascade={javax.persistence.CascadeType.MERGE, javax.persistence.CascadeType.PERSIST, javax.persistence.CascadeType.REFRESH}"
Instance Method Summary collapse
- #as_lazyMode ⇒ Object
- #as_write ⇒ Object
-
#as_write_metadata ⇒ Object
return “true”.
- #crank_isDetailFromMasterDetail? ⇒ Boolean
- #crank_isMasterFromMasterDetail? ⇒ Boolean
-
#java_addEnumStringAttribute! ⇒ Object
add string as enum compatibility layer string.
- #java_isMethodToClassApplyToOrReturn? ⇒ Boolean
- #java_isMethodToClassReturn? ⇒ Boolean
-
#java_javadocLink(location = nil) ⇒ Object
returns a javadoc link suitable for @see and @link.
-
#java_write ⇒ Object
write java attribute variable (Uses java_writePropertyComment, java_writePropertyModifiers ,java_propertyRoleType,java_NameProperty).
- #java_writeFinalModifier ⇒ Object
-
#java_writeGetterComment ⇒ Object
Methode vide.
-
#java_writeJavadoc ⇒ Object
write property javadoc comment.
-
#java_writePropertyComment ⇒ Object
Methode vide.
-
#java_writePropertyModifiers ⇒ Object
write java modifiers if needed (public, static, …) (Uses java_visibilityModifiers, java_writeStaticModifier) example: private static final transient long.
-
#java_writeSetterComment ⇒ Object
Methode vide.
-
#java_writeTransient ⇒ Object
write java transient modifier if needed.
- #jpa_addFetchType(ah) ⇒ Object
- #jpa_addJoinColumn!(ah) ⇒ Object
-
#jpa_addJoinTable(ah) ⇒ Object
adds a java annotation to specify the name of the join table.
- #jpa_addPersistenceBidirManyToManyMaster!(ah) ⇒ Object
- #jpa_addPersistenceBidirManyToManySlave!(ah) ⇒ Object
- #jpa_addPersistenceBidirManyToOneMaster!(ah) ⇒ Object
- #jpa_addPersistenceBidirManyToOneSlave!(ah) ⇒ Object
- #jpa_addPersistenceBidirOneToManyMaster!(ah) ⇒ Object
- #jpa_addPersistenceBidirOneToManySlave!(ah) ⇒ Object
- #jpa_addPersistenceBidirOneToOneMaster!(ah) ⇒ Object
- #jpa_addPersistenceBidirOneToOneSlave!(ah) ⇒ Object
-
#jpa_addPersistenceManyAttribute!(ah) ⇒ Object
adds JPA annotation for an attribute with a cardinality *.
-
#jpa_addPersistenceOneAttribute!(ah) ⇒ Object
adds JPA annotation for an attribute with a cardinality 0..1 or 1.
-
#jpa_addPersistenceTo!(ah) ⇒ Object
adds property persistence annotation to annotationHolder.
- #jpa_addPersistenceToAssociation!(ah) ⇒ Object
- #jpa_addPersistenceToAssociationBidir!(ah) ⇒ Object
- #jpa_addPersistenceToAssociationUnidir!(ah) ⇒ Object
- #jpa_addPersistenceToAttribute!(ah) ⇒ Object
- #jpa_addPersistenceToAttribute_TypeModificator!(ah) ⇒ Object
- #jpa_addPersistenceUnidirManyToMany!(ah) ⇒ Object
- #jpa_addPersistenceUnidirManyToOne!(ah) ⇒ Object
- #jpa_addPersistenceUnidirOneToMany!(ah) ⇒ Object
- #jpa_addPersistenceUnidirOneToOne!(ah) ⇒ Object
- #jpa_addRelationCascadeType(isIncludeType = true) ⇒ Object
- #jpa_isPersistent? ⇒ Boolean
- #nil_lvb(obj) ⇒ Object
- #struts_addActionFormAttribute!(form) ⇒ Object
-
#struts_addActionFormAttributeEnumeration!(form) ⇒ Object
Adds to the form class, a suggester operation corresponding to this attribute.
-
#struts_addActionFormAttributeReference!(form) ⇒ Object
suggester for a list of objects.
-
#struts_copyAsFormField!(form) ⇒ Object
adds a paginator field when cardinality >1.
-
#struts_edit_writeFieldProp(owner) ⇒ Object
writes java code for a property * labels * editing zones * security management * help zone.
-
#struts_edit_writeFieldPropCode(owner) ⇒ Object
writes java code for a property * labels * editing zones * help zone.
- #struts_edit_writeHelpMessage(owner) ⇒ Object
- #struts_edit_writeHelpToggle ⇒ Object
- #struts_edit_writeValidateErrorMessage ⇒ Object
- #struts_ignoreInForm?(ignoreDbId = true) ⇒ Boolean
- #struts_validation_writeField ⇒ Object
- #super_jpa_addPersistenceToAssociation! ⇒ Object
-
#umlx_isSecured? ⇒ Boolean
returns true if element is marked as secured.
- #writeEnclose(before, after) ⇒ Object
- #xsd_ignoreMe? ⇒ Boolean
- #xsd_writeFinalModifier ⇒ Object
-
#xsd_writeGetterComment ⇒ Object
Methode vide.
- #xsd_writeMaxOccurs ⇒ Object
- #xsd_writeMinOccurs ⇒ Object
-
#xsd_writeProperty ⇒ Object
write java attribute variable (Uses xsd_writePropertyComment, xsd_writePropertyModifiers ,xsd_propertyRoleType,xsd_NameProperty).
-
#xsd_writePropertyComment ⇒ Object
Methode vide.
-
#xsd_writePropertyModifiers ⇒ Object
write java modifiers if needed (public, static, …) (Uses xsd_visibilityModifiers, xsd_writeStaticModifier) example: private static final transient long.
-
#xsd_writeSetterComment ⇒ Object
Methode vide.
-
#xsd_writeTransient ⇒ Object
write java transient modifier if needed.
Methods included from Mjava_Annotation
#java_writeAnnotation, #java_writeMdatkAnno, #java_writeParamAnnotation
Methods included from Mxsd_Annotation
Instance Method Details
#as_lazyMode ⇒ Object
82 83 84 85 |
# File 'lib/ontomde-java/flex/main.rb', line 82 def as_lazyMode return "false" #return "true" end |
#as_write ⇒ Object
101 102 103 104 105 106 107 |
# File 'lib/ontomde-java/flex/main.rb', line 101 def as_write return if uml_type_one.kind_of?(Muml_Enumeration) write("var"); write(" _#{as_NameProperty}") write(":#{as_propertyAssociationType}") write(";\n") end |
#as_write_metadata ⇒ Object
return “true”
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/ontomde-java/flex/main.rb', line 86 def if uml_type_one.kind_of?(Muml_DataType) write %{ <!-- datatype property="#{as_Name}" -->\n} elsif umlx_oneToMany? write %{ <one-to-many property="#{as_Name}" destination="#{uml_type_one.as_destinationName}" lazy="#{as_lazyMode}"/>\n} elsif umlx_manyToOne? write %{ <!-- many-to-one property="#{as_Name}" destination="#{uml_type_one.as_destinationName}" lazy="#{as_lazyMode}"/ -->\n} elsif umlx_oneToOne? write %{ <!-- one-to-one property="#{as_Name}" destination="#{uml_type_one.as_destinationName}" lazy="#{as_lazyMode}"/ -->\n} elsif umlx_manyToMany? write %{ <!-- many-to-many property="#{as_Name}" destination="#{uml_type_one.as_destinationName}" lazy="#{as_lazyMode}"/ -->\n} else write %{ <!-- property="#{as_Name}" destination="#{uml_type_one.as_destinationName}" lazy="#{as_lazyMode}"/ -->\n} end end |
#crank_isDetailFromMasterDetail? ⇒ Boolean
41 42 43 44 45 46 |
# File 'lib/ontomde-java/crank/crankJpa.rb', line 41 def crank_isDetailFromMasterDetail? oe=umlx_otherEnd binav=(!oe.nil?) && oe.umlx_isNavigable? return false if !binav return oe.crank_isMasterFromMasterDetail? end |
#crank_isMasterFromMasterDetail? ⇒ Boolean
37 38 39 40 |
# File 'lib/ontomde-java/crank/crankJpa.rb', line 37 def crank_isMasterFromMasterDetail? return true if self.umlx_isComposite? return false end |
#java_addEnumStringAttribute! ⇒ Object
add string as enum compatibility layer string
68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/ontomde-java/java/enumCompatibilityLayer.rb', line 68 def java_addEnumStringAttribute! return unless uml_type_one.kind_of?(Muml_Enumeration) c=umlx_owner_one a=self #log.debug { "adding attribute for #{self} #{c}" } rr=c.umlx_createAndAddProperty(a.rdf_uri+"_asString",a.uml_name_one+"AsString") rr.uml_type=c.umlx_dataType_string rr.uml_visibility=::Cuml_VisibilityKind::Private rr.umlx_stringMappingForEnum=a rr.uml_isDerived=RDF_TRUE rr.uml_upperValue=a.uml_upperValue rr.uml_lowerValue=a.uml_lowerValue end |
#java_isMethodToClassApplyToOrReturn? ⇒ Boolean
80 81 82 83 |
# File 'lib/ontomde-java/java/operationAsClass.rb', line 80 def java_isMethodToClassApplyToOrReturn? s=uml_name.to_s return (s==Muml_Classifier::STRUTS_APPLY_TO_PARAM || s==Muml_Classifier::STRUTS_RESULT_PARAM_NAME) end |
#java_isMethodToClassReturn? ⇒ Boolean
77 78 79 |
# File 'lib/ontomde-java/java/operationAsClass.rb', line 77 def java_isMethodToClassReturn? return uml_name.to_s==Muml_Classifier::STRUTS_RESULT_PARAM_NAME end |
#java_javadocLink(location = nil) ⇒ Object
returns a javadoc link suitable for @see and @link.
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/ontomde-java/java/javadoc.rb', line 44 def java_javadocLink(location=nil) o=umlx_owner_one if location==o #same class return "##{java_Name}" else #different class return "#{o.java_qualifiedName}##{java_Name}" end end |
#java_write ⇒ Object
write java attribute variable (Uses java_writePropertyComment, java_writePropertyModifiers ,java_propertyRoleType,java_NameProperty)
NOTE:
-
getter/setter/… methods are handled by model transformation
1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 |
# File 'lib/ontomde-java/java/java.rb', line 1215 def java_write write("\n") if !uml_isDerived? java_writePropertyComment java_writeJavadoc java_writeAnnotation java_writeMdatkAnno(['javadoc','annotations']) if context[:hasGlobalReverse] write("\t"); java_writePropertyModifiers write("#{java_propertyAssociationType}") write(" #{java_NameProperty}") if !java_code.empty? write" = #{java_code}" elsif(context[:java_generateSetAttributeInitializer]) if (!umlx_upperValueIsOne?) && uml_qualifier.empty? && java_use_Arrays? write(" = new "); write(uml_type_one.java_qualifiedName) write("[1]") elsif (!umlx_upperValueIsOne?) && uml_qualifier.empty? write("= new "); write(java_propertyAssociationConcreteType) write("()") elsif umlx_upperValueIsOne? && !uml_qualifier.empty? write(" = new "); write(java_propertyAssociationConcreteType) write("()") elsif !umlx_upperValueIsOne? && !uml_qualifier.empty? #write(" = new "); #write(java_propertyAssociationConcreteType) #write("()") end end write(";\n") end end |
#java_writeFinalModifier ⇒ Object
1267 1268 1269 1270 |
# File 'lib/ontomde-java/java/java.rb', line 1267 def java_writeFinalModifier return unless java_isFinal? write "final " end |
#java_writeGetterComment ⇒ Object
Methode vide
1204 1205 |
# File 'lib/ontomde-java/java/java.rb', line 1204 def java_writeGetterComment end |
#java_writeJavadoc ⇒ Object
write property javadoc comment.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/ontomde-java/java/javadoc.rb', line 57 def java_writeJavadoc return unless context[:javadoc] c="" sep="" uml_ownedComment.each { |comment| c="#{c}#{sep}#{comment.uml_body_one}" sep="\n" } mtk_protected(Mrdf_Resource::NOREVERSE,"javadoc",context[:hasGlobalReverse]||context[:hideJavadocReverseTag]) { s=mtk_stss { c.java_writeJavadoc(self) #Note: RSM exports adds an extraneous http:// #Note: TODO: This code is RSM 6 specific # %{@see <a href="#{context[:rsm6WebDocURI]}#{UriNamespace.instance.unalias(rdf_uri).gsub(/http:\/\/kb#/,"")}-content.html">UML documentation.</a>}.java_writeJavadoc(self) unless context[:rsm6WebDocURI].empty? } if(!s.nil? && !s.empty?) write("\t/**\n"); write(s) write("\t */\n") end } end |
#java_writePropertyComment ⇒ Object
Methode vide
1201 1202 |
# File 'lib/ontomde-java/java/java.rb', line 1201 def java_writePropertyComment end |
#java_writePropertyModifiers ⇒ Object
write java modifiers if needed (public, static, …) (Uses java_visibilityModifiers, java_writeStaticModifier) example: private static final transient long
1257 1258 1259 1260 1261 1262 1263 1264 1265 |
# File 'lib/ontomde-java/java/java.rb', line 1257 def java_writePropertyModifiers uml_visibility.each { |v| write(v.java_visibilityModifiers) } java_writeStaticModifier java_writeFinalModifier java_writeTransient end |
#java_writeSetterComment ⇒ Object
Methode vide
1207 1208 |
# File 'lib/ontomde-java/java/java.rb', line 1207 def java_writeSetterComment end |
#java_writeTransient ⇒ Object
write java transient modifier if needed.
1273 1274 1275 1276 |
# File 'lib/ontomde-java/java/java.rb', line 1273 def java_writeTransient return unless java_isTransient? write("transient ") end |
#jpa_addFetchType(ah) ⇒ Object
63 64 65 66 |
# File 'lib/ontomde-java/jpa/mapping.rb', line 63 def jpa_addFetchType(ah) ah.umlx_owner_one.java_import_add('javax.persistence.FetchType') return "fetch=FetchType.LAZY" end |
#jpa_addJoinColumn!(ah) ⇒ Object
204 205 206 207 |
# File 'lib/ontomde-java/jpa/mapping.rb', line 204 def jpa_addJoinColumn!(ah) ah.java_annotation_add(%{@JoinColumn(name = "#{jpa_Name}_FK")}) ah.umlx_owner_one.java_import_add('javax.persistence.JoinColumn') end |
#jpa_addJoinTable(ah) ⇒ Object
adds a java annotation to specify the name of the join table.
Note:
Explicitely naming join colums and join table is required whenever multiple associations exists between two classes and also with reflexive associations.
Examples: Object A (rolea)–>(roleb) Object B Table A_roleb
field : A_id
field : B_id
Object A (rolea)–>(roleb) Object A
Table A_roleb
field : A_id
field : A_self_id
169 170 171 172 173 174 175 176 177 178 |
# File 'lib/ontomde-java/jpa/mapping.rb', line 169 def jpa_addJoinTable(ah) postfix=(uml_ownedAttribute_inv_one==uml_type_one) ? '_self' : '' ah.java_annotation_add %{ @JoinTable( name = "#{uml_ownedAttribute_inv_one.jpa_Name}_#{java_NameProperty}", joinColumns={@JoinColumn(name = "#{uml_ownedAttribute_inv_one.jpa_Name}_id")}, inverseJoinColumns={@JoinColumn(name = "#{uml_type_one.jpa_Name}#{postfix}_id")} )} ah.umlx_owner_one.java_import_add('javax.persistence.JoinTable') ah.umlx_owner_one.java_import_add('javax.persistence.JoinColumn') end |
#jpa_addPersistenceBidirManyToManyMaster!(ah) ⇒ Object
103 104 105 106 107 108 |
# File 'lib/ontomde-java/jpa/mapping.rb', line 103 def jpa_addPersistenceBidirManyToManyMaster!(ah) ah.java_annotation_add("@ManyToMany (#{jpa_addFetchType(ah)} #{jpa_addRelationCascadeType(true)})") ah.umlx_owner_one.java_import_add('javax.persistence.ManyToMany') #jpa_addJoinColumn!(ah) jpa_addJoinTable(ah) end |
#jpa_addPersistenceBidirManyToManySlave!(ah) ⇒ Object
109 110 111 112 113 114 115 116 |
# File 'lib/ontomde-java/jpa/mapping.rb', line 109 def jpa_addPersistenceBidirManyToManySlave!(ah) ah.java_annotation_add("@ManyToMany (#{jpa_addFetchType(ah)} #{jpa_addRelationCascadeType(true)}, mappedBy=\"#{umlx_otherEnd.java_NameProperty}\")") ah.umlx_owner_one.java_import_add('javax.persistence.ManyToMany') #jpa_addJoinColumn!(ah) #Do not add join column ! #(or you will get 2 join tables) #jpa_addJoinTable(ah) end |
#jpa_addPersistenceBidirManyToOneMaster!(ah) ⇒ Object
138 139 140 141 142 143 144 |
# File 'lib/ontomde-java/jpa/mapping.rb', line 138 def jpa_addPersistenceBidirManyToOneMaster!(ah) #ah.java_annotation_add(%{@ManyToOne(mappedBy="#{umlx_otherEnd.java_NameProperty}")}) ah.java_annotation_add(%{@ManyToOne (#{jpa_addFetchType(ah)} #{jpa_addRelationCascadeType(true)})}) ah.umlx_owner_one.java_import_add('javax.persistence.ManyToOne') #ah.java_annotation_add(%{@JoinColumn(name="#{java_NameProperty}_fk"}) jpa_addJoinColumn!(ah) end |
#jpa_addPersistenceBidirManyToOneSlave!(ah) ⇒ Object
145 146 147 148 149 150 151 |
# File 'lib/ontomde-java/jpa/mapping.rb', line 145 def jpa_addPersistenceBidirManyToOneSlave!(ah) #ah.java_annotation_add(%{@ManyToOne(mappedBy="#{umlx_otherEnd.java_NameProperty}")}) ah.java_annotation_add(%{@ManyToOne (#{jpa_addFetchType(ah)} #{jpa_addRelationCascadeType(true)})}) ah.umlx_owner_one.java_import_add('javax.persistence.ManyToOne') #ah.java_annotation_add(%{@JoinColumn(name="#{java_NameProperty}_fk"}) jpa_addJoinColumn!(ah) end |
#jpa_addPersistenceBidirOneToManyMaster!(ah) ⇒ Object
128 129 130 131 |
# File 'lib/ontomde-java/jpa/mapping.rb', line 128 def jpa_addPersistenceBidirOneToManyMaster!(ah) ah.java_annotation_add(%{@OneToMany (#{jpa_addFetchType(ah)}, mappedBy="#{umlx_otherEnd.java_NameProperty}"#{jpa_addRelationCascadeType})}) ah.umlx_owner_one.java_import_add('javax.persistence.OneToMany') end |
#jpa_addPersistenceBidirOneToManySlave!(ah) ⇒ Object
132 133 134 135 136 |
# File 'lib/ontomde-java/jpa/mapping.rb', line 132 def jpa_addPersistenceBidirOneToManySlave!(ah) ah.java_annotation_add(%{@OneToMany (#{jpa_addFetchType(ah)}, mappedBy="#{umlx_otherEnd.java_NameProperty}"#{jpa_addRelationCascadeType})}) ah.umlx_owner_one.java_import_add('javax.persistence.OneToMany') #jpa_addJoinColumn!(ah) end |
#jpa_addPersistenceBidirOneToOneMaster!(ah) ⇒ Object
118 119 120 121 122 |
# File 'lib/ontomde-java/jpa/mapping.rb', line 118 def jpa_addPersistenceBidirOneToOneMaster!(ah) ah.java_annotation_add("@OneToOne (#{jpa_addFetchType(ah)} #{jpa_addRelationCascadeType(true)})") ah.umlx_owner_one.java_import_add('javax.persistence.OneToOne') jpa_addJoinColumn!(ah) end |
#jpa_addPersistenceBidirOneToOneSlave!(ah) ⇒ Object
123 124 125 126 |
# File 'lib/ontomde-java/jpa/mapping.rb', line 123 def jpa_addPersistenceBidirOneToOneSlave!(ah) ah.java_annotation_add(%{@OneToOne(#{jpa_addFetchType(ah)}, mappedBy="#{umlx_otherEnd.java_NameProperty}" #{jpa_addRelationCascadeType})}) ah.umlx_owner_one.java_import_add('javax.persistence.OneToOne') end |
#jpa_addPersistenceManyAttribute!(ah) ⇒ Object
adds JPA annotation for an attribute with a cardinality *
193 194 195 196 197 198 199 200 201 202 |
# File 'lib/ontomde-java/jpa/mapping.rb', line 193 def jpa_addPersistenceManyAttribute!(ah) if true #use hibernate extensions ah.java_annotation_add(%{@CollectionOfElements}) ah.umlx_owner_one.java_import_add('org.hibernate.annotations.CollectionOfElements') else ah.java_annotation_add(%{@Transient //TODO: standard JPA cannot handle this case. Hibernate extension @CollectionOfElements is required}) ah.umlx_owner_one.java_import_add('javax.persistence.Transient') end end |
#jpa_addPersistenceOneAttribute!(ah) ⇒ Object
adds JPA annotation for an attribute with a cardinality 0..1 or 1
181 182 183 184 185 186 187 188 189 190 |
# File 'lib/ontomde-java/jpa/mapping.rb', line 181 def jpa_addPersistenceOneAttribute!(ah) ml=DatatypeMapping.instance.getMapping(self.uml_type_one).maxStringLength if ml.nil? ah.java_annotation_add(%{@Basic}) ah.umlx_owner_one.java_import_add('javax.persistence.Basic') else ah.java_annotation_add(%{@Column(length=#{ml})}) ah.umlx_owner_one.java_import_add('javax.persistence.Column') end end |
#jpa_addPersistenceTo!(ah) ⇒ Object
adds property persistence annotation to annotationHolder.
annotationHolder may be depending on annotation style:
-
property itself self
-
getter for the property
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
# File 'lib/ontomde-java/jpa/mapping.rb', line 214 def jpa_addPersistenceTo!(ah) return if ah.uml_isDerived? if uml_type_one.kind_of?(Muml_Interface) txt= %{ ERROR: JPA Persistence does not support interfaces. ERROR: An association must point to a class. ERROR: class: #{umlx_owner_one.java_qualifiedName} ERROR: attribute: #{java_Name} ERROR type #{uml_type_one.java_qualifiedName} } log.error txt raise Exception.new(txt) elsif umlx_isAttribute? jpa_addPersistenceToAttribute!(ah) else jpa_addPersistenceToAssociation!(ah) end end |
#jpa_addPersistenceToAssociation!(ah) ⇒ Object
249 250 251 252 253 254 255 256 257 |
# File 'lib/ontomde-java/jpa/mapping.rb', line 249 def jpa_addPersistenceToAssociation!(ah) oe=umlx_otherEnd binav=(!oe.nil?) && oe.umlx_isNavigable? if binav jpa_addPersistenceToAssociationBidir!(ah) else jpa_addPersistenceToAssociationUnidir!(ah) end end |
#jpa_addPersistenceToAssociationBidir!(ah) ⇒ Object
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 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
# File 'lib/ontomde-java/jpa/mapping.rb', line 274 def jpa_addPersistenceToAssociationBidir!(ah) toOne=umlx_upperValueIsOne? fromOne=umlx_otherEnd.nil? ? true : umlx_otherEnd.umlx_upperValueIsOne? master=umlx_masterEnd? if fromOne && toOne && (master) jpa_addPersistenceBidirOneToOneMaster!(ah) elsif fromOne && toOne && (!master) jpa_addPersistenceBidirOneToOneSlave!(ah) elsif fromOne && !toOne && (master) jpa_addPersistenceBidirOneToManyMaster!(ah) elsif fromOne && !toOne && (!master) jpa_addPersistenceBidirOneToManySlave!(ah) elsif !fromOne && toOne && (master) jpa_addPersistenceBidirManyToOneMaster!(ah) elsif !fromOne && toOne && (!master) jpa_addPersistenceBidirManyToOneSlave!(ah) elsif !fromOne && !toOne && (master) jpa_addPersistenceBidirManyToManyMaster!(ah) elsif !fromOne && !toOne && (!master) jpa_addPersistenceBidirManyToManySlave!(ah) else raise Warning.new('Internal error') end return # if umlx_oneToOne? # if umlx_otherEnd.nil? || !umlx_otherEnd.umlx_isNavigable? # jpa_addPersistenceUnidirOneToOne!(ah) # #ah.java_annotation_add('@OneToOne') # # elsif umlx_masterEnd? # ah.java_annotation_add("@OneToOne(cascade = {CascadeType.MERGE, CascadeType.REFRESH, CascadeType.PERSIST, CascadeType.REMOVE})") # ah.java_annotation_add("@JoinColumn(name=\"#{umlx_otherEnd.java_NameBean}_fk\")") # elsif # ah.java_annotation_add("@OneToOne(mappedBy=\"#{umlx_otherEnd.java_NameProperty}\")") # end # end # if umlx_manyToOne? # if umlx_unidirectionnel? # ah.java_annotation_add("//TOFIX MANY TO ONE Unideirectionnel NOT IMPLEMENTED") # elsif # ah.java_annotation_add("@ManyToOne") # ah.java_annotation_add("@JoinColumn(name=\"#{umlx_otherEnd.java_NameBean}_fk\")") # end # end end |
#jpa_addPersistenceToAssociationUnidir!(ah) ⇒ Object
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
# File 'lib/ontomde-java/jpa/mapping.rb', line 259 def jpa_addPersistenceToAssociationUnidir!(ah) toOne=umlx_upperValueIsOne? fromOne=umlx_otherEnd.nil? ? true : umlx_otherEnd.umlx_upperValueIsOne? if fromOne && toOne jpa_addPersistenceUnidirOneToOne!(ah) elsif fromOne && !toOne jpa_addPersistenceUnidirOneToMany!(ah) elsif !fromOne && toOne jpa_addPersistenceUnidirManyToOne!(ah) elsif !fromOne && !toOne jpa_addPersistenceUnidirManyToMany!(ah) else raise Warning.new('Internal error') end end |
#jpa_addPersistenceToAttribute!(ah) ⇒ Object
234 235 236 237 238 239 240 241 242 |
# File 'lib/ontomde-java/jpa/mapping.rb', line 234 def jpa_addPersistenceToAttribute!(ah) jpa_addPersistenceToAttribute_TypeModificator!(ah) if umlx_upperValueIsOne? jpa_addPersistenceOneAttribute!(ah) else jpa_addPersistenceManyAttribute!(ah) end return end |
#jpa_addPersistenceToAttribute_TypeModificator!(ah) ⇒ Object
244 245 246 247 |
# File 'lib/ontomde-java/jpa/mapping.rb', line 244 def jpa_addPersistenceToAttribute_TypeModificator!(ah) tpl=DatatypeMapping.instance.getMapping(self.uml_type_one) tpl.jpa_addTypeModificator(ah) end |
#jpa_addPersistenceUnidirManyToMany!(ah) ⇒ Object
97 98 99 100 101 102 |
# File 'lib/ontomde-java/jpa/mapping.rb', line 97 def jpa_addPersistenceUnidirManyToMany!(ah) ah.java_annotation_add("@ManyToMany (#{jpa_addFetchType(ah)} #{jpa_addRelationCascadeType(true)})") ah.umlx_owner_one.java_import_add('javax.persistence.ManyToMany') jpa_addJoinTable(ah) jpa_addJoinColumn!(ah) end |
#jpa_addPersistenceUnidirManyToOne!(ah) ⇒ Object
91 92 93 94 95 |
# File 'lib/ontomde-java/jpa/mapping.rb', line 91 def jpa_addPersistenceUnidirManyToOne!(ah) ah.java_annotation_add("@ManyToOne(#{jpa_addFetchType(ah)} #{jpa_addRelationCascadeType(true)}) ") ah.umlx_owner_one.java_import_add('javax.persistence.ManyToOne') jpa_addJoinColumn!(ah) end |
#jpa_addPersistenceUnidirOneToMany!(ah) ⇒ Object
84 85 86 87 88 |
# File 'lib/ontomde-java/jpa/mapping.rb', line 84 def jpa_addPersistenceUnidirOneToMany!(ah) ah.java_annotation_add(%{@OneToMany(#{jpa_addFetchType(ah)} #{jpa_addRelationCascadeType(true)})}) ah.umlx_owner_one.java_import_add('javax.persistence.OneToMany') jpa_addJoinTable(ah) end |
#jpa_addPersistenceUnidirOneToOne!(ah) ⇒ Object
76 77 78 79 80 81 82 |
# File 'lib/ontomde-java/jpa/mapping.rb', line 76 def jpa_addPersistenceUnidirOneToOne!(ah) #TODO: unicity constraint ah.java_annotation_add("@OneToOne(#{jpa_addFetchType(ah)}, cascade=CascadeType.ALL)") ah.umlx_owner_one.java_import_add('javax.persistence.OneToOne') ah.umlx_owner_one.java_import_add('javax.persistence.CascadeType') #TODO: affiner cascadeType pour les delete end |
#jpa_addRelationCascadeType(isIncludeType = true) ⇒ Object
68 69 70 71 72 73 74 75 |
# File 'lib/ontomde-java/jpa/mapping.rb', line 68 def jpa_addRelationCascadeType(isIncludeType=true) umlx_owner_one.java_import_add('javax.persistence.CascadeType') if (isIncludeType) return DEFAULT_CASCADE_I else return DEFAULT_CASCADE end end |
#jpa_isPersistent? ⇒ Boolean
520 521 522 523 |
# File 'lib/ontomde-java/jpa/jpa.rb', line 520 def jpa_isPersistent? return false if uml_isDerived? return true end |
#nil_lvb(obj) ⇒ Object
302 303 304 |
# File 'lib/ontomde-java/struts/form.rb', line 302 def nil_lvb(obj) return %{new #{STRUTS_LVB}("#{obj.java_qualifiedName}.#{NIL_LVB_RES_KEY}", "#{NIL_LVB_KEY}")} end |
#struts_addActionFormAttribute!(form) ⇒ Object
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
# File 'lib/ontomde-java/struts/form.rb', line 277 def struts_addActionFormAttribute!(form) return if db_isTransient? return if uml_isStatic? if uml_type_one.kind_of?(Muml_Enumeration) struts_addActionFormAttributeEnumeration!(form) elsif uml_type_one.kind_of?(Muml_DataType) a2=struts_copyAsFormField!(form) #Force cardinality to one (array of primitive is handeld has multi-line text) a2.uml_upperValue=form.umlx_literal(1) tpl=DatatypeMapping.instance.getMapping(uml_type_one) a2.uml_type=tpl.getFormType(form) else struts_addActionFormAttributeReference!(form) end #TODO: ajouter autres proprietes end |
#struts_addActionFormAttributeEnumeration!(form) ⇒ Object
Adds to the form class, a suggester operation corresponding to this attribute.
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 |
# File 'lib/ontomde-java/struts/form.rb', line 309 def struts_addActionFormAttributeEnumeration!(form) return if uml_isReadOnly? a2=struts_copyAsFormField!(form) #a2.uml_type=form.umlx_dataType_integer a2.uml_type=form.umlx_dataType_string #a2.uml_type=form.umlx_getOrCreateClass("java.lang.Integer") sug=form.umlx_createAndAddOperation(form.rdf_uri+"_sug_"+self.rdf_uri,"get#{self.java_NameBean}Sug") ret=sug.umlx_createAndAddReturnParameter(sug.rdf_uri+"_return") ret.uml_type=form.umlx_getOrCreateClass("#{STRUTS_LVB}") ret.uml_upperValue=form.umlx_literal(-1) ret.uml_isOrdered=RDF_TRUE sug.java_code=%{ return #{form.struts_getFormHelper.java_qualifiedName}.#{STRUTS_FORM_HELPER_ENUMTOLVB}(#{self.uml_type_one.java_qualifiedName}.class,(#{self.uml_type_one.java_qualifiedName})null,getReference().get#{self.java_NameBean}Sug()); } end |
#struts_addActionFormAttributeReference!(form) ⇒ Object
suggester for a list of objects
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 |
# File 'lib/ontomde-java/struts/form.rb', line 328 def struts_addActionFormAttributeReference!(form) a2=struts_copyAsFormField!(form) a2.uml_type=form.umlx_dataType_string if ! uml_isReadOnly? sug=form.umlx_createAndAddOperation(form.rdf_uri+"_sug_"+self.rdf_uri,"get#{self.java_NameBean}Sug") ret=sug.umlx_createAndAddReturnParameter(sug.rdf_uri+"_return") ret.uml_type=form.umlx_getOrCreateClass("#{STRUTS_LVB}") ret.uml_upperValue=form.umlx_literal(-1) ret.uml_isOrdered=RDF_TRUE sug.java_code= <<ENDJAVA java.util.List<#{STRUTS_LVB}> ret=new java.util.ArrayList<#{STRUTS_LVB}>(); #{STRUTS_LVB} lvb=null; // // //#{self.umlx_manySide? ? "" : %{lvb=new #{STRUTS_LVB}("--","empty"); // //ret.add(lvb);} } // return #{form.struts_getFormHelper.java_qualifiedName}.#{STRUTS_FORM_HELPER_ENUMTOLVB}(#{self.uml_type_one.java_qualifiedName}.class,(#{self.uml_type_one.java_qualifiedName})null,getReference().get#{self.java_NameBean}Sug()); for (#{self.uml_type_one.java_qualifiedName} item : getReference().get#{self.java_NameBean}Sug()) { if(item!=null) { lvb=new #{STRUTS_LVB}("obj:"+item.getId(), Long.toString(item.getId())); } else { lvb=#{nil_lvb(self.uml_type_one)}; } ret.add(lvb); } return ret; ENDJAVA end if(umlx_isComposite?) m=java_createAndAddSuggester_one r=nil (m.uml_returnResult+m.uml_ownedParameter).each {|p| next unless p.uml_direction_one.isReturn? ; r=p.uml_type_one } sugC=form.umlx_createAndAddOperation(form.rdf_uri+"_sugC","#{m.java_Name}") ret=sugC.umlx_createAndAddReturnParameter("#{sugC.rdf_uri}_ret") ret.uml_type=form.umlx_getOrCreateClass("#{STRUTS_LVB}") ret.uml_upperValue=form.umlx_literal(-1) ret.uml_isOrdered=RDF_TRUE sugC.java_code=%{ return #{form.struts_getFormHelper.java_qualifiedName}.#{STRUTS_FORM_HELPER_ENUMTOLVB}(#{r.java_qualifiedName}.class,(#{r.java_qualifiedName})null,getReference().#{m.java_Name}(),true); } end end |
#struts_copyAsFormField!(form) ⇒ Object
adds a paginator field when cardinality >1
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/ontomde-java/struts/form.rb', line 259 def struts_copyAsFormField!(form) #log.debug { %{add form field #{self} to #{form}} } a2=form.umlx_createAndAddProperty(rdf_uri+"_ActionFormField") a2.uml_name=uml_name a2.uml_upperValue=uml_upperValue a2.uml_lowerValue=uml_lowerValue a2.java_use_Arrays=RDF_TRUE a2.struts_sourceProperty=self if ! umlx_upperValueIsOne? paginator=form.umlx_createAndAddProperty(rdf_uri+"_ActionFormField_page") paginator.uml_name=uml_name.to_s+"_strutsPage" paginator.uml_type=form.umlx_owner_one.umlx_dataType_integer a2.struts_paginatorProperty=paginator end return a2 end |
#struts_edit_writeFieldProp(owner) ⇒ Object
writes java code for a property
-
labels
-
editing zones
-
security management
-
help zone
791 792 793 794 795 |
# File 'lib/ontomde-java/struts/jsp_edit.rb', line 791 def struts_edit_writeFieldProp(owner) write(%{<xmdas:SecureZoneTag name="#{owner.java_qualifiedName}.#{java_Name}">\n}) if context[:security] struts_edit_writeFieldPropCode(owner) write(%{</xmdas:SecureZoneTag>\n}) if context[:security] end |
#struts_edit_writeFieldPropCode(owner) ⇒ Object
writes java code for a property
-
labels
-
editing zones
-
help zone
801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 |
# File 'lib/ontomde-java/struts/jsp_edit.rb', line 801 def struts_edit_writeFieldPropCode(owner) write <<END <div class="row"> <span class="label"> #{struts_writeMsg("#{owner.java_qualifiedName}.#{java_Name}")} </span> END write %{<span class="formw"><table><tr><td>\n\n} struts_edit_writeHelpToggle write %{</td><td>\n\n} #Protected zone for edit area mtk_protected(Mrdf_Resource::NOREVERSE,"edit") { uml_type_one.struts_edit_writeField(self,owner) } write %{</td><td>\n\n} struts_edit_writeValidateErrorMessage write %{</td></tr></table>\n\n} write("</span>\n</div>") struts_edit_writeHelpMessage(owner) #write("</div>") end |
#struts_edit_writeHelpMessage(owner) ⇒ Object
840 841 842 843 844 845 846 847 848 849 850 851 852 |
# File 'lib/ontomde-java/struts/jsp_edit.rb', line 840 def struts_edit_writeHelpMessage(owner) write %{ <div class="aidelongue" id='aide_#{java_Name}'> <span class="labelHelp"> <bean:message key="help.label"/> </span> <span class="contentHelp"> #{struts_writeMsg("#{owner.java_qualifiedName}.#{java_Name}.help")} </span> </div> } end |
#struts_edit_writeHelpToggle ⇒ Object
831 832 833 834 835 836 837 838 |
# File 'lib/ontomde-java/struts/jsp_edit.rb', line 831 def struts_edit_writeHelpToggle if uml_ownedComment.empty? write %{<img src="#{css_path_model}/#{css_color_class}/image/vide.gif" width="25" height="25" border="0" alt="" />\n} else write %{<img src="#{css_path_model}/#{css_color_class}/image/btnHelp.gif" width="25" height="25" border="0" alt="help" onclick='togglehelp("#{java_Name}")' />\n} end end |
#struts_edit_writeValidateErrorMessage ⇒ Object
827 828 829 |
# File 'lib/ontomde-java/struts/jsp_edit.rb', line 827 def struts_edit_writeValidateErrorMessage write %{<html:messages property="#{java_Name}" id="error"><bean:write name="error" /></html:messages>\n} end |
#struts_ignoreInForm?(ignoreDbId = true) ⇒ Boolean
240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/ontomde-java/struts/form.rb', line 240 def struts_ignoreInForm?(ignoreDbId=true) return true if uml_type_one.db_isTransient? && !uml_type_one.kind_of?(Muml_Enumeration) && !uml_type_one.kind_of?(Muml_DataType) return true if db_isTransient? return true if uml_isStatic? return true if java_ignoreMe? return true if ignoreDbId && uml_name_one=="id" return true if uml_name_one==Muml_Classifier::DB_OBJECT_VERSION_FIELD #return true if java_getter_property_inv.empty? #return true if java_setter_property_inv.empty? # a is a property added for compatibility return true unless umlx_stringMappingForEnum.empty? return false end |
#struts_validation_writeField ⇒ Object
59 60 61 |
# File 'lib/ontomde-java/struts/validation.rb', line 59 def struts_validation_writeField self.uml_type_one.struts_validation_writeField(self) end |
#super_jpa_addPersistenceToAssociation! ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/ontomde-java/crank/crankJpa.rb', line 32 def jpa_addPersistenceToAssociation!(ah) oe=umlx_otherEnd binav=(!oe.nil?) && oe.umlx_isNavigable? if binav jpa_addPersistenceToAssociationBidir!(ah) else jpa_addPersistenceToAssociationUnidir!(ah) end end |
#umlx_isSecured? ⇒ Boolean
returns true if element is marked as secured.
7 8 9 |
# File 'lib/ontomde-java/java/security.rb', line 7 def umlx_isSecured? return umlx_hasStereotype?("Secured") end |
#writeEnclose(before, after) ⇒ Object
780 781 782 783 784 |
# File 'lib/ontomde-java/struts/jsp_edit.rb', line 780 def writeEnclose(before,after) write before yield write after end |
#xsd_ignoreMe? ⇒ Boolean
1246 1247 1248 1249 1250 |
# File 'lib/ontomde-java/java/xsd.rb', line 1246 def xsd_ignoreMe? return true if java_ignoreMe? n=java_Name.to_s return true if (n=="isLogicallyDeleted") || (n=="objectVersion") end |
#xsd_writeFinalModifier ⇒ Object
1235 1236 1237 1238 |
# File 'lib/ontomde-java/java/xsd.rb', line 1235 def xsd_writeFinalModifier return unless xsd_isFinal? write "final " end |
#xsd_writeGetterComment ⇒ Object
Methode vide
1146 1147 |
# File 'lib/ontomde-java/java/xsd.rb', line 1146 def xsd_writeGetterComment end |
#xsd_writeMaxOccurs ⇒ Object
1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 |
# File 'lib/ontomde-java/java/xsd.rb', line 1152 def xsd_writeMaxOccurs return if umlx_upperValueIsOne? write(%{ maxOccurs="}) u=uml_upperValue.to_s if(u=="-1") write("unbounded") else write(u) end write(%{"}) end |
#xsd_writeMinOccurs ⇒ Object
1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 |
# File 'lib/ontomde-java/java/xsd.rb', line 1163 def xsd_writeMinOccurs return if umlx_lowerValueIsOne? write(%{ minOccurs="}) u=uml_lowerValue.to_s if(u=="-1") write("unbounded") else write(u) end write(%{"}) end |
#xsd_writeProperty ⇒ Object
write java attribute variable (Uses xsd_writePropertyComment, xsd_writePropertyModifiers ,xsd_propertyRoleType,xsd_NameProperty)
NOTE:
-
getter/setter/… methods are handled by model transformation
1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 |
# File 'lib/ontomde-java/java/xsd.rb', line 1180 def xsd_writeProperty return if xsd_ignoreMe? write(%{ <xsd:element name="#{xsd_Name}" type="#{uml_type_one.xsd_qualifiedName}"}) xsd_writeMinOccurs xsd_writeMaxOccurs write(%{/>\n}) # return # if !uml_isDerived? # xsd_writePropertyComment # xsd_writeAnnotation # write(" "); # xsd_writePropertyModifiers # write("#{xsd_propertyAssociationType}") # write(" #{xsd_NameProperty}") # # if !xsd_code.empty? # write"= #{xsd_code}" # elsif(context[:xsd_generateSetAttributeInitializer]) # if (!umlx_upperValueIsOne?) && uml_qualifier.empty? && xsd_use_Arrays? # write("= new "); # write(uml_type_one.xsd_qualifiedName) # write("[1]") # elsif (!umlx_upperValueIsOne?) && uml_qualifier.empty? # write("= new "); # write(xsd_propertyAssociationConcreteType) # write("()") # elsif umlx_upperValueIsOne? && !uml_qualifier.empty? # write("= new "); # write(xsd_propertyAssociationConcreteType) # write("()") # elsif !umlx_upperValueIsOne? && !uml_qualifier.empty? # #write("= new "); # #write(xsd_propertyAssociationConcreteType) # #write("()") # end # end # write(";\n") # end end |
#xsd_writePropertyComment ⇒ Object
Methode vide
1143 1144 |
# File 'lib/ontomde-java/java/xsd.rb', line 1143 def xsd_writePropertyComment end |
#xsd_writePropertyModifiers ⇒ Object
write java modifiers if needed (public, static, …) (Uses xsd_visibilityModifiers, xsd_writeStaticModifier) example: private static final transient long
1225 1226 1227 1228 1229 1230 1231 1232 1233 |
# File 'lib/ontomde-java/java/xsd.rb', line 1225 def xsd_writePropertyModifiers uml_visibility.each { |v| write(v.xsd_visibilityModifiers) } xsd_writeStaticModifier xsd_writeFinalModifier xsd_writeTransient end |
#xsd_writeSetterComment ⇒ Object
Methode vide
1149 1150 |
# File 'lib/ontomde-java/java/xsd.rb', line 1149 def xsd_writeSetterComment end |
#xsd_writeTransient ⇒ Object
write java transient modifier if needed.
1241 1242 1243 1244 |
# File 'lib/ontomde-java/java/xsd.rb', line 1241 def xsd_writeTransient return unless xsd_isTransient? write("transient ") end |