lib/openwfe/worklist/storeparticipant.rb in openwferu-0.9.4 vs lib/openwfe/worklist/storeparticipant.rb in openwferu-0.9.5
- old
+ new
@@ -36,10 +36,11 @@
# "made in Japan"
#
# John Mettraux at openwfe.org
#
+require 'openwfe/utils'
require 'openwfe/storage/yamlfilestorage'
require 'openwfe/participants/participant'
module OpenWFE
@@ -130,11 +131,11 @@
self.each_value do |workitem|
result << workitem \
if (not workflow_instance_id) or workitem.fei.parent_wfid == workflow_instance_id
end
- result
+ return result
end
end
#
# The simplest workitem store possible, gathers the workitem in a
@@ -145,16 +146,44 @@
# that's all...
end
#
- # TODO : finish me
+ # Implementation of a store participant stores the workitems in
+ # yaml file in a dedicated directory.
#
class YamlParticipant < YamlFileStorage
include StoreParticipantMixin
- def initialize
- workpath = application_context[:work_directory] + "/participants"
- super(service_name, application_context, workpath)
+ attr_accessor :dirname
+
+ #
+ # The constructor for YamlParticipant awaits a dirname and an
+ # application_context.
+ # The dirname should be a simple name acceptable as a filename.
+ #
+ def initialize (dirname, application_context)
+
+ @dirname = OpenWFE::ensure_for_filename(dirname.to_s)
+
+ service_name = @self.class.name + "__" + @dirname
+
+ path =
+ application_context[:work_directory] +
+ "/participants/" +
+ @dirname
+
+ super(service_name, application_context, path)
end
+
+ protected
+
+ def compute_file_path (fei)
+
+ @basepath +
+ fei.workflow_instance_id + "__" +
+ fei.workflow_definition_name + "_" +
+ fei.workflow_definition_revision + "__" +
+ fei.expression_id + ".yaml"
+ end
end
end