Module: Muml_Property
- Defined in:
- lib/ontomde-uml2/uml2.rb,
lib/ontomde-uml2/umlx.rb,
lib/ontomde-uml2/umlx.rb,
lib/ontomde-uml2/owner.rb,
lib/ontomde-uml2/dotDiagram.rb,
lib/ontomde-uml2/kb/protege.rb,
lib/ontomde-uml2/cardinality.rb
Instance Method Summary collapse
-
#prot_writeNTriple ⇒ Object
writes this property as RDF triples.
- #prot_writeNTriple_association ⇒ Object
-
#prot_writeNTriple_common ⇒ Object
writes property elements common to association and attribute as RDF triples.
-
#umlx_class_one ⇒ Object
uml_ownedAttribute_inv_one is sometime broken (RSM does not consistently populate this field) umlx_class_one figures out the correct value of uml_ownedAttribute_inv_one.
-
#umlx_classDiagram_dotFragment ⇒ Object
Generate dot graphical instruction for this element.
-
#umlx_copyToAttributeProperty(oa) ⇒ Object
copy elements to the attribute property in Muml_Classifier module.
-
#umlx_exactlyOneSide? ⇒ Boolean
Is this property such an extremity of an SQL mapping ? (lowerValue==1 && upperValue==1).
-
#umlx_isAssociation? ⇒ Boolean
returns true if this property is part of an association.
-
#umlx_isAttribute? ⇒ Boolean
returns true if this property is not part of an association.
-
#umlx_isComposite? ⇒ Boolean
returns true if this property is part of composite association.
-
#umlx_isNavigable? ⇒ Boolean
returns true if property is navigable.
-
#umlx_isShared? ⇒ Boolean
returns true if this property is part of an shared association.
-
#umlx_manySide? ⇒ Boolean
Is this property such an extremity of an SQL mapping ?.
-
#umlx_manyToMany? ⇒ Boolean
Should this SQL mapping used for this association ?.
-
#umlx_manyToOne? ⇒ Boolean
Should this SQL mapping used for this association ?.
-
#umlx_masterEnd? ⇒ Boolean
Is this property such an extremity of an SQL mapping ?.
-
#umlx_oneSide? ⇒ Boolean
Is this property such an extremity of an SQL mapping ? (lowerValue<=1 && upperValue==1).
-
#umlx_oneToMany? ⇒ Boolean
Should this SQL mapping used for this association ?.
-
#umlx_oneToOne? ⇒ Boolean
Should this SQL mapping used for this association ?.
-
#umlx_otherEnd ⇒ Object
Returns the other end of the association this property is linked to.
-
#umlx_owner_one(donotlog = false) ⇒ Object
returns element owner if found, nil otherwise.
- #umlx_unidirectionnel? ⇒ Boolean
Instance Method Details
#prot_writeNTriple ⇒ Object
writes this property as RDF triples
313 314 315 316 317 318 319 320 321 322 323 324 325 |
# File 'lib/ontomde-uml2/kb/protege.rb', line 313 def prot_writeNTriple # against infinite loop return unless @kb_exported.nil? @kb_exported=true if (uml_association.length==0) prot_writeNTriple_common #prot_writeNTriple_attribute else prot_writeNTriple_common prot_writeNTriple_association end end |
#prot_writeNTriple_association ⇒ Object
382 383 384 385 386 |
# File 'lib/ontomde-uml2/kb/protege.rb', line 382 def prot_writeNTriple_association write("<#{prot_uri}> <http://protege.stanford.edu/system#inverseProperty> <#{umlx_otherEnd.prot_uri}> .\n"); # make sure other end is exported when it is not navigable. umlx_otherEnd.prot_writeNTriple unless umlx_otherEnd.umlx_isNavigable? end |
#prot_writeNTriple_common ⇒ Object
writes property elements common to association and attribute as RDF triples
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 374 375 376 377 378 379 380 |
# File 'lib/ontomde-uml2/kb/protege.rb', line 328 def prot_writeNTriple_common o=self e=o.umlx_class_one #e=o.uml_ownedAttribute_inv #e=uml_class_one if e.nil? if e.nil? #log.debug "null!!!!" return end write("<#{o.prot_uri}> <#{NS_RDF_2000}rdf-schema#domain> <#{e.prot_uri}> .\n"); append_comment t=o.uml_type_one if t.kind_of?(Cuml_Enumeration) write("<#{o.prot_uri}> <#{NS_RDF_2000}rdf-schema#range> <#{NS_RDF_2000}rdf-schema#Literal> .\n") write(%{<#{o.prot_uri}> <http://protege.stanford.edu/system#range> "symbol" .\n}) t.uml_ownedLiteral.each {|c| write(%{<#{o.prot_uri}> <http://protege.stanford.edu/system#allowedValues> "#{c}" .\n}) } elsif (t.kind_of?(Muml_PrimitiveType)||t.kind_of?(Muml_DataType)) write("<#{o.prot_uri}> <#{NS_RDF_2000}rdf-schema#range> <#{t.prot_uri}> .\n") write(%{<#{o.prot_uri}> <http://protege.stanford.edu/system#range> "#{t.prot_primitive_type}" .\n}) else write("<#{o.prot_uri}> <#{NS_RDF_2000}rdf-schema#range> <#{t.prot_uri}> .\n") end write("<#{o.prot_uri}> <#{NS_RDF_1999}22-rdf-syntax-ns#type> <http://protege.stanford.edu/kb#UML_SLOT> .\n") write("<#{o.prot_uri}> <http://protege.stanford.edu/kb#UML_LABEL> \"#{o.prot_label}\".\n") write("<#{o.prot_uri}> <#{NS_UML_CLASS}#UML_URI> \"#{UriNamespace.instance.unalias(o.rdf_uri)}\" .\n") write("<#{o.prot_uri}> <#{RDF_LABEL_URI}> \"#{o.uml_name.to_s.nt_escape}\" .\n") cardUp=umlx_upperValueIsOne? ? "1" : "*" cardLow=umlx_lowerValueIsZero? ? "0" : "1" if ! uml_qualifier.empty? #qualifiers changes cardinality semantics cardLow="0" cardUp="*" end ##if isComposition # log.debug "est une composition" # cardLow="1" #end if cardLow!="0" write("<#{o.prot_uri}> <http://protege.stanford.edu/system#minCardinality> \"#{cardLow}\" .\n") end if cardUp!="-1" write("<#{o.prot_uri}> <http://protege.stanford.edu/system#maxCardinality> \"#{cardUp}\" .\n") end end |
#umlx_class_one ⇒ Object
uml_ownedAttribute_inv_one is sometime broken (RSM does not consistently populate this field) umlx_class_one figures out the correct value of uml_ownedAttribute_inv_one
581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 |
# File 'lib/ontomde-uml2/umlx.rb', line 581 def umlx_class_one # return uml_ownedAttribute_inv_one #ret=uml_ownedAttribute_inv_one0 ret=uml_class_one0 return ret unless ret.nil? #use association other end oe=umlx_otherEnd ret=oe.uml_type_one if !oe.nil? return ret unless ret.nil? #use ext_isReferencedBy ext_isReferencedBy.each { |o| next unless o.respond_to?(:uml_ownedAttribute) o.uml_ownedAttribute.each { |c| return o if c==self } } log.error("umlx_class_one not found in model for #{self}:#{self.class}") return nil end |
#umlx_classDiagram_dotFragment ⇒ Object
Generate dot graphical instruction for this element.
108 109 110 111 112 113 114 |
# File 'lib/ontomde-uml2/dotDiagram.rb', line 108 def umlx_classDiagram_dotFragment return if umlx_isAttribute? o=uml_class_one c=uml_type_one write(%{#{c.dotId} [label="#{c.uml_name}"]\n}) write(%{#{o.dotId}->#{c.dotId} [arrowtail=none,arrowhead=vee,minlen=2,label="#{uml_name}"]\n}) end |
#umlx_copyToAttributeProperty(oa) ⇒ Object
copy elements to the attribute property in Muml_Classifier module
71 72 73 74 75 76 77 |
# File 'lib/ontomde-uml2/umlx.rb', line 71 def umlx_copyToAttributeProperty(oa) oa.uml_upperValue=self.uml_upperValue oa.uml_lowerValue=self.uml_lowerValue oa.uml_type=self.uml_type oa.uml_isOrdered=self.uml_isOrdered oa.uml_isUnique=self.uml_isUnique end |
#umlx_exactlyOneSide? ⇒ Boolean
Is this property such an extremity of an SQL mapping ? (lowerValue==1 && upperValue==1)
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ontomde-uml2/cardinality.rb', line 32 def umlx_exactlyOneSide? assoc = uml_association_one0 return false if assoc.nil? lowerValue = self.uml_lowerValue_one0 return false if lowerValue.nil? return false if lowerValue.umlx_to_i != 1 upperValue = self.uml_upperValue_one0 if !upperValue.nil? return false if upperValue.umlx_to_i!=1 end return true end |
#umlx_isAssociation? ⇒ Boolean
returns true if this property is part of an association.
57 58 59 |
# File 'lib/ontomde-uml2/umlx.rb', line 57 def umlx_isAssociation? return (!umlx_isAttribute?) && (!uml_aggregation_one0.nil?) && (uml_aggregation_one.isNone?) end |
#umlx_isAttribute? ⇒ Boolean
returns true if this property is not part of an association. An attribute whose type is a class is considered an association.
50 51 52 53 54 |
# File 'lib/ontomde-uml2/umlx.rb', line 50 def umlx_isAttribute? t=uml_type_one ret=(uml_association.to_s.empty?) && (t.kind_of?(Muml_DataType)||t.kind_of?(Muml_Enumeration)) return ret end |
#umlx_isComposite? ⇒ Boolean
returns true if this property is part of composite association
66 67 68 |
# File 'lib/ontomde-uml2/umlx.rb', line 66 def umlx_isComposite? return (!umlx_isAttribute?) && (!uml_aggregation_one0.nil?) && (uml_aggregation_one.isComposite?) end |
#umlx_isNavigable? ⇒ Boolean
returns true if property is navigable
42 43 44 45 46 |
# File 'lib/ontomde-uml2/umlx.rb', line 42 def umlx_isNavigable? o=umlx_owner_one(true) return false if o.nil? return o.uml_ownedAttribute.include?(self) end |
#umlx_isShared? ⇒ Boolean
returns true if this property is part of an shared association.
62 63 64 |
# File 'lib/ontomde-uml2/umlx.rb', line 62 def umlx_isShared? return (!umlx_isAttribute?) && (uml_aggregation_one.isShared?) end |
#umlx_manySide? ⇒ Boolean
Is this property such an extremity of an SQL mapping ?
91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/ontomde-uml2/cardinality.rb', line 91 def umlx_manySide? #assoc = uml_association_one0 #return false if assoc.nil? lowerValue = uml_lowerValue_one0 if !lowerValue.nil? return true if lowerValue.umlx_to_i>1 || lowerValue.umlx_to_i==-1 end upperValue = uml_upperValue_one0 if !upperValue.nil? return true if upperValue.umlx_to_i>1 || upperValue.umlx_to_i==-1 end return false end |
#umlx_manyToMany? ⇒ Boolean
Should this SQL mapping used for this association ?
62 63 64 65 66 67 68 69 |
# File 'lib/ontomde-uml2/cardinality.rb', line 62 def umlx_manyToMany? assoc = uml_association_one0 return false if assoc.nil? return false if !umlx_manySide? otherEnd = umlx_otherEnd return false if otherEnd.nil? return otherEnd.umlx_manySide? end |
#umlx_manyToOne? ⇒ Boolean
Should this SQL mapping used for this association ?
82 83 84 85 86 87 88 |
# File 'lib/ontomde-uml2/cardinality.rb', line 82 def umlx_manyToOne? assoc = uml_association_one0 return false if assoc.nil? otherEnd = umlx_otherEnd return false if otherEnd.nil? return otherEnd.umlx_oneToMany? end |
#umlx_masterEnd? ⇒ Boolean
Is this property such an extremity of an SQL mapping ?
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/ontomde-uml2/cardinality.rb', line 112 def umlx_masterEnd? assoc = uml_association_one0 #return false if assoc.nil? #return false if assoc.uml_memberEnd.empty? || assoc.uml_memberEnd.size==1 #return self==assoc.uml_memberEnd.first oe=umlx_otherEnd return true if oe.nil? return true if umlx_isNavigable? && !oe.umlx_isNavigable? return false if (!umlx_isNavigable?) && oe.umlx_isNavigable? #Bidirectionnal association. #First member is arbitrarily chosen as master. return self==assoc.uml_memberEnd.first end |
#umlx_oneSide? ⇒ Boolean
Is this property such an extremity of an SQL mapping ? (lowerValue<=1 && upperValue==1)
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/ontomde-uml2/cardinality.rb', line 47 def umlx_oneSide? #assoc = uml_association_one #return false if assoc.nil? lowerValue = self.uml_lowerValue_one0 if !lowerValue.nil? return false if lowerValue.umlx_to_i>1 end upperValue = self.uml_upperValue_one0 if !upperValue.nil? return false if upperValue.umlx_to_i!=1 end return true end |
#umlx_oneToMany? ⇒ Boolean
Should this SQL mapping used for this association ?
72 73 74 75 76 77 78 79 |
# File 'lib/ontomde-uml2/cardinality.rb', line 72 def umlx_oneToMany? assoc = uml_association_one0 return false if assoc.nil? return false if !umlx_manySide? otherEnd = umlx_otherEnd return false if otherEnd.nil? return otherEnd.umlx_oneSide? end |
#umlx_oneToOne? ⇒ Boolean
Should this SQL mapping used for this association ?
22 23 24 25 26 27 28 |
# File 'lib/ontomde-uml2/cardinality.rb', line 22 def umlx_oneToOne? return false if uml_association_one0.nil? return false if !umlx_oneSide? otherEnd = umlx_otherEnd return false if otherEnd.nil? return otherEnd.umlx_oneSide? end |
#umlx_otherEnd ⇒ Object
Returns the other end of the association this property is linked to. NOTES:
Returns nil if this class is not part of an association
Returns nil if other en is not navigable.
192 193 194 195 196 197 198 199 |
# File 'lib/ontomde-uml2/uml2.rb', line 192 def umlx_otherEnd self.uml_association.each { |ass| ass.uml_memberEnd.each { |p| return p if p!=self } } return nil end |
#umlx_owner_one(donotlog = false) ⇒ Object
returns element owner if found, nil otherwise
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/ontomde-uml2/owner.rb', line 60 def umlx_owner_one(donotlog=false) ext_isReferencedBy.each { |res| next unless res.kind_of?(Muml_Classifier) next if res.kind_of?(Muml_Association) next unless res.uml_ownedAttribute.include?(self) return res } log.error("umlx_owner_one not found for #{self.class} #{self}") unless donotlog return nil end |
#umlx_unidirectionnel? ⇒ Boolean
104 105 106 107 108 109 |
# File 'lib/ontomde-uml2/cardinality.rb', line 104 def umlx_unidirectionnel? return umlx_otherEnd.nil? #assoc = uml_association_one0 #return false if assoc.nil? #return !assoc.uml_ownedEnd.empty? end |