Class: OpenWFE::Worklist
- Inherits:
-
Object
- Object
- OpenWFE::Worklist
- Includes:
- LocalParticipant
- Defined in:
- lib/openwfe/worklist/worklist.rb
Overview
An OpenWFEja-style worklist.
Instance Attribute Summary collapse
-
#stores ⇒ Object
readonly
Returns the value of attribute stores.
Attributes included from Contextual
Instance Method Summary collapse
-
#add_store(regex, store_name, store) ⇒ Object
For now, just a shortcut for .
-
#authenticate(user, pass) ⇒ Object
A simple call to the authentify method of the @auth_system passed a initialization time.
- #consume(workitem) ⇒ Object
- #delegate(user, from_store_name, to_store_name) ⇒ Object
-
#each_store(&block) ⇒ Object
Iterates over each of the stores in this worklist.
- #forward(user, store_name, workitem) ⇒ Object
- #get(user, store_name, fei) ⇒ Object
- #get_and_lock(user, store_name, fei) ⇒ Object
-
#get_headers(user, store_name, limit) ⇒ Object
Well, this implementation just returns workitems.
-
#get_permissions(user, store_name) ⇒ Object
Returns a string like “rwd” or “rw” or even “”.
-
#get_store(store_name) ⇒ Object
Returns the store instance with the given name.
-
#initialize(application_context, params) ⇒ Worklist
constructor
Builds a new worklist.
-
#launch_flow(engine_name, launch_item) ⇒ Object
Not really the job of a worklist, but it was in OpenWFEja, so here it is…
- #list_workitems(user, store_name, workflow_instance_id = nil) ⇒ Object
-
#lookup_store(store_name) ⇒ Object
Returns the first store whose regex matches the given store_name.
- #release(user, store_name, wi_or_fei) ⇒ Object
- #save(user, store_name, workitem) ⇒ Object
Methods included from LocalParticipant
#call_block, #get_flow_expression, #reply_to_engine
Methods included from Contextual
#get_work_directory, #init_service, #lookup
Methods included from Logging
#ldebug, #ldebug_callstack, #lerror, #lfatal, #linfo, #llog, #lunknown, #lwarn
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
Constructor Details
#initialize(application_context, params) ⇒ Worklist
Builds a new worklist.
Parameters are :
-
:auth_system : something with an authenticate(user, pass) and an optional authorised?(user, store, action) methods.
-
:launchables : an array of URLs : launchables, in this basic implementation, all users share the same list
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/openwfe/worklist/worklist.rb', line 64 def initialize (application_context, params) @application_context = application_context as = params[:auth_system] @auth_system = if as == nil DefaultAuthSystem.new elsif as.kind_of?(Hash) DefaultAuthSystem.new(as) else as end @stores = [] end |
Instance Attribute Details
#stores ⇒ Object (readonly)
Returns the value of attribute stores.
52 53 54 |
# File 'lib/openwfe/worklist/worklist.rb', line 52 def stores @stores end |
Instance Method Details
#add_store(regex, store_name, store) ⇒ Object
For now, just a shortcut for
@stores << [ regex, store_name, store]
121 122 123 124 125 126 127 |
# File 'lib/openwfe/worklist/worklist.rb', line 121 def add_store (regex, store_name, store) @stores << [ regex, store_name, store] store.application_context = @application_context \ if store.respond_to?(:application_context=) end |
#authenticate(user, pass) ⇒ Object
A simple call to the authentify method of the @auth_system passed a initialization time.
98 99 100 |
# File 'lib/openwfe/worklist/worklist.rb', line 98 def authenticate (user, pass) @auth_system.authenticate(user, pass) end |
#consume(workitem) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/openwfe/worklist/worklist.rb', line 81 def consume (workitem) pname = workitem.participant_name each_store do |regex, store_name, store| next unless pname.match regex store.consume workitem break end end |
#delegate(user, from_store_name, to_store_name) ⇒ Object
178 179 180 181 182 |
# File 'lib/openwfe/worklist/worklist.rb', line 178 def delegate (user, from_store_name, to_store_name) (user, from_store_name, :write) (user, to_store_name, :write) # TODO : continue me end |
#each_store(&block) ⇒ Object
Iterates over each of the stores in this worklist.
187 188 189 190 191 192 193 194 195 |
# File 'lib/openwfe/worklist/worklist.rb', line 187 def each_store (&block) # :yields: regex, store_name, store return unless block @stores.each do |v| regex, store_name, store = v block.call regex, store_name, store end end |
#forward(user, store_name, workitem) ⇒ Object
169 170 171 172 |
# File 'lib/openwfe/worklist/worklist.rb', line 169 def forward (user, store_name, workitem) (user, store_name, :write) get_store(store_name).forward(user, workitem) end |
#get(user, store_name, fei) ⇒ Object
146 147 148 149 |
# File 'lib/openwfe/worklist/worklist.rb', line 146 def get (user, store_name, fei) (user, store_name, :read) get_store(store_name).get(fei) end |
#get_and_lock(user, store_name, fei) ⇒ Object
150 151 152 153 |
# File 'lib/openwfe/worklist/worklist.rb', line 150 def get_and_lock (user, store_name, fei) (user, store_name, :write) get_store(store_name).get_and_lock(user, fei) end |
#get_headers(user, store_name, limit) ⇒ Object
Well, this implementation just returns workitems
132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/openwfe/worklist/worklist.rb', line 132 def get_headers (user, store_name, limit) (user, store_name, :read) l = [] get_store(store_name).each do |workitem, locked| break if limit and l.size >= limit l << [ workitem, locked ] end l end |
#get_permissions(user, store_name) ⇒ Object
Returns a string like “rwd” or “rw” or even “”.
Read / Write / Delegate
107 108 109 110 111 112 113 114 |
# File 'lib/openwfe/worklist/worklist.rb', line 107 def (user, store_name) s = "" [ :read, :write, :delegate ].each do |action| s << action.to_s[0, 1] \ if @auth_system.(user, store_name, action) end s end |
#get_store(store_name) ⇒ Object
Returns the store instance with the given name.
211 212 213 214 215 216 |
# File 'lib/openwfe/worklist/worklist.rb', line 211 def get_store (store_name) each_store do |regex, s_name, store| return store if s_name == store_name end nil end |
#launch_flow(engine_name, launch_item) ⇒ Object
Not really the job of a worklist, but it was in OpenWFEja, so here it is…
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
# File 'lib/openwfe/worklist/worklist.rb', line 222 def launch_flow (engine_name, launch_item) e = lookup_engine engine_name raise "couldn't find engine named '#{engine_name}'" unless e if e.is_a? OpenWFE::Engine e.launch launch_item elsif e.is_a? OpenWFE::Participant e.consume launch_item else raise \ "cannot launch a flow via something of "+ "class #{e.class.name}" end end |
#list_workitems(user, store_name, workflow_instance_id = nil) ⇒ Object
173 174 175 176 |
# File 'lib/openwfe/worklist/worklist.rb', line 173 def list_workitems (user, store_name, workflow_instance_id=nil) (user, store_name, :read) get_store(store_name).list_workitems(workflow_instance_id) end |
#lookup_store(store_name) ⇒ Object
Returns the first store whose regex matches the given store_name.
201 202 203 204 205 206 |
# File 'lib/openwfe/worklist/worklist.rb', line 201 def lookup_store (store_name) each_store do |regex, name, store| return store if regex.match store_name end nil end |
#release(user, store_name, wi_or_fei) ⇒ Object
155 156 157 158 159 160 161 162 163 |
# File 'lib/openwfe/worklist/worklist.rb', line 155 def release (user, store_name, wi_or_fei) (user, store_name, :write) fei = wi_or_fei fei = fei.fei if fei.respond_to?(:fei) get_store(store_name).release(user, fei) end |
#save(user, store_name, workitem) ⇒ Object
165 166 167 168 |
# File 'lib/openwfe/worklist/worklist.rb', line 165 def save (user, store_name, workitem) (user, store_name, :write) get_store(store_name).save(user, workitem) end |