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.
- data/History.txt +8 -0
- data/Manifest.txt +39 -0
- data/README.txt +77 -0
- data/Rakefile +23 -0
- data/lib/ontomde-uml2.rb +31 -0
- data/lib/ontomde-uml2/autoImplement.rb +196 -0
- data/lib/ontomde-uml2/cardinality.rb +130 -0
- data/lib/ontomde-uml2/check.rb +28 -0
- data/lib/ontomde-uml2/createAndAdd.rb +222 -0
- data/lib/ontomde-uml2/depencies.rb +30 -0
- data/lib/ontomde-uml2/dotDiagram.rb +115 -0
- data/lib/ontomde-uml2/enumerated.rb +36 -0
- data/lib/ontomde-uml2/extension.rb +5 -0
- data/lib/ontomde-uml2/helper.rb +14 -0
- data/lib/ontomde-uml2/multipleInheritance.rb +104 -0
- data/lib/ontomde-uml2/nt_old_to_nt_new.sh +28 -0
- data/lib/ontomde-uml2/owner.rb +61 -0
- data/lib/ontomde-uml2/salvageErrors.rb +71 -0
- data/lib/ontomde-uml2/select.rb +85 -0
- data/lib/ontomde-uml2/shortcut.rb +27 -0
- data/lib/ontomde-uml2/uml2.rb +236 -0
- data/lib/ontomde-uml2/uml2.rdfs.nt +2560 -0
- data/lib/ontomde-uml2/umlx.rb +638 -0
- data/lib/ontomde-uml2/version.rb +5 -0
- data/lib/ontomde-uml2/versionSignature.rb +34 -0
- data/test/_test_dot.rb +53 -0
- data/test/_test_perf.rb +44 -0
- data/test/model/.project +11 -0
- data/test/model/SID.emx +25904 -0
- data/test/model/SID.emx.nt +62554 -0
- data/test/model/SID.uml2 +25904 -0
- data/test/model/simple2.emx +891 -0
- data/test/model/simple2.emx.nt +2713 -0
- data/test/model/simple2WithProfile.emx +771 -0
- data/test/test_base.rb +97 -0
- data/test/test_clone.rb +78 -0
- data/test/test_misc.rb +196 -0
- data/test/test_ontomde-uml2.rb +0 -0
- metadata +113 -0
@@ -0,0 +1,104 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
module Mrdf_Model
|
5
|
+
def umlx_mapMultipleInheritanceToInterface!
|
6
|
+
nl=Set.new
|
7
|
+
umlx_classesWithMultipleInheritance.each {|c|
|
8
|
+
c.umlx_mapMultipleInheritanceToInterface!(nl)
|
9
|
+
}
|
10
|
+
|
11
|
+
end
|
12
|
+
def umlx_classesWithMultipleInheritance(ret=Set.new)
|
13
|
+
uml_Class_all.each {|c|
|
14
|
+
next if c.kind_of?(Muml_Interface) || c.kind_of?(Muml_Enumeration)
|
15
|
+
next if c.uml_generalization.length <2
|
16
|
+
ret << c
|
17
|
+
}
|
18
|
+
return ret
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
module Muml_Class
|
24
|
+
#nl : no loop
|
25
|
+
def umlx_mapMultipleInheritanceToInterface!(nl)
|
26
|
+
if nl.include?(self)
|
27
|
+
log.error {"umlx_mapMultipleInheritanceToInterface!: multiple call detected for #{self}" }
|
28
|
+
return
|
29
|
+
end
|
30
|
+
nl<< self
|
31
|
+
log.debug { "umlx_mapMultipleInheritanceToInterface! #{self}::#{self.class.name}" }
|
32
|
+
#Create an interface to replace this class
|
33
|
+
#Interface will have the name of the class
|
34
|
+
#Class implements the interface
|
35
|
+
i=umlx_owner_one.umlx_createAndAddInterface("#{self.rdf_uri}_interface",self.uml_name.to_s)
|
36
|
+
self.umlx_createAndAddImplementation(i)
|
37
|
+
|
38
|
+
#Obviously The class name must change to avoid a name clash.
|
39
|
+
self.uml_name="#{self.uml_name}_Implem"
|
40
|
+
|
41
|
+
#process type 3 elements (refer to diagram)
|
42
|
+
#(type 3 are handled as type 1 from the other extremity)
|
43
|
+
#Change classes this class generalize to interface
|
44
|
+
ug_copy=Array.new ; uml_generalization.each {|g| ug_copy<< g }
|
45
|
+
ug_copy.each { |general|
|
46
|
+
t=general.uml_general_one
|
47
|
+
#log.debug { "mi recursing trough generalization from #{self} to #{t}"}
|
48
|
+
i2=t.umlx_mapMultipleInheritanceToInterface!(nl)
|
49
|
+
i.umlx_createAndAddGeneralization(i2)
|
50
|
+
}
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
#process type 2 elements (refer to diagram)
|
55
|
+
#replace this class as attribute with interface i everywhere in model
|
56
|
+
uml_type_inv.each {|m|
|
57
|
+
#log.debug { "Changing attribut #{m} type from #{self} to #{i}" }
|
58
|
+
m.uml_type=i
|
59
|
+
}
|
60
|
+
|
61
|
+
#process type 1 elements (refer to diagram)
|
62
|
+
#replace this class generalization with i interface implementation
|
63
|
+
uml_general_inv.each { |general|
|
64
|
+
general.uml_generalization_inv.each {|cgen|
|
65
|
+
#log.debug { "Changing #{cgen} generalization #{self} to implement #{i}" }
|
66
|
+
#create new implementation
|
67
|
+
cgen.umlx_createAndAddImplementation(i)
|
68
|
+
#remove old generalization
|
69
|
+
cgen.uml_generalization.delete(general)
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
#process type 4 and 5 elements (refer to diagram)
|
74
|
+
#copy property from this class to interface i
|
75
|
+
uml_ownedAttribute.each { |a|
|
76
|
+
#log.debug { "Copy property #{a} to interface #{i}" }
|
77
|
+
na=i.umlx_createAndAddProperty("#{a.rdf_uri}_interface",a.uml_name.to_s);
|
78
|
+
a.umlx_copyToAttributeProperty(na)
|
79
|
+
}
|
80
|
+
|
81
|
+
#process type 7 elements (refer to diagram)
|
82
|
+
#copy method from this class to interface i
|
83
|
+
uml_ownedOperation.each { |op|
|
84
|
+
#log.debug { "Copy operation #{op} to interface #{i}" }
|
85
|
+
nop=i.umlx_createAndAddOperation("#{op.rdf_uri}_interface",op.uml_name.to_s)
|
86
|
+
#copy parameter
|
87
|
+
op.uml_ownedParameter.each { |p|
|
88
|
+
np=nop.umlx_createAndAddParameter("#{p.rdf_uri}_interface",p.uml_name.to_s)
|
89
|
+
p.umlx_copyToAttributeProperty(np)
|
90
|
+
}
|
91
|
+
#copy return parameter
|
92
|
+
op.uml_returnResult.each { |p|
|
93
|
+
np=nop.umlx_createAndAddReturnParameter("#{p.rdf_uri}_interface",p.uml_name.to_s)
|
94
|
+
p.umlx_copyToAttributeProperty(np)
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
|
99
|
+
return i
|
100
|
+
end
|
101
|
+
|
102
|
+
|
103
|
+
end
|
104
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
(
|
3
|
+
echo "("
|
4
|
+
echo "echo \"#!ontomdx\""
|
5
|
+
|
6
|
+
echo "cat uml2.rdfs.nt.org | sed '"
|
7
|
+
(
|
8
|
+
cat uml2.rdfs.nt.org | grep 'rdf-syntax-ns#Property' | sed 's/^<\([^<>]*\)> <\([^<>]*\)>.*/URI=\1/g' | uniq
|
9
|
+
#cat uml2.rdfs.nt.org | sed 's/^<\([^<>]*\)> <\([^<>]*\)>.*/URI=\2/g' | uniq
|
10
|
+
#cat uml2.rdfs.nt.org | sed 's/^<\([^<>]*\)> <\([^<>]*\)> <\([^<>]*\)>.*/URI=\3/g'
|
11
|
+
) \
|
12
|
+
| grep URI \
|
13
|
+
| sort | uniq \
|
14
|
+
| sed 's/.*#\(.*\)_\(.*\)/s\/\\(http:\\\/\\\/uml\\\/2#\\)\1_\2\/\\1\2\/g/g' \
|
15
|
+
|
16
|
+
echo "' \\"
|
17
|
+
# removes duplicate declaration (became homonyms)
|
18
|
+
echo ") | sort | uniq \\"
|
19
|
+
echo " > uml2.rdfs.nt_tmp"
|
20
|
+
|
21
|
+
) > nt_old_to_nt_new_tmp.sh
|
22
|
+
|
23
|
+
./nt_old_to_nt_new_tmp.sh
|
24
|
+
mv uml2.rdfs.nt_tmp uml2.rdfs.nt
|
25
|
+
#cat uml2.rdfs.nt.org | sort | uniq > tmp2
|
26
|
+
#diff uml2.rdfs.nt.org uml2.rdfs.nt
|
27
|
+
|
28
|
+
rm -f uml2.rdfs.nt.rb
|
@@ -0,0 +1,61 @@
|
|
1
|
+
|
2
|
+
module Muml_Package
|
3
|
+
def umlx_owner_one
|
4
|
+
#return uml_ownedMember_inv_one0
|
5
|
+
ext_isReferencedBy.each { |res|
|
6
|
+
return res if res.respond_to?(:uml_ownedMember) && res.uml_ownedMember.include?(self)
|
7
|
+
}
|
8
|
+
return nil
|
9
|
+
end
|
10
|
+
def umlx_owner=(p)
|
11
|
+
old=umlx_owner_one
|
12
|
+
old.uml_ownedMember.delete(self) unless old.nil?
|
13
|
+
p.uml_ownedMember_add(self)
|
14
|
+
ext_isReferencedBy_add(p)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
module Muml_Classifier
|
19
|
+
def umlx_owner_one
|
20
|
+
#return uml_ownedMember_inv_one0
|
21
|
+
ext_isReferencedBy.each { |res|
|
22
|
+
return res if res.respond_to?(:uml_ownedMember) && res.uml_ownedMember.include?(self)
|
23
|
+
}
|
24
|
+
return nil
|
25
|
+
end
|
26
|
+
def umlx_owner=(p)
|
27
|
+
old=umlx_owner_one
|
28
|
+
old.uml_ownedMember.delete(self) unless old.nil?
|
29
|
+
p.uml_ownedMember_add(self)
|
30
|
+
ext_isReferencedBy_add(p)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
module Muml_Operation
|
35
|
+
#returns element owner if found, nil otherwise
|
36
|
+
def umlx_owner_one
|
37
|
+
ext_isReferencedBy.each { |res|
|
38
|
+
next unless res.kind_of?(Muml_Classifier)
|
39
|
+
next if res.kind_of?(Muml_Association)
|
40
|
+
next unless res.uml_ownedOperation.include?(self)
|
41
|
+
return res
|
42
|
+
}
|
43
|
+
log.error("umlx_owner_one not found for #{self.class} #{self}")
|
44
|
+
return nil
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
module Muml_Property
|
49
|
+
#returns element owner if found, nil otherwise
|
50
|
+
def umlx_owner_one(donotlog=false)
|
51
|
+
ext_isReferencedBy.each { |res|
|
52
|
+
next unless res.kind_of?(Muml_Classifier)
|
53
|
+
next if res.kind_of?(Muml_Association)
|
54
|
+
next unless res.uml_ownedAttribute.include?(self)
|
55
|
+
return res
|
56
|
+
}
|
57
|
+
log.error("umlx_owner_one not found for #{self.class} #{self}") unless donotlog
|
58
|
+
return nil
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
@@ -0,0 +1,71 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
module Mrdf_Model
|
6
|
+
# Tries to fix a broken UML model.
|
7
|
+
# This feature is not meant for serious work
|
8
|
+
# and should only be used for quick demonstration.
|
9
|
+
def umlx_tryToSalvageErrors!
|
10
|
+
return unless context[:salvage,false]
|
11
|
+
log.error { <<END
|
12
|
+
|
13
|
+
************ salvage mode is on ***************
|
14
|
+
Salvage mode should only be used for quick
|
15
|
+
demonstration purposes and never for any serious
|
16
|
+
work.
|
17
|
+
************ salvage mode is on ***************
|
18
|
+
END
|
19
|
+
}
|
20
|
+
each { |k,v|
|
21
|
+
# fix untyped property
|
22
|
+
if v.kind_of?(Muml_Property)
|
23
|
+
v.uml_type=v.umlx_owner_one.umlx_dataType_string if v.uml_type.empty?
|
24
|
+
# id is generated if persistence is enabled
|
25
|
+
v.uml_name="business Id" if context[:db] && v.uml_name.to_s=="id"
|
26
|
+
end
|
27
|
+
|
28
|
+
#fix blank or missing names
|
29
|
+
if v.kind_of?(Muml_NamedElement)
|
30
|
+
v.uml_name="missing_name_in_model_"+v.rdf_uri if v.uml_name.empty? || v.uml_name.to_s==""
|
31
|
+
end
|
32
|
+
}
|
33
|
+
each { |k,v|
|
34
|
+
|
35
|
+
#fix visibility (force to public)
|
36
|
+
if v.respond_to?(:uml_visibility)
|
37
|
+
v.uml_visibility=::Cuml_VisibilityKind::Public
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
# ejb service should not be abstract
|
42
|
+
if v.kind_of?(Muml_Class) && v.umlx_hasStereotype?("Service")
|
43
|
+
v.uml_isAbstract="false"
|
44
|
+
end
|
45
|
+
|
46
|
+
#no duplicate attribute (in one single class)
|
47
|
+
if v.kind_of?(Muml_Class)
|
48
|
+
names=Set.new
|
49
|
+
i=1
|
50
|
+
v.uml_ownedAttribute.each { |a|
|
51
|
+
n=a.uml_name.to_s
|
52
|
+
if a.respond_to?(:java_Name)
|
53
|
+
#in case java is loaded
|
54
|
+
n=a.java_Name.to_s
|
55
|
+
end
|
56
|
+
|
57
|
+
if names.include?(n)
|
58
|
+
i=i+1
|
59
|
+
a.uml_name="#{v.uml_name}_duplicate_#{i}"
|
60
|
+
else
|
61
|
+
names.add(n)
|
62
|
+
end
|
63
|
+
}
|
64
|
+
|
65
|
+
end
|
66
|
+
}
|
67
|
+
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# utility methods to select parts of a model
|
2
|
+
#
|
3
|
+
module Mrdf_Model
|
4
|
+
#search and returns every uml model
|
5
|
+
def uml_Model_all
|
6
|
+
return @typeIndex[Muml_Model]
|
7
|
+
ret=Array.new
|
8
|
+
each { |k,m|
|
9
|
+
next unless m.kind_of?(Muml_Model)
|
10
|
+
ret << m
|
11
|
+
}
|
12
|
+
return ret
|
13
|
+
end
|
14
|
+
def uml_Class_all(ret=Set.new)
|
15
|
+
#return @typeIndex[Muml_Class]
|
16
|
+
uml_Model_all.each { |m|
|
17
|
+
m.uml_Class_all(ret)
|
18
|
+
}
|
19
|
+
return ret
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
module Muml_Model
|
24
|
+
#search and returns evry uml class contained in the current model.
|
25
|
+
#NOTE: inner classes are not included
|
26
|
+
def uml_Class_all(ret=Set.new)
|
27
|
+
uml_ownedMember.each { |n|
|
28
|
+
if n.kind_of?(Muml_Enumeration)||n.kind_of?(Muml_Interface) || (n.kind_of?(Muml_Class) && n.umlx_isReallyAClass?)
|
29
|
+
ret << n
|
30
|
+
elsif n.kind_of?(Muml_Package) && !n.kind_of?(Muml_Profile)
|
31
|
+
n.uml_Class_all(ret)
|
32
|
+
else
|
33
|
+
#log.debug { "uml_Class_all ignored #{n.class.name} #{n}" }
|
34
|
+
end
|
35
|
+
}
|
36
|
+
return ret
|
37
|
+
end
|
38
|
+
#search and returns evry uml class contained in the current model.
|
39
|
+
#NOTE: inner classes are not included
|
40
|
+
def uml_UseCase_all(ret=Array.new)
|
41
|
+
uml_ownedMember.each { |n|
|
42
|
+
if n.kind_of?(Muml_UseCase)
|
43
|
+
ret << n
|
44
|
+
elsif n.kind_of?(Muml_Package) && !n.kind_of?(Muml_Profile)
|
45
|
+
n.uml_UseCase_all(ret)
|
46
|
+
else
|
47
|
+
#log.debug { "ignored #{n}" }
|
48
|
+
end
|
49
|
+
}
|
50
|
+
return ret
|
51
|
+
end
|
52
|
+
end
|
53
|
+
module Muml_Package
|
54
|
+
#search and returns evry uml class contained in the current package.
|
55
|
+
#NOTE: inner classes are not included
|
56
|
+
def uml_Class_all(ret=Array.new)
|
57
|
+
uml_ownedMember.each { |n|
|
58
|
+
if n.kind_of?(Muml_Enumeration)||n.kind_of?(Muml_Interface) || (n.kind_of?(Muml_Class) && n.umlx_isReallyAClass?)
|
59
|
+
ret << n
|
60
|
+
elsif n.kind_of?(Muml_Package) && !n.kind_of?(Muml_Profile)
|
61
|
+
n.uml_Class_all(ret)
|
62
|
+
else
|
63
|
+
#log.debug { "ignored #{n}" }
|
64
|
+
end
|
65
|
+
}
|
66
|
+
return ret
|
67
|
+
end
|
68
|
+
#search and returns evry uml class contained in the current package.
|
69
|
+
#NOTE: inner classes are not included
|
70
|
+
def uml_UseCase_all(ret=Array.new)
|
71
|
+
uml_ownedMember.each { |n|
|
72
|
+
if n.kind_of?(Muml_UseCase)
|
73
|
+
ret << n
|
74
|
+
next
|
75
|
+
end
|
76
|
+
if n.kind_of?(Muml_Package) && !n.kind_of?(Muml_Profile)
|
77
|
+
n.uml_UseCase_all(ret)
|
78
|
+
next
|
79
|
+
end
|
80
|
+
#log.debug { "ignored #{n}" }
|
81
|
+
}
|
82
|
+
return ret
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#Handle shortcuts (from a namespace to a model)
|
2
|
+
|
3
|
+
module Mrdf_Model
|
4
|
+
#Transform a set of UML models with links into a
|
5
|
+
#single model with uml ownedMember.
|
6
|
+
def umlx_processShortcuts!
|
7
|
+
each_value { |s|
|
8
|
+
next unless s.respond_to?(:umlx_shortcut)
|
9
|
+
next if s.umlx_shortcut.nil?
|
10
|
+
|
11
|
+
s.umlx_shortcut.each {|p|
|
12
|
+
#remove link with package
|
13
|
+
p.uml_ownedMember_inv.each { |m|
|
14
|
+
m.uml_ownedMember.delete(p)
|
15
|
+
}
|
16
|
+
|
17
|
+
#replace shortcut with ownership
|
18
|
+
s.uml_ownedMember_add(p)
|
19
|
+
}
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
}
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,236 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
|
3
|
+
class Crdf_Model
|
4
|
+
# Loads UML2 metamodel.
|
5
|
+
def loadUml2
|
6
|
+
loadMetaModelFromFile("#{File.dirname(__FILE__)}/uml2.rdfs.nt");
|
7
|
+
addTypeIndex(Muml_Class)
|
8
|
+
addTypeIndex(Muml_Model)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
module Muml_Classifier
|
13
|
+
# Returns in a Set any class this class inherit froms, both directly and indirectly (trough other classes)
|
14
|
+
#parameter is used internaly for recursion and should not be used.
|
15
|
+
def umlx_classifier_generalization_indirect(s=Set.new)
|
16
|
+
self.uml_generalization.each { |gene|
|
17
|
+
gene.uml_general.each{ |c|
|
18
|
+
recurse=!s.include?(c) # anti boucle infinie sur modele KO
|
19
|
+
s.add(c)
|
20
|
+
c.umlx_classifier_generalization_indirect(s) if recurse
|
21
|
+
}
|
22
|
+
}
|
23
|
+
return s
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
module Muml_Namespace
|
28
|
+
# Returns containing package.
|
29
|
+
# NOTE: Returns null if containing package is a Model.
|
30
|
+
def umlx_package
|
31
|
+
#TODO: utiliser relation inverse when available
|
32
|
+
p=umlx_owner_one
|
33
|
+
return nil if p.kind_of?(Cuml_Model)
|
34
|
+
return p
|
35
|
+
end
|
36
|
+
|
37
|
+
# Internal use.
|
38
|
+
#
|
39
|
+
# Kept for possible future use.
|
40
|
+
def _computePackage_notUsed
|
41
|
+
rdf_model.each { |a,x|
|
42
|
+
if(x.class==Cuml_Class)
|
43
|
+
x.uml_nestedClassifier {
|
44
|
+
return x if e==self
|
45
|
+
}
|
46
|
+
end
|
47
|
+
if(x.class==Cuml_Package)
|
48
|
+
x.uml_ownedMember.each { |e|
|
49
|
+
return x if e==self
|
50
|
+
}
|
51
|
+
end
|
52
|
+
}
|
53
|
+
return nil
|
54
|
+
end
|
55
|
+
end
|
56
|
+
module Muml_Namespace
|
57
|
+
#Returns the chain of namespace owning this element including this element
|
58
|
+
def umlx_hierarchy
|
59
|
+
p=umlx_package
|
60
|
+
if(p==nil) # || p.kind_of?(Muml_Model))
|
61
|
+
r=Array.new()
|
62
|
+
else
|
63
|
+
r=p.umlx_hierarchy
|
64
|
+
end
|
65
|
+
r.push(self) if !self.kind_of?(Muml_Model)
|
66
|
+
return r
|
67
|
+
end
|
68
|
+
|
69
|
+
#Returns the chain of namespace owning this element *NOT* including this element
|
70
|
+
def umlx_sub_hierarchy
|
71
|
+
p=umlx_package
|
72
|
+
if(p==nil)
|
73
|
+
r=Array.new()
|
74
|
+
else
|
75
|
+
r=p.umlx_hierarchy
|
76
|
+
end
|
77
|
+
return r
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
module ::Muml_NamedElement
|
82
|
+
#Internal use
|
83
|
+
#
|
84
|
+
#Used by web server
|
85
|
+
def to_s
|
86
|
+
s=uml_name.to_s
|
87
|
+
return s if s.length>0
|
88
|
+
super
|
89
|
+
end
|
90
|
+
end
|
91
|
+
module ::Muml_Generalization
|
92
|
+
#Internal use
|
93
|
+
#
|
94
|
+
#Used by web server
|
95
|
+
def to_s
|
96
|
+
return "->#{uml_general.to_s}"
|
97
|
+
end
|
98
|
+
end
|
99
|
+
module ::Muml_Implementation
|
100
|
+
#Internal use
|
101
|
+
#
|
102
|
+
#Used by web server
|
103
|
+
def to_s
|
104
|
+
return "->#{uml_realizingClassifier.to_s}"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
module ::Muml_Association
|
109
|
+
#Internal use
|
110
|
+
#
|
111
|
+
#Used by web server
|
112
|
+
def to_s
|
113
|
+
return "#{uml_ownedEnd}->#{uml_memberEnd}"
|
114
|
+
end
|
115
|
+
end
|
116
|
+
module ::Muml_LiteralUnlimitedNatural
|
117
|
+
def to_s
|
118
|
+
return uml_value.to_s if uml_value.to_s.length>0
|
119
|
+
super
|
120
|
+
end
|
121
|
+
def umlx_to_i
|
122
|
+
return 0 if to_s.nil?
|
123
|
+
return to_s.to_i;
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
127
|
+
module ::Muml_LiteralInteger
|
128
|
+
def to_s
|
129
|
+
return uml_value.to_s if uml_value.to_s.length>0
|
130
|
+
super
|
131
|
+
end
|
132
|
+
def umlx_to_i
|
133
|
+
return 0 if to_s.nil?
|
134
|
+
return to_s.to_i;
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
module ::Muml_Property
|
139
|
+
#Returns the other end of the association this property is linked to.
|
140
|
+
#NOTES:
|
141
|
+
# Returns nil if this class is not part of an association
|
142
|
+
# Returns nil if other en is not navigable.
|
143
|
+
def umlx_otherEnd
|
144
|
+
self.uml_association.each { |ass|
|
145
|
+
ass.uml_memberEnd.each { |p|
|
146
|
+
return p if p!=self
|
147
|
+
}
|
148
|
+
}
|
149
|
+
return nil
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
module ::Muml_Class
|
154
|
+
# returns ownedAttribute including non navigable ones.
|
155
|
+
def umlx_ownedAttribute
|
156
|
+
ret=Array.new
|
157
|
+
ext_isReferencedBy.each { |res|
|
158
|
+
next if !res.kind_of?(Cuml_Property)
|
159
|
+
##log.debug "referencedBy : #{res.class.name}"
|
160
|
+
next if res.uml_type_one!=self
|
161
|
+
ret << res
|
162
|
+
}
|
163
|
+
return ret
|
164
|
+
end
|
165
|
+
|
166
|
+
# returns true if this class is a direct composante member end of a composition.
|
167
|
+
# NOTE:
|
168
|
+
# This method returns direct relations only.
|
169
|
+
# cf: umlx_isComposanteRec? for recursive
|
170
|
+
def umlx_isComposante?
|
171
|
+
#(self.umlx_ownedAttribute-self.uml_ownedAttribute).each { |a|
|
172
|
+
(self.umlx_ownedAttribute).each { |a|
|
173
|
+
next if self.uml_ownedAttribute.include?(a)
|
174
|
+
#next if !p.kind_of?(Cuml_Property)
|
175
|
+
#log.debug "#{self.uml_name} --> #{a.umlx_otherEnd.class.name}"
|
176
|
+
#[a, a.umlx_otherEnd].each { |p|
|
177
|
+
[a].each { |p|
|
178
|
+
|
179
|
+
return true if (!p.nil?) && (!p.uml_aggregation_one0.nil?)&& (p.uml_aggregation_one.isComposite?)
|
180
|
+
}}
|
181
|
+
return false
|
182
|
+
end
|
183
|
+
|
184
|
+
# returns true if this class is this class or one of its inheriting class is a direct composante member end of a composition.
|
185
|
+
# cf: umlx_isComposante? for non recursive behavior.
|
186
|
+
def umlx_isComposanteRec?
|
187
|
+
return true if umlx_isComposante?
|
188
|
+
self.umlx_classifier_generalization_indirect.each {|c|
|
189
|
+
return true if c.umlx_isComposanteRec?
|
190
|
+
}
|
191
|
+
return false
|
192
|
+
end
|
193
|
+
|
194
|
+
# returns true if this class carries directly a composition
|
195
|
+
# cf umlx_carryCompositionRec? for recursive behavior.
|
196
|
+
def umlx_carryComposition?
|
197
|
+
(self.uml_ownedAttribute+self.umlx_ownedAttribute).each { |a|
|
198
|
+
#next if !p.kind_of?(Cuml_Property)
|
199
|
+
#log.debug "#{self.uml_name} --> #{a.umlx_otherEnd.class.name}"
|
200
|
+
[a, a.umlx_otherEnd].each { |p|
|
201
|
+
|
202
|
+
return true if (!p.nil?) && (!p.uml_aggregation_one0.nil?)&& (p.uml_aggregation_one.isComposite?)
|
203
|
+
}}
|
204
|
+
return false
|
205
|
+
end
|
206
|
+
#
|
207
|
+
# returns true if this class or one of its inherited classes carries directly a composition
|
208
|
+
# cf umlx_carryComposition? for non recursive behavior.
|
209
|
+
def umlx_carryCompositionRec?
|
210
|
+
return true if umlx_carryComposition?
|
211
|
+
self.umlx_classifier_generalization_indirect.each {|c|
|
212
|
+
return true if c.umlx_carryCompositionRec?
|
213
|
+
}
|
214
|
+
return false
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
module Muml_Operation
|
219
|
+
#retrieve operation return parameter if any (nil otherwise)
|
220
|
+
def umlx_returnResult_one0
|
221
|
+
fp=nil
|
222
|
+
uml_returnResult.each { |p|
|
223
|
+
#pour RSM (non conformite de l'export)
|
224
|
+
next unless p.uml_direction_one.isReturn?
|
225
|
+
fp=p
|
226
|
+
}
|
227
|
+
uml_ownedParameter.each { |p|
|
228
|
+
next unless p.uml_direction_one.isReturn?
|
229
|
+
fp=p
|
230
|
+
}
|
231
|
+
return fp
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
|
236
|
+
#end # ProfileCoreUML
|