lib/openwfe/expressions/fe_subprocess.rb in openwferu-0.9.5 vs lib/openwfe/expressions/fe_subprocess.rb in openwferu-0.9.6
- old
+ new
@@ -37,10 +37,13 @@
# "made in Japan"
#
# John Mettraux at openwfe.org
#
+#require 'uri'
+
+require 'openwfe/utils'
require 'openwfe/expressions/fe_utils'
#
# the subprocess expression
@@ -63,50 +66,80 @@
# <print>${a}${b}${c}</print>
# </process-definition>
#
# </process-definition>
#
+ # It's totally OK to have URLs as referenced processes :
+ #
+ # require 'openwfe/def'
+ #
+ # class AnotherDefinition0 < OpenWFE::ProcessDefinition
+ # def make
+ # sequence do
+ # participant ref => "toto"
+ # subprocess ref => "http://company.process.server/def0.rb"
+ # end
+ # end
+ # end
+ #
class SubProcessRefExpression < FlowExpression
#
# apply / reply
def apply (workitem)
ref = OpenWFE::lookup_ref(self, workitem)
- raise "'subprocess' expression misses a 'ref', 'field-ref' or 'variable-ref' attribute" if not ref
+ raise "'subprocess' expression misses a 'ref', 'field-ref' or 'variable-ref' attribute" unless ref
- template_fei = lookup_variable(ref)
+ template_uri = parse_uri(ref)
+ template = if template_uri
+ template_uri
+ else
+ lookup_variable(ref)
+ end
+
#template_fei = lookup_participant(ref) if not template_fei
raise "did not find any subprocess named '#{ref}'" \
- if not template_fei
+ if not template
forget = lookup_boolean_attribute(:forget, workitem)
requester = @fei
requester = @fei.workflowInstanceId if forget
params = lookup_attributes(workitem)
- #puts " ... params are #{params.to_s}"
+ text = OpenWFE::fetch_text_content(self, workitem, false)
+ params["0"] = text if text
+ #puts " ... params are #{params.keys.join(', ')}"
+
get_expression_pool()\
- .launch_template(requester, 0, template_fei, workitem, params)
+ .launch_template(requester, 0, template, workitem, params)
end
#def reply (workitem)
#end
- #protected
- # def lookup_participant (ref)
- # participant = get_participant_map.lookup_participant(ref)
- # return nil unless participant
- # #
- # # builds a participant expression on the fly
- # end
+ protected
+
+ def parse_uri (ref)
+
+ uri = OpenWFE::parse_uri(ref)
+
+ return nil unless uri
+
+ return uri if uri.scheme == "http"
+ return uri if uri.scheme == "https"
+ return uri if uri.scheme == "ftp"
+ # what else ...
+
+ return nil
+ end
end
end