ontomde-uml2-java 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,217 @@
1
+
2
+
3
+ class String
4
+ JAVA_ESCAPEJAVADOC_RE=/\*\\/
5
+ #write string as javadoc
6
+ #NOTE: source strings should not include javadoc comments open/close
7
+ # (javadoc comments open/closed are removed)
8
+ def java_writeJavadoc(res)
9
+ # replace escaped carriage return by true carriage return
10
+ # remove java comments (we are already inside a javadoc)
11
+ self.gsub(/\\r\\n/,"\n").gsub(/\*\//,'--').gsub(/\/\*/,'--').each { |line|
12
+ res.write(" * #{line}".tr("\n"," ").rstrip)
13
+ res.write("\n")
14
+ }
15
+ end
16
+ end
17
+
18
+ module Muml_Classifier
19
+ #write classifier javadoc comment.
20
+ def java_writeJavadoc
21
+ return unless context[:javadoc]
22
+ c=""
23
+ sep=""
24
+ uml_ownedComment.each { |comment|
25
+ c="#{c}#{sep}#{comment.uml_body_one}"
26
+ sep="\n"
27
+ }
28
+ write(" /**\n");
29
+ c.java_writeJavadoc(self)
30
+ #Note: RSM exports adds an extraneous http://
31
+ #Note: TODO: This code is RSM 6 specific
32
+ %{@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?
33
+
34
+ write(" */\n")
35
+ end
36
+ end
37
+
38
+ module Muml_Property
39
+ #returns a javadoc link suitable for @see and @link.
40
+ def java_javadocLink(location=nil)
41
+ o=umlx_owner_one
42
+ if location==o
43
+ #same class
44
+ return "##{java_Name}"
45
+ else
46
+ #different class
47
+ return "#{o.java_qualifiedName}##{java_Name}"
48
+ end
49
+
50
+ end
51
+ end
52
+
53
+
54
+ module Muml_Operation
55
+ #returns a javadoc link suitable for @see and @link.
56
+ def java_javadocLink(location=nil)
57
+ o=umlx_owner_one
58
+ if location==o
59
+ #same class
60
+ return "##{java_Name}"
61
+ else
62
+ #different class
63
+ return "#{o.java_qualifiedName}##{java_Name}"
64
+ end
65
+ end
66
+
67
+
68
+ #write operation javadoc comment.
69
+ def java_writeJavadoc
70
+ return unless context[:javadoc]
71
+ write(" /**\n");
72
+ hasDoc=false
73
+
74
+ # if !java_getter_property.empty? && !java_getter_property_one.uml_isDerived?
75
+ # "getter for property {@link #{java_getter_property_one.java_javadocLink}}".java_writeJavadoc(self)
76
+ # end
77
+ # if !java_setter_property.empty? && !java_setter_property_one.uml_isDerived?
78
+ # "setter for property {@link #{java_setter_property_one.java_javadocLink}}".java_writeJavadoc(self)
79
+ # end
80
+
81
+ p=java_getter_property_one0
82
+ if !p.nil?
83
+ oe=p.umlx_otherEnd
84
+ if !oe.nil? && oe.umlx_isNavigable?
85
+ g=oe.java_AttributeGlobalGetter_one0
86
+ if !g.nil?
87
+ "This property is part of a bi-navigable association {@link #{g.java_javadocLink(self)}}<br/>".java_writeJavadoc(self)
88
+ end
89
+ end
90
+ end
91
+
92
+
93
+ if !uml_ownedComment.empty?
94
+ #write("* @return the \n");
95
+ uml_ownedComment.each { |comment|
96
+ hasDoc=true
97
+ comment.uml_body_one.java_writeJavadoc(self)
98
+ }
99
+
100
+ elsif !java_getter_property.empty?
101
+ java_getter_property_one.uml_ownedComment.each { |comment|
102
+ hasDoc=true
103
+ comment.uml_body_one.java_writeJavadoc(self)
104
+ }
105
+ else
106
+ #nop
107
+ end
108
+ #if(!hasDoc)
109
+ # "TODO: document this element in source UML model".java_writeJavadoc(self)
110
+ #end
111
+
112
+ uml_ownedParameter.each { |p|
113
+ c=""
114
+ p.uml_ownedComment.each { |comment|
115
+ c="#{c} #{comment.uml_body_one}"
116
+ }
117
+ next if c.empty? && p.uml_direction_one.isReturn?
118
+ "#{p.uml_direction_one.isReturn? ? %{@return} : %{@param}} #{p.java_Name unless p.uml_direction_one.isReturn?}#{c}".java_writeJavadoc(self)
119
+ }
120
+
121
+ if !java_setter_property.empty?
122
+ hasDoc=true
123
+ p=java_setter_property_one
124
+ if !p.java_AttributeGlobalGetter.empty?
125
+ "@see #{p.java_AttributeGlobalGetter_one.java_javadocLink}".java_writeJavadoc(self)
126
+ end
127
+ end
128
+
129
+ write(" */\n")
130
+ end
131
+ end
132
+
133
+ module Muml_EnumerationLiteral
134
+ def java_writeJavadoc
135
+ return unless context[:javadoc]
136
+ c=""
137
+ uml_ownedComment.each { |comment|
138
+ c="#{c} #{comment.uml_body_one}"
139
+ }
140
+ return if c.empty?
141
+ write(" /**\n");
142
+ c.java_writeJavadoc(self)
143
+ write(" */\n")
144
+ end
145
+ end
146
+
147
+
148
+ module Mrdf_Model
149
+
150
+ #returns a hash of package sets for which a javadoc should be generated.
151
+ #hash key is the qualifiedName of the packages
152
+ #(several uml packages may have the same name in different UML models)
153
+ #
154
+ #A package is included if :
155
+ #* it contains a generated class/interface/enum
156
+ #* it contains a uml comment
157
+ def java_getUsedPackages
158
+
159
+ ps=Hash.new
160
+ uml_Class_all.each { |e|
161
+ p=e.umlx_owner_one
162
+ next unless p.kind_of?(Muml_Package)
163
+ next if p.kind_of?(Muml_Model)
164
+ next if e.umlx_external?
165
+ pn=p.java_qualifiedName.to_s
166
+ s=ps[pn]
167
+ if s.nil?
168
+ s=Set.new
169
+ ps[pn]=s
170
+ end
171
+ s.add(p)
172
+ }
173
+
174
+ each { |k,p|
175
+ next unless p.kind_of?(Muml_Package)
176
+ next if p.kind_of?(Muml_Model)
177
+ next if p.uml_ownedComment.empty?
178
+ pn=p.java_qualifiedName.to_s
179
+ s=ps[pn]
180
+ if s.nil?
181
+ s=Set.new
182
+ ps[pn]=s
183
+ end
184
+ s.add(p)
185
+ }
186
+ return ps
187
+ end
188
+
189
+ #generates java documentation files (package-info.java) for
190
+ #packages directly containing elements (class, enum, interface)
191
+ #cf: http://java.sun.com/docs/books/jls/third_edition/html/packages.html
192
+ def java_generatePackageDoc
193
+ return unless context[:javadoc]
194
+ java_getUsedPackages.each { |packageName,packageSet|
195
+ fn=nil
196
+ packageSet.each { |package|
197
+ fn="#{package.java_FilePath}/#{package.java_Name}/package-info.java"
198
+ break
199
+ }
200
+ mtk_writeSession(fn) {
201
+ write("/**\n")
202
+ packageSet.each { |package|
203
+ package.uml_ownedComment.each { |comment|
204
+ comment.uml_body_one.java_writeJavadoc(self)
205
+ }
206
+ }
207
+ write("**/\n\n")
208
+ write("package #{packageName};\n")
209
+ }
210
+ }
211
+ end
212
+ end
213
+
214
+
215
+
216
+
217
+
@@ -0,0 +1,26 @@
1
+
2
+ class Crdfs_Class
3
+
4
+ #UML metaclass to java class mapping.
5
+ #Example:
6
+ #An UML metaclass class maps to a java.lang.Class java class.
7
+ #Note:
8
+ # feature introduced for opencrx.
9
+ JAVA_METACLASS_MAPPING={
10
+ "uml_Class" => "java.lang.Class"
11
+ }
12
+
13
+ # returns the java class name for this meta-class.
14
+ # Example:
15
+ #
16
+ # Note:
17
+ # added for openmdx which uses attributes of type "metaclass-class".
18
+ def java_qualifiedName
19
+ qn=JAVA_METACLASS_MAPPING[rdf_uri]
20
+ return qn unless qn.nil?
21
+ msg="unknown java_qualifiedName for meta-class #{rdf_uri}"
22
+ return "int /*TODO: #{msg} */"
23
+ end
24
+
25
+ end
26
+
@@ -0,0 +1,130 @@
1
+ module Muml_Classifier
2
+ STRUTS_APPLY_TO_PARAM="applyTo"
3
+ STRUTS_APPLY_TO_PROP="ApplyTo"
4
+ end
5
+
6
+ module Muml_Operation
7
+ rdf_safe_attr_reader_many :struts_bizOperationReverse
8
+ end
9
+
10
+ module Muml_Parameter
11
+ #the method parameter
12
+ rdf_safe_attr_reader_many :struts_sourceParameter
13
+ end
14
+
15
+
16
+ module Mrdf_Model
17
+ def struts_addAllOperationAggregateParameterClass!
18
+ return unless context[:withGenerateMethodForm]
19
+
20
+ uml_Class_all.each {|c|
21
+ #exclude classes explicitely set to false
22
+ next if (!c.umlx_businessMethod.empty?) && (!c.umlx_businessMethod?)
23
+ c.uml_ownedOperation.each {|biz|
24
+ #next if c.java_isATestFile?
25
+ next unless biz.kind_of?(Muml_Operation)
26
+ next unless biz.umlx_businessMethod?
27
+ next if biz.umlx_isConstructor?
28
+ next if biz.uml_visibility_one.isPrivate?
29
+ next if biz.uml_visibility_one.isProtected?
30
+ next if biz.uml_isStatic?
31
+ #c=biz.umlx_owner_one
32
+
33
+ p=c.umlx_package
34
+ if p.nil?
35
+ log.error{"Model modification required !!! class #{c} is in root model element. Classes should be in a package."}
36
+ next
37
+ end
38
+ next unless c.kind_of?(Muml_Class)
39
+
40
+ p=p.umlx_getOrCreatePackage(context[:classMethodSubDir,"methods"],p)
41
+ #BUG:biz_uri ne suffisait pas car si 2 classes immplémnetaient 2 fois une méthode d'une classe abstraite
42
+ #la classe crée avait les 2 mêmes uri et donc était zappé par la suite(notamment le java_transform
43
+ mpc=p.umlx_createAndAddClass(c.rdf_uri+biz.rdf_uri+"_mpc2");
44
+ mpc.umlx_businessMethod=RDF_TRUE
45
+ mpc.struts_addAllOperationAggregateParameterClass!(biz)
46
+ mpc.db_isTransient=RDF_TRUE
47
+
48
+ m=mpc.umlx_createAndAddOperation(mpc.rdf_uri+"merge","merge");
49
+ #TODO merge referenced items
50
+ m.java_code="return this; "
51
+ p=m.umlx_createAndAddReturnParameter(m.rdf_uri+'_ret',"return")
52
+ p.uml_type=mpc
53
+
54
+ }}
55
+ end
56
+ end
57
+ module Muml_Classifier
58
+
59
+ rdf_safe_attr_reader_many :struts_bizOperation
60
+ #
61
+ #Creates a class for every business method holding every parameters
62
+ #and
63
+ #
64
+ #
65
+
66
+ STRUTS_RESULT_PARAM_NAME="_result"
67
+
68
+ def struts_addAllOperationAggregateParameterClass!(biz)
69
+ mpc=self
70
+ mpc.struts_bizOperation=biz
71
+ biz.struts_bizOperationReverse_add(mpc)
72
+ #biz.struts_bizForm=mpc
73
+ mpc.uml_name="#{biz.umlx_owner_one.java_Name}#{biz.java_Name}MPC"
74
+ (biz.uml_ownedParameter+biz.uml_returnResult).each { |param|
75
+ #next if param.uml_direction_one.isReturn?
76
+ mpcp=mpc.umlx_createAndAddProperty(mpc.rdf_uri+"_mpc3")
77
+ param.umlx_copyToAttributeProperty(mpcp)
78
+ mpcp.uml_name= param.uml_direction_one.isReturn? ? STRUTS_RESULT_PARAM_NAME : param.uml_name
79
+ }
80
+ mpc.struts_addApplyToParameter!(biz)
81
+ mpc.struts_addProceed!(biz)
82
+ #mpc.apaCom_addLogger!
83
+ end
84
+
85
+ def struts_addApplyToParameter!(biz)
86
+ mpc=self
87
+ m,m1,m2=mpc.umlx_createAndAddAssociation(mpc.rdf_uri+"_apply",biz.umlx_owner_one)
88
+ m1.uml_name=STRUTS_APPLY_TO_PARAM
89
+ m2.uml_name="#{STRUTS_APPLY_TO_PARAM}_inv"
90
+ end
91
+
92
+ def struts_addProceed!(biz)
93
+ mpc=self
94
+ cpt=mpc.umlx_createAndAddOperation(mpc.rdf_uri+"_proceed","proceed")
95
+ params=""; sep=""
96
+ hasRP=false
97
+ (biz.uml_ownedParameter+biz.uml_returnResult).each { |param|
98
+ if param.uml_direction_one.isReturn?
99
+ hasRP=true
100
+ next
101
+ end
102
+ params="#{params}#{sep}#{param.java_Name}"
103
+ sep=","
104
+ }
105
+ if(biz.uml_raisedException.empty?)
106
+ cpt.java_code=%{
107
+ #{hasRP ? "#{STRUTS_RESULT_PARAM_NAME}=" : ""} #{STRUTS_APPLY_TO_PARAM}.#{biz.java_Name}(#{params});
108
+ }
109
+ else
110
+ cpt.java_code=%{
111
+ try {
112
+ //log.error("before biz method");
113
+ //log.error("applyTo="+#{STRUTS_APPLY_TO_PARAM});
114
+ #{hasRP ? "#{STRUTS_RESULT_PARAM_NAME}=" : ""} #{STRUTS_APPLY_TO_PARAM}.#{biz.java_Name}(#{params});
115
+ //log.error("after biz method");
116
+ //log.error("result="+#{hasRP ? STRUTS_RESULT_PARAM_NAME : %{"-none-"}});
117
+ } catch(Exception e) {
118
+ //TODO: implement proper exception handling
119
+ throw new java.lang.RuntimeException(e);
120
+ }
121
+ }
122
+ end
123
+
124
+ end
125
+ end
126
+
127
+
128
+
129
+
130
+
@@ -0,0 +1,232 @@
1
+ # Authentification and security model enhancements.
2
+ #
3
+
4
+ module Muml_Property
5
+ #return true if element is marked as secured.
6
+ def umlx_isSecured?
7
+ return umlx_hasStereotype?("Secured")
8
+ end
9
+ end
10
+ module Muml_Operation
11
+ #return true if element is marked as secured.
12
+ def umlx_isSecured?
13
+ return umlx_hasStereotype?("Secured")
14
+ end
15
+ end
16
+
17
+ module Mrdf_Model
18
+
19
+ #Retrieve an enumeration that will contain a list of secured methods
20
+ def umlx_getSecuredMethodEnumeration
21
+ return umlx_reserved_model.umlx_getOrCreateEnumeration("xmda.security.SecuredMethodInventory",Muml_Classifier::UMLX_SEARCH_EVERY_MODEL)
22
+ end
23
+
24
+ def umlx_populateSecuredMethodEnumeration
25
+ umlx_generateStaticSecurityRoleEnum
26
+ e=umlx_getSecuredMethodEnumeration
27
+
28
+ #populate inventory
29
+ uml_Class_all.each {|c|
30
+ next unless c.umlx_businessMethod?
31
+ next if c.kind_of?(Muml_Interface)
32
+ cn="#{c.java_qualifiedName}.class"
33
+ c.uml_ownedOperation.each {|op|
34
+ next unless op.umlx_businessMethod?
35
+ #operation was generated from an interface
36
+ next if (!op.umlx_redefinesMethod.empty?) && (!op.umlx_redefinesMethod_one.umlx_owner_one.kind_of?(Muml_Interface))
37
+ lit=e.umlx_createAndAddLiteral("#{op.umlx_owner_one.java_qualifiedName}_#{op.java_Name}")
38
+ lit.java_initParameterValue_add(cn)
39
+ lit.java_initParameterValue_add(%{"#{op.java_Name}"})
40
+ }
41
+ }
42
+
43
+ cc=umlx_reserved_model.umlx_getOrCreateClass("java.lang.Classxx")
44
+ cc.uml_name="Class<?>"
45
+ cc.java_isGeneric=RDF_TRUE
46
+
47
+ str=e.umlx_owner_one.umlx_dataType_string
48
+ # add constructor
49
+ c=e.umlx_createAndAddOperation("#{c}.constructor","constructor")
50
+ c.uml_appliedStereotype_add(e.umlx_getOrCreateStereotype("Create"))
51
+ c.uml_visibility=::Cuml_VisibilityKind::Private
52
+ p1=c.umlx_createAndAddParameter("#{c.uri}_p1","_ownerClass")
53
+ p1.uml_type=cc
54
+ p2=c.umlx_createAndAddParameter("#{c.uri}_p2","_operationName")
55
+ p2.uml_type=str
56
+ c.java_code="ownerClass=_ownerClass;\noperationName=_operationName;"
57
+
58
+ #add attributes
59
+ a1=e.umlx_createAndAddProperty("#{e}_a1","ownerClass")
60
+ a1.uml_type=cc
61
+ a2=e.umlx_createAndAddProperty("#{e}_a2","operationName")
62
+ a2.uml_type=str
63
+
64
+ #add finder
65
+ f=e.umlx_createAndAddOperation("#{e.uri}_find","find")
66
+ f.uml_isStatic=RDF_TRUE
67
+ a1=f.umlx_createAndAddParameter("#{e}_a1","ownerClass")
68
+ a1.uml_type=cc
69
+ a2=f.umlx_createAndAddParameter("#{e}_a2","operationName")
70
+ a2.uml_type=str
71
+ a3=f.umlx_createAndAddReturnParameter("#{e}_ret","enum")
72
+ a3.uml_type=e
73
+ f.java_code=<<END
74
+ //TODO !!!!!!!!!!!
75
+ return null ; //#{e.java_Name}
76
+ END
77
+
78
+ end
79
+
80
+ #model may contain several enumeration of roles stereotypes staticSecurityRole
81
+ #For implementation use, an enumeration containing every roles is generated.
82
+ #Role container name could be appended to role name but it is not because it
83
+ #would make code refactoring more complex.
84
+ #As a consequence, role name should be unique application wide.
85
+ def umlx_generateStaticSecurityRoleEnum
86
+ e=umlx_reserved_model.umlx_getOrCreateEnumeration("xmda.security.StaticSecurityRole",Muml_Classifier::UMLX_SEARCH_EVERY_MODEL)
87
+ self.each_value { |v|
88
+ next unless v.kind_of?(Muml_Enumeration)
89
+ next unless v.umlx_hasStereotype?("staticSecurityRole")
90
+ v.uml_ownedLiteral.each {|c|
91
+ #role name should be unique
92
+ e.umlx_createAndAddLiteral(c.to_s)
93
+ }
94
+ }
95
+ end
96
+
97
+ #Retrieve an enumeration that will contain a list of secured property
98
+ def umlx_getSecuredPropertyEnumeration
99
+ return umlx_reserved_model.umlx_getOrCreateEnumeration("xmda.security.SecuredPropertyInventory",Muml_Classifier::UMLX_SEARCH_EVERY_MODEL)
100
+ end
101
+
102
+ def umlx_populateSecuredPropertyEnumeration
103
+ #umlx_generateStaticSecurityRoleEnum
104
+ e=umlx_getSecuredPropertyEnumeration
105
+
106
+ #populate inventory
107
+ uml_Class_all.each {|c|
108
+ next unless c.umlx_businessMethod?
109
+
110
+ #Hack: transient operation
111
+ #next if c.db_isTransient?
112
+
113
+
114
+ next if c.kind_of?(Muml_Interface)
115
+ cn="#{c.java_qualifiedName}.class"
116
+ c.uml_ownedAttribute.each {|op|
117
+ #next unless op.umlx_businessMethod?
118
+ #operation was generated from an interface
119
+ #next if (!op.umlx_redefinesProperty.empty?) && (!op.umlx_redefinesProperty_one.umlx_owner_one.kind_of?(Muml_Interface))
120
+ lit=e.umlx_createAndAddLiteral("#{op.umlx_owner_one.java_qualifiedName}_#{op.java_Name}")
121
+ lit.java_initParameterValue_add(cn)
122
+ lit.java_initParameterValue_add(%{"#{op.java_Name}"})
123
+ lit.java_initParameterValue_add(op.umlx_isSecured?)
124
+ }
125
+ }
126
+
127
+
128
+ #Classxx is on purpose
129
+ cc=umlx_reserved_model.umlx_getOrCreateClass("java.lang.Classxx")
130
+ cc.uml_name="Class<?>"
131
+ cc.java_isGeneric=RDF_TRUE
132
+
133
+ str=e.umlx_owner_one.umlx_dataType_string
134
+ bol=e.umlx_owner_one.umlx_dataType_boolean
135
+ # add constructor
136
+ c=e.umlx_createAndAddOperation("#{c}.constructor","constructor")
137
+ c.uml_appliedStereotype_add(e.umlx_getOrCreateStereotype("Create"))
138
+ c.uml_visibility=::Cuml_VisibilityKind::Private
139
+ p1=c.umlx_createAndAddParameter("#{c.uri}_p1","_ownerClass")
140
+ p1.uml_type=cc
141
+ p2=c.umlx_createAndAddParameter("#{c.uri}_p2","_propertyName")
142
+ p2.uml_type=str
143
+ p3=c.umlx_createAndAddParameter("#{c.uri}_p3","_isSecured")
144
+ p3.uml_type=bol
145
+ c.java_code="ownerClass=_ownerClass;\npropertyName=_propertyName;\nisSecured=_isSecured;"
146
+
147
+ #add attributes
148
+ a1=e.umlx_createAndAddProperty("#{e}_a1","ownerClass")
149
+ a1.uml_type=cc
150
+ a2=e.umlx_createAndAddProperty("#{e}_a2","propertyName")
151
+ a2.uml_type=str
152
+ a3=e.umlx_createAndAddProperty("#{e}_a2","isSecured")
153
+ a3.uml_type=bol
154
+
155
+
156
+ #add finder
157
+ f=e.umlx_createAndAddOperation("#{e.uri}_find","find")
158
+ f.uml_isStatic=RDF_TRUE
159
+ a1=f.umlx_createAndAddParameter("#{e}_a1","ownerClass")
160
+ a1.uml_type=cc
161
+ a2=f.umlx_createAndAddParameter("#{e}_a2","propertyName")
162
+ a2.uml_type=str
163
+ a3=f.umlx_createAndAddReturnParameter("#{e}_ret","enum")
164
+ a3.uml_type=e
165
+ f.java_code=<<END
166
+ //TODO !!!!!!!!!!!
167
+ return null ; //#{e.java_Name}
168
+ END
169
+
170
+ end
171
+
172
+ #Java annotation used to mark a Secured method or field.
173
+ JAVA_SECURE_ANNOTATION="@xmda.security.Secure"
174
+
175
+ # process element marked as secured
176
+ def umlx_processSecuredElements
177
+ e=umlx_reserved_model.umlx_getOrCreateInterface("org.acegisecurity.userdetails.UserDetails")
178
+
179
+ uml_Class_all.each {|c|
180
+ #sec=false
181
+ next if c.kind_of?(Muml_Interface) || c.kind_of?(Muml_Enumeration)
182
+ c.uml_ownedOperation.each {|o|
183
+ next unless o.umlx_isSecured?
184
+ o.java_annotation_add(JAVA_SECURE_ANNOTATION)
185
+ #sec=true
186
+ }
187
+ c.uml_ownedAttribute.each { |a|
188
+ next unless a.umlx_isSecured?
189
+ a.java_annotation_add(JAVA_SECURE_ANNOTATION)
190
+ #sec=true
191
+ }
192
+ c.umlx_addGetStaticRoleOperation! #if sec
193
+ }
194
+ end
195
+
196
+ end
197
+ module Muml_Class
198
+
199
+ # method comment that will be generated as javadoc
200
+ JAVA_GETSTATIC_ROLE_COMMENT=<<ENDHELP
201
+ This method returns a set of "static roles" that *may* *be* granted to the user based on database informations.
202
+
203
+ When a "security role" (defined at runtime) is bounded(linked) to a "static role" (defined at compile time),
204
+ users must
205
+ - be granted the security role
206
+ - and the bounded "static role" must be included in the set of role returned by this method.
207
+ ENDHELP
208
+
209
+ #method default implementation
210
+ JAVA_GETSTATIC_ROLE_CODE=<<ENDROLECODE
211
+ //return empty list (every static role are denied)
212
+ return new java.util.HashSet<xmda.security.StaticSecurityRole>();
213
+ ENDROLECODE
214
+
215
+ #public List<SecurityRole> getStaticRoles(org.acegi.security.UserDetails userName
216
+ def umlx_addGetStaticRoleOperation!
217
+ m=self.umlx_createAndAddOperation("#{rdf_uri}_getStaticRoles","getStaticRoles")
218
+
219
+ r=m.umlx_createAndAddReturnParameter("#{m.rdf_uri}_return")
220
+ r.uml_type=umlx_reserved_model.umlx_getOrCreateEnumeration("xmda.security.StaticSecurityRole",Muml_Classifier::UMLX_SEARCH_EVERY_MODEL)
221
+ r.uml_upperValue=umlx_literal(-1)
222
+ r.umlx_createAndAddComment("#{r.rdf_uri}_c1",JAVA_GETSTATIC_ROLE_COMMENT)
223
+
224
+ p=m.umlx_createAndAddParameter("#{m.rdf_uri}_p1","user")
225
+ p.uml_type=umlx_reserved_model.umlx_getOrCreateEnumeration("org.acegisecurity.userdetails.UserDetails",Muml_Classifier::UMLX_SEARCH_EVERY_MODEL)
226
+
227
+ m.java_code=JAVA_GETSTATIC_ROLE_CODE
228
+ end
229
+
230
+
231
+ end
232
+
@@ -0,0 +1,7 @@
1
+ module Ontomde
2
+ module Uml2
3
+ module Java
4
+ VERSION = '1.0.4'
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,37 @@
1
+ # This class is meant to be included in your project that require java code generation capability.
2
+ #
3
+ #EXAMPLE: The following code will generate all the java file corresponding to the UML elements stored in model.emx.nt
4
+ #
5
+ # require '#{h}'
6
+ # modelFile='model.emx.nt'
7
+ #
8
+ # model=Crdf_Model.new
9
+ # model.loadUml2
10
+ # model.loadModelFromFile(modelFile)
11
+ #
12
+ # model.mtk_context(:build=> build) {
13
+ # model.java_generate
14
+ # }
15
+ # puts "Your Java file have been generated"
16
+
17
+
18
+ require 'ontomde-uml2'
19
+
20
+ h="#{File.dirname(__FILE__)}/ontomde-uml2-java"
21
+ require "#{h}/version.rb"
22
+ require "#{h}/JavaMapping.rb"
23
+ require "#{h}/java.rb"
24
+ require "#{h}/javaHelper.rb"
25
+ require "#{h}/accessorCode.rb"
26
+ require "#{h}/accessorSignature.rb"
27
+ require "#{h}/meta.rb"
28
+ require "#{h}/enumCompatibilityLayer.rb"
29
+ require "#{h}/enumAssignable.rb"
30
+ require "#{h}/operationAsClass.rb"
31
+ require "#{h}/build.rb"
32
+ require "#{h}/collectionMapping.rb"
33
+ require "#{h}/javadoc.rb"
34
+ require "#{h}/security.rb"
35
+ require "#{h}/groovy.rb"
36
+
37
+
File without changes