Module: Muml_Classifier
- Defined in:
- lib/ontomde-uml2/umlx.rb,
lib/ontomde-uml2/uml2.rb,
lib/ontomde-uml2/umlx.rb,
lib/ontomde-uml2/umlx.rb,
lib/ontomde-uml2/umlx.rb,
lib/ontomde-uml2/umlx.rb,
lib/ontomde-uml2/owner.rb,
lib/ontomde-uml2/helper.rb,
lib/ontomde-uml2/depencies.rb,
lib/ontomde-uml2/createAndAdd.rb,
lib/ontomde-uml2/createAndAdd.rb
Overview
Helper methods to compute class depencies This feature is used primarily for imports (in ActionScript generator)
Instance Method Summary collapse
-
#umlx_assignableClassifier(ret = Set.new) ⇒ Object
returns every type assignable to this classifier (this includes self and any class deriving from it) Template parameter are filtered out.
-
#umlx_classifier_generalization_indirect(s = Set.new) ⇒ Object
Returns in a Set any class this class inherit froms, both directly and indirectly (trough other classes) Note: parameter is used internaly for recursion and should not be used.
-
#umlx_computeDirectDepencies(ret = Set.new) ⇒ Object
returns every class this elements depends on.
-
#umlx_createAndAddAssociation(new_uri, otherEnd) ⇒ Object
Creates and adds a new UML Association.
-
#umlx_createAndAddEnumeration(new_uri, new_name = nil) ⇒ Object
Creates and add a new UML Enumeration.
-
#umlx_createAndAddOperation(new_uri, new_name = nil) ⇒ Object
Creates and adds a new UML Operation.
-
#umlx_createAndAddProperty(new_uri, new_name = nil) ⇒ Object
Creates and adds a new UML property.
-
#umlx_getElementNamed(name) ⇒ Object
returns nil or element with the proper name in the current namespace.
-
#umlx_hasRelation? ⇒ Boolean
returns true if this class directly carries associations, compositions or aggregations.
-
#umlx_isTemplateParameter? ⇒ Boolean
heuristique.
-
#umlx_model ⇒ Object
Returns UML Model containing self.
-
#umlx_ownedAndInheritedOperation(ret = Set.new) ⇒ Object
returns every type assignable to this classifier (this includes self and any class deriving from it).
-
#umlx_ownedAttributeHierarchical ⇒ Object
attribute I own directly or indirectly via inheritance.
-
#umlx_ownedOperationHierarchical ⇒ Object
operation I own directly or indirectly via inheritance.
- #umlx_owner=(p) ⇒ Object
- #umlx_owner_one ⇒ Object
Instance Method Details
#umlx_assignableClassifier(ret = Set.new) ⇒ Object
returns every type assignable to this classifier (this includes self and any class deriving from it) Template parameter are filtered out
618 619 620 621 622 623 624 625 626 627 |
# File 'lib/ontomde-uml2/umlx.rb', line 618 def umlx_assignableClassifier(ret=Set.new) return ret if ret.include?(self) ret<< self uml_general_inv.each { |g| g.uml_generalization_inv.each {|c| next if c.umlx_isTemplateParameter? c.umlx_assignableClassifier(ret) }} return ret end |
#umlx_classifier_generalization_indirect(s = Set.new) ⇒ Object
Returns in a Set any class this class inherit froms, both directly and indirectly (trough other classes) Note: parameter is used internaly for recursion and should not be used.
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ontomde-uml2/uml2.rb', line 16 def umlx_classifier_generalization_indirect(s=Set.new) self.uml_generalization.each { |gene| gene.uml_general.each{ |c| recurse=!s.include?(c) # anti boucle infinie sur modele KO s.add(c) c.umlx_classifier_generalization_indirect(s) if recurse } } return s end |
#umlx_computeDirectDepencies(ret = Set.new) ⇒ Object
returns every class this elements depends on
6 7 8 9 10 11 |
# File 'lib/ontomde-uml2/depencies.rb', line 6 def umlx_computeDirectDepencies(ret=Set.new) (uml_ownedAttribute+uml_ownedOperation).each { |a| a.umlx_computeDirectDepencies(ret) } return ret end |
#umlx_createAndAddAssociation(new_uri, otherEnd) ⇒ Object
Creates and adds a new UML Association. Return the newly created association. new_uri should be globaly unique.
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
# File 'lib/ontomde-uml2/createAndAdd.rb', line 214 def umlx_createAndAddAssociation(new_uri,otherEnd) c1=self; c2=otherEnd a=Cuml_Association.new(rdf_Repository,new_uri) m1=Cuml_Property.new(rdf_Repository,"#{new_uri}_e1") m1.uml_type=c2 #m1.uml_class=c1 c1.uml_ownedAttribute_add(m1) m2=Cuml_Property.new(rdf_Repository,"#{new_uri}_e2") m2.uml_type=c1 #m2.uml_class=c1 #c2.uml_ownedAttribute_add(m2) [m1,m2].each { |m| a.uml_memberEnd_add(m) m.uml_association=a m.uml_isUnique=RDF_TRUE m.uml_isOrdered=RDF_FALSE m.uml_visibility=::Cuml_VisibilityKind::Public } return [a,m1,m2] end |
#umlx_createAndAddEnumeration(new_uri, new_name = nil) ⇒ Object
Creates and add a new UML Enumeration. Return the newly created element. new_uri should be globaly unique.
88 89 90 91 92 93 94 95 96 97 |
# File 'lib/ontomde-uml2/createAndAdd.rb', line 88 def umlx_createAndAddEnumeration(new_uri,new_name=nil) c=Cuml_Enumeration.new(rdf_Repository,new_uri) #uml_nestedClassifier_add(c) #puts "--------> #{self} #{new_name}" c.umlx_owner=self c.uml_name=new_name unless new_name.nil? c.uml_visibility=::Cuml_VisibilityKind::Public #puts "création classe #{new_name} in #{self.java_qualifiedName}" return c end |
#umlx_createAndAddOperation(new_uri, new_name = nil) ⇒ Object
Creates and adds a new UML Operation. Return the newly created element. new_uri should be globaly unique.
188 189 190 191 192 193 194 |
# File 'lib/ontomde-uml2/createAndAdd.rb', line 188 def umlx_createAndAddOperation(new_uri,new_name=nil) m=Cuml_Operation.new(rdf_Repository,new_uri) self.uml_ownedOperation_add(m) m.uml_name=new_name unless new_name.nil? m.uml_visibility=::Cuml_VisibilityKind::Public return m end |
#umlx_createAndAddProperty(new_uri, new_name = nil) ⇒ Object
Creates and adds a new UML property. Return the newly created element. new_uri should be globaly unique.
199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/ontomde-uml2/createAndAdd.rb', line 199 def umlx_createAndAddProperty(new_uri,new_name=nil) #log.debug { %{umlx_createAndAddProperty : name="#{new_name}" uri="#{uri}" owner="#{self}" owner_uri="#{self.rdf_uri}"} } m=Cuml_Property.new(rdf_Repository,new_uri) self.uml_ownedAttribute_add(m) m.uml_name=new_name unless new_name.nil? m.uml_isUnique=RDF_TRUE m.uml_isOrdered=RDF_FALSE m.uml_visibility=::Cuml_VisibilityKind::Public #m.uml_class=self return m end |
#umlx_getElementNamed(name) ⇒ Object
returns nil or element with the proper name in the current namespace
238 239 240 241 242 243 244 245 246 |
# File 'lib/ontomde-uml2/umlx.rb', line 238 def umlx_getElementNamed(name) uml_ownedAttribute.each { |om| return om if om.uml_name.to_s==name } uml_ownedOperation.each { |om| return om if om.uml_name.to_s==name } return super(name) end |
#umlx_hasRelation? ⇒ Boolean
returns true if this class directly carries associations, compositions or aggregations.
96 97 98 99 100 101 |
# File 'lib/ontomde-uml2/umlx.rb', line 96 def umlx_hasRelation? uml_ownedAttribute.each { |o| return true unless o.umlx_isAttribute? } return false end |
#umlx_isTemplateParameter? ⇒ Boolean
heuristique. If element has no owner, it is a root class class in root package is not supported anyway.
632 633 634 |
# File 'lib/ontomde-uml2/umlx.rb', line 632 def umlx_isTemplateParameter? return umlx_owner_one.nil? end |
#umlx_model ⇒ Object
Returns UML Model containing self.
296 297 298 299 300 301 302 303 304 305 306 |
# File 'lib/ontomde-uml2/umlx.rb', line 296 def umlx_model p=umlx_package return p.umlx_model unless p.nil? #(uml_nestedClassifier_inv).each { |o| # puts "o=#{o}" #} log.error { "umlx_model:no model found for #{self.class.name} #{self}" } return rdf_Repository.umlx_model end |
#umlx_ownedAndInheritedOperation(ret = Set.new) ⇒ Object
returns every type assignable to this classifier (this includes self and any class deriving from it)
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/ontomde-uml2/helper.rb', line 4 def umlx_ownedAndInheritedOperation(ret=Set.new) uml_ownedOperation.each {|biz| ret << biz } uml_generalization.each { |g| next if g.kind_of?(Muml_Interface) g.uml_general_one.umlx_ownedAndInheritedOperation(ret) } return ret end |
#umlx_ownedAttributeHierarchical ⇒ Object
attribute I own directly or indirectly via inheritance
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/ontomde-uml2/uml2.rb', line 42 def umlx_ownedAttributeHierarchical() ret=Set.new umlx_classifier_generalization_indirect.each { |i| i.uml_ownedAttribute.each { |oo| ret.add(oo) } } self.uml_ownedAttribute.each { |oo| ret.add(oo) } return ret end |
#umlx_ownedOperationHierarchical ⇒ Object
operation I own directly or indirectly via inheritance
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ontomde-uml2/uml2.rb', line 28 def umlx_ownedOperationHierarchical() ret=Set.new umlx_classifier_generalization_indirect.each { |i| i.uml_ownedOperation.each { |oo| ret.add(oo) } } self.uml_ownedOperation.each { |oo| ret.add(oo) } return ret end |
#umlx_owner=(p) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ontomde-uml2/owner.rb', line 26 def umlx_owner=(p) old=umlx_owner_one if old.nil? # elsif old.kind_of?(Muml_Package) old.uml_ownedMember.delete(self) else old.uml_nestedClassifier.delete(self) end if p.kind_of?(Muml_Package) p.uml_ownedMember_add(self) else p.uml_nestedClassifier_add(self) end ext_isReferencedBy_add(p) end |
#umlx_owner_one ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/ontomde-uml2/owner.rb', line 19 def umlx_owner_one #return uml_ownedMember_inv_one0 ext_isReferencedBy.each { |res| return res if res.respond_to?(:uml_ownedMember) && res.uml_ownedMember.include?(self) } return nil end |