Class: OpenWFE::InFlowWorkItem

Inherits:
InFlowItem show all
Defined in:
lib/openwfe/workitem.rb

Overview

When the term ‘workitem’ is used it’s generally referring to instances of this InFlowWorkItem class. InFlowWorkItem are circulating within process instances and carrying data around. Their ‘payload’ is located in their attribute Hash field.

Direct Known Subclasses

Header

Instance Attribute Summary collapse

Attributes inherited from InFlowItem

#flow_expression_id, #participant_name

Attributes inherited from WorkItem

#attributes, #last_modified

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from InFlowItem

#last_expression_id, #last_expression_id=

Methods inherited from WorkItem

#[], #[]=, #dup, #has_attribute?, #initialize, #lookup_attribute, #method_missing, #set_attribute, #touch, #unset_attribute

Constructor Details

This class inherits a constructor from OpenWFE::WorkItem

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class OpenWFE::WorkItem

Instance Attribute Details

#dispatch_timeObject

Returns the value of attribute dispatch_time.



286
287
288
# File 'lib/openwfe/workitem.rb', line 286

def dispatch_time
  @dispatch_time
end

#filterObject

Returns the value of attribute filter.



286
287
288
# File 'lib/openwfe/workitem.rb', line 286

def filter
  @filter
end

#historyObject

Returns the value of attribute history.



286
287
288
# File 'lib/openwfe/workitem.rb', line 286

def history
  @history
end

#storeObject

Returns the value of attribute store.



288
289
290
# File 'lib/openwfe/workitem.rb', line 288

def store
  @store
end

Class Method Details

.from_h(h) ⇒ Object

Rebuilds an InFlowWorkItem from its hash version.



330
331
332
333
334
335
336
337
# File 'lib/openwfe/workitem.rb', line 330

def InFlowWorkItem.from_h (h)

    wi = super
    wi.dispatch_time = h[:dispatch_time]
    wi.history = h[:history]
    wi.filter = h[:filter]
    wi
end

Instance Method Details

#get_boolean_resultObject

Returns true or false.



368
369
370
371
372
373
# File 'lib/openwfe/workitem.rb', line 368

def get_boolean_result

    r = get_result
    return false unless r
    (r == true or r == "true")
end

#get_resultObject

Just a shortcut (for consistency) of

workitem.attributes["__result__"]


360
361
362
363
# File 'lib/openwfe/workitem.rb', line 360

def get_result

    @attributes[FIELD_RESULT]
end

#set_result(result) ⇒ Object

Sets the ‘__result__’ field of this workitem



342
343
344
345
# File 'lib/openwfe/workitem.rb', line 342

def set_result (result)

    @attributes[FIELD_RESULT] = result
end

#to_hObject

For some easy YAML encoding, turns the workitem into a Hash (Any YAML-enabled platform can thus read it).



318
319
320
321
322
323
324
325
# File 'lib/openwfe/workitem.rb', line 318

def to_h

    h = super
    h[:dispatch_time] = @dispatch_time
    h[:history] = @history
    h[:filter] = @filter
    h
end

#to_sObject

Outputting the workitem in a human readable format



295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
# File 'lib/openwfe/workitem.rb', line 295

def to_s

    s = ""
    s << "  #{self.class} :\n"
    s << "  - flow_expression_id : #{@flow_expression_id}\n"
    s << "  - participant_name :   #{@participant_name}\n"
    s << "  - last_modified :      #{@last_modified}\n"
    s << "  - dispatch_time :      #{@dispatch_time}\n"
    s << "  - attributes :\n"

    s << "    {\n"
    @attributes.keys.sort.each do |k|
        v = @attributes[k]
    s << "      #{k.inspect} => #{v.inspect},\n"
    end
    s << "    }"
    s
end

#unset_resultObject

Makes sure the ‘__result__’ field of this workitem is empty.



350
351
352
353
# File 'lib/openwfe/workitem.rb', line 350

def unset_result

    @attributes.delete FIELD_RESULT
end