Module: Mrdf_Model

Defined in:
lib/ontomde-uml2-jpdl/jpdl.rb,
lib/ontomde-uml2-jpdl/main.rb,
lib/ontomde-uml2-jpdl/graphic.rb,
lib/ontomde-uml2-jpdl/jpdl_deploy.rb

Constant Summary collapse

BPM_JPDL_DEPLOY_CLASS =
"xmda.jpdl.Deploy"

Instance Method Summary collapse

Instance Method Details

#bpm_addPingNode!Object

adds ping node to all process in model (feature used for process deployement test)



33
34
35
36
37
# File 'lib/ontomde-uml2-jpdl/main.rb', line 33

def bpm_addPingNode!
  bpm_allProcess.each { |c|
    c.bpm_addPingNode!
  }
end

#bpm_allProcess(ret = Array.new) ⇒ Object



39
40
41
42
43
44
# File 'lib/ontomde-uml2-jpdl/main.rb', line 39

def bpm_allProcess(ret=Array.new)
  self.each { |k,c|
    ret<< c if c.kind_of?(Mbpm_process)
  }
  return ret
end

#bpm_dumpJPDLObject



4
5
6
7
8
9
# File 'lib/ontomde-uml2-jpdl/jpdl.rb', line 4

def bpm_dumpJPDL
  bpm_allProcess.each { |c|
    puts ""
    puts "#{mtk_stss{c.bpm_writeJPDL}}"
  }
end

#bpm_genJPDLDeployObject

Generates a JPDL deployer as a JUNIT class Junit provides easy diagnostic an a convenient GUI



8
9
10
11
# File 'lib/ontomde-uml2-jpdl/jpdl_deploy.rb', line 8

def bpm_genJPDLDeploy
  bpm_allProcess.each { |c|
  }
end

#bpm_graphGen_dotObject



2
3
4
5
6
# File 'lib/ontomde-uml2-jpdl/graphic.rb', line 2

def bpm_graphGen_dot
  bpm_allProcess { |res|
    res.bpm_graphGen_dot
  }
end

#bpm_loadBPMObject



14
15
16
# File 'lib/ontomde-uml2-jpdl/main.rb', line 14

def bpm_loadBPM
  loadMetaModelFromFile("#{File.dirname(__FILE__)}/bpm.rdfs",true)
end

#bpm_loadJPDL(fileNameJPDL) ⇒ Object

Load a BPM from a JPDL XML file



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/ontomde-uml2-jpdl/jpdl.rb', line 16

def bpm_loadJPDL(fileNameJPDL)
  nameHash=Hash.new
  file = File.new( fileNameJPDL)
  doc = REXML::Document.new file
  i=0
  pname=doc.elements["/process-definition"].attribute("name").to_s
  #puts "pname=#{pname}"

  if (pname.nil? || pname=="")
    log.error { %{Error detected
********* PROCESS WITHOUT NAME ****************
This software has detected that process stored
in file #{fileNameJPDL} has a blank name.
********* PROCESS WITHOUT NAME ****************
      }}

    exit 1
  end


  pr=Cbpm_process.new(self,"#{pname}_#{i}")
  #Le nom du process peut contenir le type de retour du process
  pnames = pname.split('|')
  pr.bpm_processName=pnames[0]
  puts "Process Name #{pr.bpm_processName}"
  if pnames.length > 1
    pr.bpm_processReturnType = pnames[1]
  end

  doc.elements.each("/process-definition/*") { |elt|
    # t is the XML node name() which is the type of the node
    nodeType=elt.elements["name()"].to_s
    i=i+1 ; obj=nil
    name=elt.attribute("name").to_s
    node_uri="node_#{pname}_#{name}"

    if (name.nil? || name=="")
      log.error { %{Error detected
********* PROCESS WITHOUT NAME ****************
This software has detected that process stored
in file #{fileNameJPDL} has a blank name.
********* PROCESS WITHOUT NAME ****************
        }}

      exit 1
    end
    if nodeType==Cbpm_forkNode::BPM_JPDL_TYPE_NAME
      obj=Cbpm_forkNode.new(self,node_uri)
    elsif nodeType==Cbpm_joinNode::BPM_JPDL_TYPE_NAME
      obj=Cbpm_joinNode.new(self,node_uri)
    elsif nodeType==Cbpm_endNode::BPM_JPDL_TYPE_NAME
      obj=Cbpm_endNode.new(self,node_uri)
    elsif nodeType==Cbpm_startNode::BPM_JPDL_TYPE_NAME
      obj=Cbpm_startNode.new(self,node_uri)
    elsif nodeType==Cbpm_synchronousDecisionNode::BPM_JPDL_TYPE_NAME
      obj=Cbpm_synchronousDecisionNode.new(self,node_uri)
    elsif nodeType==Cbpm_synchronousNode::BPM_JPDL_TYPE_NAME
      obj=Cbpm_synchronousNode.new(self,node_uri)
    elsif nodeType==Cbpm_asynchronousNode::BPM_JPDL_TYPE_NAME
      obj=Cbpm_asynchronousNode.new(self,node_uri)
      #elsif #TODO: asynchronous decision node
    else
      throw Exception.new("unknown jpdl node type '#{nodeType}' for process #{pr.bpm_processName} in file #{fileNameJPDL}")
    end

    # this node is part of pr process
    pr.bpm_processNode_add(obj)

    if obj.kind_of?(Mbpm_named_Node)
      obj.bpm_nodeName=name
    end
    nameHash[name]=obj
  }

  timerHash=Hash.new

  doc.elements.each("//timer") { |elt|
    from=nameHash[elt.elements[".."].attribute("name").to_s]
    #Le nom du timer est en fait le nom de la transition de sortie du timer
    puts "Timer found:#{elt} "
    name=elt.attribute("transition")

    tr=Cbpm_timeOutTransition.new(self,"tr_#{pname}_#{name}")
    tr.bpm_transitionName=name.to_s
    from.bpm_leavingTransition_add(tr)

    #Gestion du temps
    jpdlDuration = "#{elt.attribute("duration")}"
    jpdlSplit = jpdlDuration.split(" ")
    tr.bpm_timeOutDuration=jpdlSplit[0]
    tr.bpm_timeOutUnit=jpdlSplit[jpdlSplit.length - 1]
    tr.bpm_timeOutIsBusinessDuration=RDF_FALSE
    jpdlSplit.each { |element|
      if "business"==element
        tr.bpm_timeOutIsBusinessDuration=RDF_TRUE
        break
      end
    }

    timerHash["#{name}"]=tr
  }

  doc.elements.each("//transition") { |elt|
    from=nameHash[elt.elements[".."].attribute("name").to_s]
    to=nameHash[elt.attribute("to").to_s]
    name=elt.attribute("name")

    #On regarde si la transition porte le m�me nom que la transition du timer
    tr = timerHash["#{name}"]
    if tr.nil?
      # Ce n'est pas une transition de timer
      tr=Cbpm_transition.new(self,"tr_#{pname}_#{name}")
      tr.bpm_transitionName=name.to_s
      from.bpm_leavingTransition_add(tr)
    end
    #On rajoute dans tous les cas le noeud de sortie
    tr.bpm_destinationNode=to
  }
end

#bpm_transform!Object



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ontomde-uml2-jpdl/main.rb', line 17

def bpm_transform!
  #mtk_writeSession("bpm.log") {
  s=Array.new
  each { |k,res|
    next unless res.kind_of?(Mbpm_process)
    s << res
  }
  s.each { |res|
    res.bpm_transform!
  }
  #bpm_dumpJPDL
  bpm_genJPDLDeploy
end

#java_getClassWithQualifiedName(qname) ⇒ Object



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

def java_getClassWithQualifiedName(qname)
  uml_Class_all.each { |f|
    return f if f.java_qualifiedName.to_s.casecmp(qname)==0
  }
  puts "not found #{qname}"
  #exit 1
  return nil
end