| Class | OpenWFE::Worklist |
| In: |
lib/openwfe/worklist/worklist.rb
|
| Parent: | Object |
An OpenWFEja-style worklist.
| stores | [R] |
Builds a new worklist.
Parameters are :
# File lib/openwfe/worklist/worklist.rb, line 64
64: def initialize (application_context, params)
65:
66: @application_context = application_context
67:
68: as = params[:auth_system]
69:
70: @auth_system = if as == nil
71: DefaultAuthSystem.new
72: elsif as.kind_of?(Hash)
73: DefaultAuthSystem.new(as)
74: else
75: as
76: end
77:
78: @stores = []
79: end
For now, just a shortcut for
@stores << [ regex, store_name, store]
# File lib/openwfe/worklist/worklist.rb, line 121
121: def add_store (regex, store_name, store)
122:
123: @stores << [ regex, store_name, store]
124:
125: store.application_context = @application_context \
126: if store.respond_to?(:application_context=)
127: end
A simple call to the authentify method of the @auth_system passed a initialization time.
# File lib/openwfe/worklist/worklist.rb, line 98
98: def authenticate (user, pass)
99: @auth_system.authenticate(user, pass)
100: end
# File lib/openwfe/worklist/worklist.rb, line 81
81: def consume (workitem)
82:
83: pname = workitem.participant_name
84:
85: each_store do |regex, store_name, store|
86:
87: next unless pname.match regex
88:
89: store.consume workitem
90: break
91: end
92: end
# File lib/openwfe/worklist/worklist.rb, line 178
178: def delegate (user, from_store_name, to_store_name)
179: authorized?(user, from_store_name, :write)
180: authorized?(user, to_store_name, :write)
181: # TODO : continue me
182: end
Iterates over each of the stores in this worklist.
# File lib/openwfe/worklist/worklist.rb, line 187
187: def each_store (&block) # :yields: regex, store_name, store
188:
189: return unless block
190:
191: @stores.each do |v|
192: regex, store_name, store = v
193: block.call regex, store_name, store
194: end
195: end
# File lib/openwfe/worklist/worklist.rb, line 169
169: def forward (user, store_name, workitem)
170: authorized?(user, store_name, :write)
171: get_store(store_name).forward(user, workitem)
172: end
# File lib/openwfe/worklist/worklist.rb, line 146
146: def get (user, store_name, fei)
147: authorized?(user, store_name, :read)
148: get_store(store_name).get(fei)
149: end
# File lib/openwfe/worklist/worklist.rb, line 150
150: def get_and_lock (user, store_name, fei)
151: authorized?(user, store_name, :write)
152: get_store(store_name).get_and_lock(user, fei)
153: end
Well, this implementation just returns workitems
# File lib/openwfe/worklist/worklist.rb, line 132
132: def get_headers (user, store_name, limit)
133:
134: authorized?(user, store_name, :read)
135:
136: l = []
137:
138: get_store(store_name).each do |workitem, locked|
139: break if limit and l.size >= limit
140: l << [ workitem, locked ]
141: end
142:
143: l
144: end
Returns a string like "rwd" or "rw" or even "".
Read / Write / Delegate
# File lib/openwfe/worklist/worklist.rb, line 107
107: def get_permissions (user, store_name)
108: s = ""
109: [ :read, :write, :delegate ].each do |action|
110: s << action.to_s[0, 1] \
111: if @auth_system.authorized?(user, store_name, action)
112: end
113: s
114: end
Returns the store instance with the given name.
# File lib/openwfe/worklist/worklist.rb, line 211
211: def get_store (store_name)
212: each_store do |regex, s_name, store|
213: return store if s_name == store_name
214: end
215: nil
216: end
Not really the job of a worklist, but it was in OpenWFEja, so here it is…
# File lib/openwfe/worklist/worklist.rb, line 222
222: def launch_flow (engine_name, launch_item)
223:
224: e = lookup_engine engine_name
225:
226: raise "couldn't find engine named '#{engine_name}'" unless e
227:
228: if e.is_a? OpenWFE::Engine
229:
230: e.launch launch_item
231:
232: elsif e.is_a? OpenWFE::Participant
233:
234: e.consume launch_item
235:
236: else
237: raise \
238: "cannot launch a flow via something of "+
239: "class #{e.class.name}"
240: end
241: end
# File lib/openwfe/worklist/worklist.rb, line 173
173: def list_workitems (user, store_name, workflow_instance_id=nil)
174: authorized?(user, store_name, :read)
175: get_store(store_name).list_workitems(workflow_instance_id)
176: end
Returns the first store whose regex matches the given store_name.
# File lib/openwfe/worklist/worklist.rb, line 201
201: def lookup_store (store_name)
202: each_store do |regex, name, store|
203: return store if regex.match store_name
204: end
205: nil
206: end
# File lib/openwfe/worklist/worklist.rb, line 155
155: def release (user, store_name, wi_or_fei)
156:
157: authorized?(user, store_name, :write)
158:
159: fei = wi_or_fei
160: fei = fei.fei if fei.respond_to?(:fei)
161:
162: get_store(store_name).release(user, fei)
163: end
# File lib/openwfe/worklist/worklist.rb, line 165
165: def save (user, store_name, workitem)
166: authorized?(user, store_name, :write)
167: get_store(store_name).save(user, workitem)
168: end
# File lib/openwfe/worklist/worklist.rb, line 260
260: def authorized? (user, store_name, action)
261:
262: return true unless @auth_system.respond_to?(:authorized?)
263:
264: unless @auth_system.authorized?(user, store_name, action)
265: raise \
266: "'#{user}' is not authorized " +
267: "to '#{action}' on store '#{store_name}'"
268: end
269:
270: true
271: end
This method is called when a launch_flow request is coming, it will lookup in the participant map to find the way (the Participant implementation) to deliver the launch_item to the engine.
If there is no engine with that name, the default (local) engine is returned (and will thus be used to launch the flow).
# File lib/openwfe/worklist/worklist.rb, line 254
254: def lookup_engine (engine_name)
255: e = get_participant_map.lookup_participant engine_name
256: return e if e
257: get_engine
258: end