Class: OpenWFE::YamlFileExpressionStorage
- Inherits:
-
YamlFileStorage
- Object
- YamlFileStorage
- OpenWFE::YamlFileExpressionStorage
- Includes:
- ExpressionStorageBase, OwfeServiceLocator
- Defined in:
- lib/openwfe/expool/yamlexpstorage.rb
Overview
YAML expression storage. Expressions (atomic pieces of process instances) are stored in a hierarchy of YAML files.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from YamlFileStorage
Attributes included from ServiceMixin
Attributes included from Contextual
Class Method Summary collapse
-
.split_file_path(path) ⇒ Object
Returns nil (if the path doesn’t match an stored expression path) or an array [ workflow_instance_id, expression_id, expression_name ].
Instance Method Summary collapse
- #fetch_root(wfid) ⇒ Object
-
#find_expressions(options) ⇒ Object
Find expressions matching various criteria.
-
#initialize(service_name, application_context) ⇒ YamlFileExpressionStorage
constructor
A new instance of YamlFileExpressionStorage.
-
#to_s ⇒ Object
Returns a human-readable list of the current YAML file paths.
Methods included from ExpressionStorageBase
#class_accepted?, #does_match?, #observe_expool
Methods included from OwfeServiceLocator
#get_engine, #get_error_journal, #get_expool, #get_expression_map, #get_expression_pool, #get_expression_storage, #get_expression_storages, #get_journal, #get_participant_map, #get_scheduler, #get_wfid_generator
Methods inherited from YamlFileStorage
#[], #[]=, #delete, #has_key?, #length, #purge
Methods included from ServiceMixin
Methods included from Contextual
#get_work_directory, #init_service, #lookup
Methods included from Logging
#ldebug, #ldebug_callstack, #lerror, #lfatal, #linfo, #llog, #lunknown, #lwarn
Constructor Details
#initialize(service_name, application_context) ⇒ YamlFileExpressionStorage
Returns a new instance of YamlFileExpressionStorage.
66 67 68 69 70 71 |
# File 'lib/openwfe/expool/yamlexpstorage.rb', line 66 def initialize (service_name, application_context) super service_name, application_context, '/expool' observe_expool end |
Class Method Details
.split_file_path(path) ⇒ Object
Returns nil (if the path doesn’t match an stored expression path) or an array [ workflow_instance_id, expression_id, expression_name ].
This is a class method (not an instance one).
160 161 162 163 164 165 |
# File 'lib/openwfe/expool/yamlexpstorage.rb', line 160 def self.split_file_path (path) md = path.match %r{.*/(.*)__([\d.]*)_(.*).yaml} return nil unless md [ md[1], md[2], md[3] ] end |
Instance Method Details
#fetch_root(wfid) ⇒ Object
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 135 136 |
# File 'lib/openwfe/expool/yamlexpstorage.rb', line 109 def fetch_root (wfid) fei = FlowExpressionId.new fei.wfid = wfid fei.expid = "0" fei.expression_name = "process-definition" root = self[fei] return root if root # # direct hit missed, scanning... each_object_path(compute_dir_path(wfid)) do |p| a = self.class.split_file_path p next unless a next unless a[0] == wfid fexp = load_object p return fexp if fexp.is_a?(DefineExpression) end nil end |
#find_expressions(options) ⇒ Object
Find expressions matching various criteria. (See Engine#list_process_status for an explanation)
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 |
# File 'lib/openwfe/expool/yamlexpstorage.rb', line 77 def find_expressions () wfid_prefix = [:wfid_prefix] wfid_regex = nil wfid_regex = Regexp.new("^"+wfid_prefix) if wfid_prefix .delete :wfid_prefix # no need to check this in further does_match? calls result = [] each_object_path do |path| unless path.match /\/engine_environment.yaml$/ a = self.class.split_file_path path next unless a # not an expression file wfid = a[0] next if wfid_regex and (not wfid_regex.match(wfid)) end fexp = load_object path next unless does_match?(, fexp) result << fexp end result end |
#to_s ⇒ Object
Returns a human-readable list of the current YAML file paths. (one expression per path).
142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/openwfe/expool/yamlexpstorage.rb', line 142 def to_s s = "\n\n==== #{self.class} ====" s << "\n" each_object_path do |path| s << path s << "\n" end s << "==== . ====\n" s end |