Module: Mbpm_process

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

Instance Method Summary collapse

Instance Method Details

#bpm_addPingNode!Object

pingTest node is a node added to ping the process for testing purposses and deployement test purposes



132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/ontomde-uml2-jpdl/main.rb', line 132

def bpm_addPingNode!
  return unless context[:bpm_addPingNode,true]
  s=bpm_getOrCreateStartNode
  e=bpm_getOrCreateEndNode
  d=bpm_createAndAddSynchronousDecisionNode("_pingMode")
  t=s.bpm_leavingTransition_one

  #insert node d between s and first node after s
  d.bpm_addTransition!("productionMode",t.bpm_destinationNode_one)
  d.bpm_addTransition!("testMode",e)
  t.bpm_destinationNode=d
end

#bpm_createAndAddSynchronousDecisionNode(name) ⇒ Object

create



146
147
148
149
150
151
# File 'lib/ontomde-uml2-jpdl/main.rb', line 146

def bpm_createAndAddSynchronousDecisionNode(name)
  ret=Cbpm_synchronousDecisionNode.new(self.rdf_model,"#{self.rdf_uri}_#{name}")
  ret.bpm_nodeName=name
  self.bpm_processNode_add(ret)
  return ret
end

#bpm_getOrCreateEndNodeObject

returns process start node creates one if necessary



166
167
168
169
170
171
172
173
174
# File 'lib/ontomde-uml2-jpdl/main.rb', line 166

def bpm_getOrCreateEndNode
  bpm_processNode.each {|n|
    return n if n.kind_of?(Mbpm_endNode)
  }
  ret=Cbpm_startNode.new(self.rdf_model,"#{self.rdf_uri}_endNode")
  ret.bpm_nodeName="endNode"
  self.bpm_processNode_add(ret)
  return ret
end

#bpm_getOrCreateStartNodeObject

returns process start node creates one if necessary



155
156
157
158
159
160
161
162
163
# File 'lib/ontomde-uml2-jpdl/main.rb', line 155

def bpm_getOrCreateStartNode
  bpm_processNode.each {|n|
    return n if n.kind_of?(Mbpm_startNode)
  }
  ret=Cbpm_startNode.new(self.rdf_model,"#{self.rdf_uri}_startNode")
  ret.bpm_nodeName="startNode"
  self.bpm_processNode_add(ret)
  return ret
end

#bpm_getProcessClass(muml) ⇒ Object



65
66
67
68
69
70
71
72
73
74
# File 'lib/ontomde-uml2-jpdl/main.rb', line 65

def bpm_getProcessClass(muml)
  bpmClass = BPM::BpmClass
  bpmClass += "<#{self.bpm_processReturnTypeOrNullReturn}>"
  ret=muml.umlx_getOrCreateClass(bpmClass)
  ret.java_isGeneric=RDF_TRUE
  #ret.db_isTransient=RDF_FALSE
  ret.db_isTransient=RDF_FALSE
  puts "ProcessClass = #{bpmClass}"
  return ret
end

#bpm_graphGen_dotObject



176
177
178
179
180
181
182
183
184
# File 'lib/ontomde-uml2-jpdl/main.rb', line 176

def bpm_graphGen_dot
  mtk_writeSession("bpm.dot") {
    write("digraph {\n")
    bpm_processNode.each {|n|
      n.bpm_graphGen_dot
    }
    write ("} // end of file\n")
  }
end

#bpm_processReturnTypeOrNullReturnObject



149
150
151
152
153
154
# File 'lib/ontomde-uml2-jpdl/jpdl.rb', line 149

def bpm_processReturnTypeOrNullReturn
  if self.bpm_processReturnType_one0.nil?
    return BPM::NullReturn
  end
  return self.bpm_processReturnType
end

#bpm_qualifiedNameObject

returns a qualified name for this process (return processName itself because processName is supposed to be a qualifiedName)



61
62
63
# File 'lib/ontomde-uml2-jpdl/main.rb', line 61

def bpm_qualifiedName
  return bpm_processName.to_s
end

#bpm_transform!Object



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
# File 'lib/ontomde-uml2-jpdl/main.rb', line 76

def bpm_transform!
  mrdf=context[:umlModel,self.rdf_model]
  muml=mrdf.umlx_reserved_model
  j=mrdf.java_getClassWithQualifiedName(bpm_qualifiedName)
  j=muml.umlx_getOrCreateClass("#{bpm_qualifiedName}",::Muml_Namespace::UMLX_SEARCH_EVERY_MODEL) if j.nil?
  #TODO Gérer la récupération dans la signature de la méthode du type et la génération de deux méthodes
  #Evite la génération de l'ID
  j.extend(Muml_ClassProcess);
  j.db_isTransient=RDF_FALSE
  self.bpm_javaProcessJobsClass=j # store direct reference
  j.umlx_external="false"

  j.umlx_createAndAddGeneralization( bpm_getProcessClass(muml))


  bpm_processNode.each {|n|
    next if n.kind_of?(Mbpm_passive_Node)
    if n.kind_of?(Mbpm_source_Node)
      n.bpm_createEnumerationForTransitions!(j)
    end
    #n.bpm_createConnectorForNodeAction!
    n.bpm_addJavaProcessOperation(j)
  }

  m=j.umlx_createAndAddOperation("#{j.rdf_uri}_processDefinition","getProcessDefinition")
  m.java_annotation_add("@Override")
  p=m.umlx_createAndAddReturnParameter("#{j.rdf_uri}_ret","return")
  p.uml_type=j.umlx_dataType_string
  m.java_code=%{return ""\n#{mtk_stss{bpm_writeJPDL}.gsub(/"/,'\\"').gsub(/^(.*)$/,'     +"\1"')};}

  # external process name
  m=j.umlx_createAndAddOperation("#{j.rdf_uri}_externalProcessName","getExternalProcessName")
  p=m.umlx_createAndAddReturnParameter("#{j.rdf_uri}_ret","return")
  p.uml_type=j.umlx_dataType_string
  m.java_code=%{return "#{bpm_qualifiedName}";}


  me=j.umlx_createAndAddOperation("#{j.rdf_uri}_onEnd","xmdaOnEnd")
  me.java_annotation_add("@Override")
  p=me.umlx_createAndAddReturnParameter("#{me.rdf_uri}_ret","return")

  p.uml_type=j.umlx_getOrCreateClass("#{bpm_processReturnTypeOrNullReturn}")
  me.java_code=%{return null;}

  #    p.uml_type=j.umlx_getOrCreateClass("java.lang.Class")

  # external process id
  # moved to base class
  #p=j.umlx_createAndAddProperty("#{j.rdf_uri}_externalBPMid","BpmExternalId")
  #m.uml_type=j.umlx_dataType_long

end

#bpm_writeJPDLObject

write element as XML JPDL



139
140
141
142
143
144
145
146
147
148
# File 'lib/ontomde-uml2-jpdl/jpdl.rb', line 139

def bpm_writeJPDL
  mtk_default_context( :bpm_rawJPDL => true) {
    write(%{<?xml version="1.0" encoding="UTF-8"?>\n})
    write(%{<process-definition\n    xmlns="urn:jbpm.org:jpdl-3.2"\n    name="#{self.bpm_processName}">\n})
    bpm_processNode.each {|n|
      n.bpm_writeJPDL
    }
    write(%{</process-definition>\n})
  }
end