Module: Muml_Operation

Defined in:
lib/ontomde-uml2/uml2.rb,
lib/ontomde-uml2/umlx.rb,
lib/ontomde-uml2/umlx.rb,
lib/ontomde-uml2/umlx.rb,
lib/ontomde-uml2/owner.rb,
lib/ontomde-uml2/depencies.rb,
lib/ontomde-uml2/kb/protege.rb,
lib/ontomde-uml2/createAndAdd.rb,
lib/ontomde-uml2/autoImplement.rb

Instance Method Summary collapse

Instance Method Details

#kb_writeComponentOperationObject



663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
# File 'lib/ontomde-uml2/kb/protege.rb', line 663

def kb_writeComponentOperation
  u="#{rdf_uri}_soaOp"
  write "<\#{u}> <\#{NS_RDF_2000}rdf-schema#label> \"\" .\n<\#{u}> <\#{NS_RDF_2000}rdf-schema#subClassOf> <\#{Mrdf_Repository::SERVICE_URI}> .\n<\#{u}> <\#{NS_RDF_2000}rdf-schema#comment> \"Definition for service  \#{uml_name}\" .\n<\#{u}> <\#{NS_RDF_1999}22-rdf-syntax-ns#type> <http://protege.stanford.edu/kb#UML_METACLASS> .    \n"
  
  (uml_ownedParameter+uml_returnResult).each { |p|
    up="#{p.rdf_uri}-soaMapping"
    write "<\#{up}> <\#{NS_RDF_1999}22-rdf-syntax-ns#type> <\#{NS_RDF_1999}22-rdf-syntax-ns#Property> .\n<\#{up}> <http://protege.stanford.edu/system#maxCardinality> \"1\" .\n<\#{up}> <\#{NS_RDF_2000}rdf-schema#label> \"param\#{p}\" .\n<\#{up}> <\#{NS_RDF_2000}rdf-schema#domain> <\#{u}> .\n<\#{up}> <\#{NS_RDF_2000}rdf-schema#range> <\#{Mrdf_Repository::DATAFILTER_URI}> .\n<\#{up}> <\#{NS_RDF_2000}rdf-schema#comment> \"service\" .      \n"
  }
  

end

#umlx_class_oneObject

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



540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
# File 'lib/ontomde-uml2/umlx.rb', line 540

def umlx_class_one
  return uml_ownedOperation_inv_one
  ##
  ##      ret=uml_class_one
  ##      #ret=uml_ownedAttribute_inv_one0
  ##      return ret unless ret.nil?
  ##
  ##      #use ext_isReferencedBy
  ##      ext_isReferencedBy.each { |o|
  ##        next unless o.respond_to?(:uml_ownedOperation)
  ##        o.uml_ownedOperation.each { |c|
  ##          return o if c==self
  ##          }
  ##        }
  ##      log.error("umlx_class_one not found in model for #{self}:#{self.class}")
  ##      return nil
end

#umlx_computeDirectDepencies(ret = Set.new) ⇒ Object

returns every class this elements depends on



16
17
18
19
20
21
# File 'lib/ontomde-uml2/depencies.rb', line 16

def umlx_computeDirectDepencies(ret=Set.new)
  (uml_returnResult+uml_ownedParameter).each { |a|
    a.umlx_computeDirectDepencies(ret)
  }
  return ret
end

#umlx_createAndAddParameter(new_uri, new_name = nil) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/ontomde-uml2/createAndAdd.rb', line 6

def umlx_createAndAddParameter(new_uri,new_name=nil)
  p=Cuml_Parameter.new(rdf_Repository,new_uri)
  uml_ownedParameter_add(p)
  p.uml_name=new_name unless new_name.nil?
  p.uml_isUnique=RDF_TRUE
  p.uml_isOrdered=RDF_FALSE
  p.uml_direction=Cuml_ParameterDirectionKind::In
  return p
end

#umlx_createAndAddReturnParameter(new_uri, new_name = "return") ⇒ Object

Create and add a return parameter.



18
19
20
21
22
23
24
25
26
# File 'lib/ontomde-uml2/createAndAdd.rb', line 18

def umlx_createAndAddReturnParameter(new_uri,new_name="return")
  p=Cuml_Parameter.new(rdf_Repository,new_uri)
  uml_ownedParameter_add(p)
  p.uml_name=new_name
  p.uml_isUnique=RDF_TRUE
  p.uml_isOrdered=RDF_FALSE
  p.uml_direction=Cuml_ParameterDirectionKind::Return
  return p
end

#umlx_isConstructor?Boolean

Returns true if operation is a constructor NOTE: RSM stereotype is “Create”, MagicDraw “create”

Returns:

  • (Boolean)


589
590
591
# File 'lib/ontomde-uml2/umlx.rb', line 589

def umlx_isConstructor?
  return umlx_hasStereotype?("Create")
end

#umlx_owner_oneObject

returns element owner if found, nil otherwise



36
37
38
39
40
41
42
43
44
45
# File 'lib/ontomde-uml2/owner.rb', line 36

def umlx_owner_one
  ext_isReferencedBy.each { |res|
    next unless res.kind_of?(Muml_Classifier)
    next if res.kind_of?(Muml_Association)
    next unless res.uml_ownedOperation.include?(self)
    return res
  }
  log.error("umlx_owner_one not found for #{self.class} #{self}")
  return nil
end

#umlx_returnResult_one0Object

retrieve operation return parameter if any (nil otherwise)



255
256
257
258
259
260
261
262
263
264
265
266
267
# File 'lib/ontomde-uml2/uml2.rb', line 255

def umlx_returnResult_one0
  fp=nil
  uml_returnResult.each { |p|
    #pour RSM (non conformite de l'export)
    next unless p.uml_direction_one.isReturn?
    fp=p
  }
  uml_ownedParameter.each { |p|
    next unless p.uml_direction_one.isReturn?
    fp=p
  }
  return fp
end

#umlx_signatureObject



177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/ontomde-uml2/autoImplement.rb', line 177

def umlx_signature
  #todo: take parameter into account
  r="#{uml_name}("
  sep=""
  uml_ownedParameter.each { |p|
    next if Cuml_ParameterDirectionKind::Return==p.uml_direction_one
    r="#{r}#{sep}#{p.umlx_signature}"
    sep=","
  }
  r="#{r})"
  return r
end