ontomde-uml2 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,28 @@
1
+
2
+
3
+ module Mrdf_Model
4
+ def umlx_checkAbstractAndInheritance()
5
+ return unless context[:checkForAbstractAndInheritance,false]
6
+ msg=""
7
+ uml_Class_all.each { |c|
8
+ next if c.kind_of?(Muml_Enumeration)
9
+ next if c.kind_of?(Muml_Interface)
10
+ next if c.umlx_external?
11
+ next if c.uml_isAbstract?
12
+ next if c.uml_general_inv.empty?
13
+ msg=msg+"\n**** #{c.uml_name}"
14
+ }
15
+ return if msg.empty?
16
+ log.error { %{
17
+ ******************* INCORRECT MODEL *******************
18
+ This model contains incorrect constructions.
19
+
20
+ The following classe(s) has (have) been found guilty
21
+ of being *not* abstract and having inheriting classes.
22
+ Please, check your model and mark these classes abstract
23
+ #{msg}
24
+ ******************* INCORRECT MODEL *******************
25
+ }}
26
+ #exit(1)
27
+ end
28
+ end
@@ -0,0 +1,222 @@
1
+ # This file contains several helper to create new UML elements.
2
+
3
+
4
+
5
+ module Muml_Operation
6
+ def umlx_createAndAddParameter(new_uri,new_name=nil)
7
+ p=Cuml_Parameter.new(rdf_model,new_uri)
8
+ uml_ownedParameter_add(p)
9
+ p.uml_name=new_name unless new_name.nil?
10
+ p.uml_isUnique=RDF_TRUE
11
+ p.uml_isOrdered=RDF_FALSE
12
+ p.uml_direction=Cuml_ParameterDirectionKind::In
13
+ return p
14
+ end
15
+
16
+ #Create and add a return parameter.
17
+ #
18
+ def umlx_createAndAddReturnParameter(new_uri,new_name="return")
19
+ p=Cuml_Parameter.new(rdf_model,new_uri)
20
+ uml_ownedParameter_add(p)
21
+ p.uml_name=new_name
22
+ p.uml_isUnique=RDF_TRUE
23
+ p.uml_isOrdered=RDF_FALSE
24
+ p.uml_direction=Cuml_ParameterDirectionKind::Return
25
+ return p
26
+ end
27
+
28
+ end
29
+ module Muml_Interface
30
+ def umlx_createAndAddGeneralization(gen)
31
+ g=Cuml_Generalization.new(rdf_model,nil)
32
+ g.uml_general=gen
33
+ g.uml_specific=self
34
+ self.uml_generalization_add(g)
35
+ return g
36
+ end
37
+ end
38
+ module Muml_Class
39
+ #Creates and add a new UML Class.
40
+ #Return the newly created element.
41
+ #new_uri should be globaly unique.
42
+ def umlx_createAndAddClass(new_uri,new_name=nil)
43
+ c=Cuml_Class.new(rdf_model,new_uri)
44
+ #uml_ownedMember_add(c)
45
+ uml_nestedClassifier_add(c)
46
+ c.umlx_owner=self
47
+ c.uml_name=new_name unless new_name.nil?
48
+ c.uml_visibility=::Cuml_VisibilityKind::Public
49
+ #puts "création classe #{new_name} in #{self.java_qualifiedName}"
50
+ return c
51
+ end
52
+ def umlx_createAndAddGeneralization(gen)
53
+ g=Cuml_Generalization.new(rdf_model,nil)
54
+ g.uml_general=gen
55
+ g.uml_specific=self
56
+ self.uml_generalization_add(g)
57
+ return g
58
+ end
59
+
60
+ def umlx_createAndAddImplementation(gen)
61
+ g=Cuml_Implementation.new(rdf_model,nil)
62
+ g.uml_supplier=gen
63
+ g.uml_implementingClassifier=self
64
+ self.uml_implementation_add(g)
65
+ return g
66
+ end
67
+ end
68
+ module Muml_Enumeration
69
+ def umlx_createAndAddLiteral(lit)
70
+ lit=lit.to_s
71
+ o=Cuml_EnumerationLiteral.new(rdf_model,"#{rdf_uri}_#{lit}")
72
+ o.uml_name=lit
73
+ self.uml_ownedLiteral_add(o)
74
+ return o
75
+ end
76
+ def umlx_createAndAddImplementation(gen)
77
+ g=Cuml_Implementation.new(rdf_model,nil)
78
+ g.uml_supplier=gen
79
+ g.uml_implementingClassifier=self
80
+ self.uml_implementation_add(g)
81
+ return g
82
+ end
83
+ end
84
+ module Muml_Package
85
+ #Creates and add a new UML Enumeration.
86
+ #Return the newly created element.
87
+ #new_uri should be globaly unique.
88
+ def umlx_createAndAddEnumeration(new_uri,new_name=nil)
89
+ c=Cuml_Enumeration.new(rdf_model,new_uri)
90
+ uml_ownedMember_add(c)
91
+ c.umlx_owner=self
92
+ c.uml_name=new_name unless new_name.nil?
93
+ c.uml_visibility=::Cuml_VisibilityKind::Public
94
+ #puts "création classe #{new_name} in #{self.java_qualifiedName}"
95
+ return c
96
+ end
97
+ #Creates and add a new UML Interface.
98
+ #Return the newly created element.
99
+ #new_uri should be globaly unique.
100
+ def umlx_createAndAddInterface(new_uri,new_name=nil)
101
+ c=Cuml_Interface.new(rdf_model,new_uri)
102
+ uml_ownedMember_add(c)
103
+ c.umlx_owner=self
104
+ c.uml_name=new_name unless new_name.nil?
105
+ c.uml_visibility=::Cuml_VisibilityKind::Public
106
+ #puts "création classe #{new_name} in #{self.java_qualifiedName}"
107
+ return c
108
+ end
109
+ #Creates and add a new UML Class.
110
+ #Return the newly created element.
111
+ #new_uri should be globaly unique.
112
+ def umlx_createAndAddClass(new_uri,new_name=nil)
113
+ c=Cuml_Class.new(rdf_model,new_uri)
114
+ uml_ownedMember_add(c)
115
+ c.umlx_owner=self
116
+ c.uml_name=new_name unless new_name.nil?
117
+ c.uml_visibility=::Cuml_VisibilityKind::Public
118
+ #puts "création classe #{new_name} in #{self.java_qualifiedName}"
119
+ return c
120
+ end
121
+ #Creates and add a new UML DataType.
122
+ #Return the newly created element.
123
+ #new_uri should be globaly unique.
124
+ def umlx_createAndAddDataType(new_uri,new_name=nil)
125
+ c=Cuml_DataType.new(rdf_model,new_uri)
126
+ uml_ownedMember_add(c)
127
+ c.umlx_owner=self
128
+ c.uml_name=new_name unless new_name.nil?
129
+ #puts "création classe #{new_name} in #{self.java_qualifiedName}"
130
+ return c
131
+ end
132
+
133
+ #Creates and add a new UML Stereotype.
134
+ #Return the newly created element.
135
+ #new_uri should be globaly unique.
136
+ def umlx_createAndAddStereotype(new_uri,new_name=nil)
137
+ c=Cuml_Stereotype.new(rdf_model,new_uri)
138
+ uml_ownedMember_add(c)
139
+ c.umlx_owner=self
140
+ c.uml_name=new_name unless new_name.nil?
141
+ return c
142
+ end
143
+
144
+ #Creates and add a new UML package.
145
+ #Return the newly created element.
146
+ #new_uri should be globaly unique.
147
+ def umlx_createAndAddPackage(new_uri,new_name=nil)
148
+ c=Cuml_Package.new(rdf_model,new_uri)
149
+ uml_ownedMember_add(c)
150
+ c.umlx_owner=self
151
+ c.uml_name=new_name unless new_name.nil?
152
+ #puts "creation package #{new_name} dans #{self} (#{self.class.name})"
153
+ return c
154
+ end
155
+ end
156
+
157
+ module Muml_Classifier
158
+ #Creates and adds a new UML Operation.
159
+ #Return the newly created element.
160
+ #new_uri should be globaly unique.
161
+ def umlx_createAndAddOperation(new_uri,new_name=nil)
162
+ m=Cuml_Operation.new(rdf_model,new_uri)
163
+ self.uml_ownedOperation_add(m)
164
+ m.uml_name=new_name unless new_name.nil?
165
+ m.uml_visibility=::Cuml_VisibilityKind::Public
166
+ return m
167
+ end
168
+
169
+ #Creates and adds a new UML property.
170
+ #Return the newly created element.
171
+ #new_uri should be globaly unique.
172
+ def umlx_createAndAddProperty(new_uri,new_name=nil)
173
+ #log.debug { %{umlx_createAndAddProperty : name="#{new_name}" uri="#{uri}" owner="#{self}" owner_uri="#{self.rdf_uri}"} }
174
+ m=Cuml_Property.new(rdf_model,new_uri)
175
+ self.uml_ownedAttribute_add(m)
176
+ m.uml_name=new_name unless new_name.nil?
177
+ m.uml_isUnique=RDF_TRUE
178
+ m.uml_isOrdered=RDF_FALSE
179
+ m.uml_visibility=::Cuml_VisibilityKind::Public
180
+ #m.uml_class=self
181
+ return m
182
+ end
183
+
184
+ #Creates and adds a new UML Association.
185
+ #Return the newly created association.
186
+ #new_uri should be globaly unique.
187
+ def umlx_createAndAddAssociation(new_uri,otherEnd)
188
+ c1=self; c2=otherEnd
189
+ a=Cuml_Association.new(rdf_model,new_uri)
190
+
191
+ m1=Cuml_Property.new(rdf_model,"#{new_uri}_e1")
192
+ m1.uml_type=c2
193
+ #m1.uml_class=c1
194
+ c1.uml_ownedAttribute_add(m1)
195
+
196
+ m2=Cuml_Property.new(rdf_model,"#{new_uri}_e2")
197
+ m2.uml_type=c1
198
+ #m2.uml_class=c1
199
+ #c2.uml_ownedAttribute_add(m2)
200
+
201
+
202
+
203
+ [m1,m2].each { |m|
204
+ a.uml_memberEnd_add(m)
205
+ m.uml_association=a
206
+ m.uml_isUnique=RDF_TRUE
207
+ m.uml_isOrdered=RDF_FALSE
208
+ m.uml_visibility=::Cuml_VisibilityKind::Public
209
+ }
210
+
211
+ return [a,m1,m2]
212
+ end
213
+ end
214
+
215
+ module Muml_Element
216
+ #Create a uml_Comment and append it to uml_ownedComment
217
+ def umlx_createAndAddComment(uri,txtComment)
218
+ c=Cuml_Comment.new(rdf_model,uri);
219
+ uml_ownedComment_add(c)
220
+ c.uml_body=txtComment
221
+ end
222
+ end
@@ -0,0 +1,30 @@
1
+ #Helper methods to compute class depencies
2
+ #This feature is used primarily for imports (in ActionScript generator)
3
+
4
+ module Muml_Classifier
5
+ #returns every class this elements depends on
6
+ def umlx_computeDirectDepencies(ret=Set.new)
7
+ (uml_ownedAttribute+uml_ownedOperation).each { |a|
8
+ a.umlx_computeDirectDepencies(ret)
9
+ }
10
+ return ret
11
+ end
12
+ end
13
+
14
+ module Muml_Operation
15
+ #returns every class this elements depends on
16
+ def umlx_computeDirectDepencies(ret=Set.new)
17
+ (uml_returnResult+uml_ownedParameter).each { |a|
18
+ a.umlx_computeDirectDepencies(ret)
19
+ }
20
+ return ret
21
+ end
22
+ end
23
+
24
+ module Muml_TypedElement
25
+ #returns every class this elements depends on
26
+ def umlx_computeDirectDepencies(ret=Set.new)
27
+ ret.add(uml_type_one)
28
+ return ret
29
+ end
30
+ end
@@ -0,0 +1,115 @@
1
+
2
+ DOT_NODE_COLOR_SECONDARY="color=lightblue2, style=filled"
3
+ DOT_NODE_COLOR_PRIMARY="color=darkolivegreen1, style=filled"
4
+
5
+ module Mrdf_Model
6
+ def umlx_generateCompositonDotDiagram
7
+ return unless context[:generateCompositionDiagram,false]
8
+ mtk_writeSession("#{context[:javaDir]}/composition.dot") {
9
+ umlx_composition_dotDiagram
10
+ }
11
+ end
12
+ def umlx_composition_dotDiagram
13
+ write <<END
14
+ digraph {
15
+ rankdir=LR
16
+ Node[shape=box,fontsize=10,color=darkolivegreen1]
17
+ END
18
+ uml_Class_all.each { |c|
19
+ next if c.kind_of?(Muml_Enumeration)
20
+ style=""
21
+ ster=""
22
+ if c.uml_isAbstract?
23
+ style=",color=pink"
24
+ elsif c.kind_of?(Muml_Interface)
25
+ style=",color=khaki"
26
+ ster="<<interface>>\\n"
27
+ elsif ! (c.uml_general_inv.empty?)
28
+ # incorrect class
29
+ # not abstract with inheriting class
30
+ style=",color=red,style=filled"
31
+ else
32
+ style=",color=red,style=filled"
33
+ style=",style=filled"
34
+ end
35
+ write(%{#{c.dotId} [label="#{ster}#{c.uml_name}" #{style}]\n})
36
+ #Implements
37
+ if c.kind_of?(Muml_Class)
38
+ c.uml_implementation.each { |g|
39
+ o=g.uml_supplier_one
40
+ write( %{#{c.dotId} -> #{o.dotId} [arrowtail=none,arrowhead=onormal,style=dotted]\n} )
41
+ }
42
+ end
43
+ c.uml_generalization.each { |g|
44
+ o=g.uml_general_one
45
+ write( %{#{c.dotId} -> #{o.dotId} [arrowtail=none,arrowhead=onormal,color=indianred3]\n} )
46
+
47
+ }
48
+
49
+ }
50
+
51
+ #Composition
52
+ each { |k,p|
53
+ next unless p.kind_of?(Muml_Association)
54
+ ce=nil #composante
55
+ ci=nil #composite
56
+ p.uml_memberEnd.each {|a|
57
+ if a.uml_aggregation_one.isComposite?
58
+ ci=a
59
+ else
60
+ ce=a
61
+ end
62
+ }
63
+ next if ci.nil? || ce.nil?
64
+ next if ci.uml_type_one.kind_of?(Muml_Stereotype)
65
+ next if ce.uml_type_one.kind_of?(Muml_Stereotype)
66
+
67
+ write( %{#{ce.uml_type_one.dotId} -> #{ci.uml_type_one.dotId} [arrowhead="none" arrowtail="diamond"]\n} )
68
+ }
69
+
70
+
71
+ write("}\n")
72
+
73
+ end
74
+ end
75
+
76
+ module Muml_Class
77
+ # generates a standard class diagram for this class in the dot language.
78
+ # Note:
79
+ # 1 level of Generalization is included.
80
+ # Attributes are included
81
+ def umlx_classDiagram_dotFile
82
+ write("digraph {\n")
83
+ #write("rankdir=LR;\n");
84
+ write("node [shape=box,#{DOT_NODE_COLOR_SECONDARY}];\n")
85
+
86
+ write(%{#{dotId} [label="#{uml_name}",#{DOT_NODE_COLOR_PRIMARY}]\n})
87
+
88
+ uml_generalization.each { |g|
89
+ g.umlx_classDiagram_dotFragment
90
+ }
91
+ uml_ownedAttribute.each { |oa|
92
+ oa.umlx_classDiagram_dotFragment
93
+ }
94
+ write("}\n")
95
+ end
96
+ end
97
+ module Muml_Generalization
98
+ # Generate dot graphical instruction for this element.
99
+ def umlx_classDiagram_dotFragment
100
+ c=uml_general_one
101
+ o=uml_specific_one
102
+ write(%{#{c.dotId} [label="#{c.uml_name}"]\n})
103
+ write(%{#{c.dotId}->#{o.dotId} [arrowhead=none,arrowtail=onormal,minlen=2]\n})
104
+ end
105
+ end
106
+ module Muml_Property
107
+ # Generate dot graphical instruction for this element.
108
+ def umlx_classDiagram_dotFragment
109
+ return if umlx_isAttribute?
110
+ o=uml_class_one
111
+ c=uml_type_one
112
+ write(%{#{c.dotId} [label="#{c.uml_name}"]\n})
113
+ write(%{#{o.dotId}->#{c.dotId} [arrowtail=none,arrowhead=vee,minlen=2,label="#{uml_name}"]\n})
114
+ end
115
+ end
@@ -0,0 +1,36 @@
1
+ # Enumerated type helpers.
2
+ #
3
+ # Detects UML enumerated types and provides helper methods and constants.
4
+ #
5
+ # EXAMPLE:
6
+ # constant: Cuml_visibilityKind::Public
7
+ # method: Cuml_visibilityKind isPublic?
8
+ #
9
+ # NOTE: UML Enumerated type are declared in this file.
10
+ module Mumlx_EnumeratedValue
11
+ # Internal use
12
+ def initialize(model,uri)
13
+ super(model,uri)
14
+ a=uri.split("_",3)
15
+ v=a[2].capitalize
16
+ @@z=self
17
+ cmd="class ::#{self.class}< ::Crdfs_Class\n public\n #{v}=@@z\n def is#{v}?\n return self==#{v}\n end\n end"
18
+ eval(cmd)
19
+ @@z=nil
20
+ end
21
+ end
22
+
23
+ # UML2 enumerated type declaration
24
+ class Cuml_VisibilityKind < ::Crdfs_Class ; include Mumlx_EnumeratedValue ; end
25
+ class Cuml_ParameterDirectionKind < ::Crdfs_Class ; include Mumlx_EnumeratedValue ; end
26
+ class Cuml_AggregationKind < ::Crdfs_Class ; include Mumlx_EnumeratedValue ; end
27
+ class Cuml_CallConcurrencyKind < ::Crdfs_Class ; include Mumlx_EnumeratedValue ; end
28
+ class Cuml_MessageKind < ::Crdfs_Class ; include Mumlx_EnumeratedValue ; end
29
+ class Cuml_MessageSort < ::Crdfs_Class ; include Mumlx_EnumeratedValue ; end
30
+ class Cuml_ExpansionKind < ::Crdfs_Class ; include Mumlx_EnumeratedValue ; end
31
+ class Cuml_InteractionOperator < ::Crdfs_Class ; include Mumlx_EnumeratedValue ; end
32
+ class Cuml_TransitionKind < ::Crdfs_Class ; include Mumlx_EnumeratedValue ; end
33
+ class Cuml_PseudostateKind < ::Crdfs_Class ; include Mumlx_EnumeratedValue ; end
34
+ class Cuml_ParameterEffectKind < ::Crdfs_Class ; include Mumlx_EnumeratedValue ; end
35
+ class Cuml_ObjectNodeOrderingKind < ::Crdfs_Class ; include Mumlx_EnumeratedValue ; end
36
+ class Cuml_ConnectorKind < ::Crdfs_Class ; include Mumlx_EnumeratedValue ; end
@@ -0,0 +1,5 @@
1
+ module Muml_Enumeration
2
+ #UML does not support implementation for enums
3
+ #Because Java does, this feature is added
4
+ rdf_safe_attr_reader_many :uml_implementation
5
+ end
@@ -0,0 +1,14 @@
1
+ module Muml_Classifier
2
+ #returns every type assignable to this classifier
3
+ #(this includes self and any class deriving from it)
4
+ def umlx_ownedAndInheritedOperation(ret=Set.new)
5
+ uml_ownedOperation.each {|biz|
6
+ ret << biz
7
+ }
8
+ uml_generalization.each { |g|
9
+ next if g.kind_of?(Muml_Interface)
10
+ g.uml_general_one.umlx_ownedAndInheritedOperation(ret)
11
+ }
12
+ return ret
13
+ end
14
+ end