Class: OpenWFE::LaunchItem

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

Overview

LaunchItem instances are used to instantiate and launch processes. They contain attributes that are used as the initial payload of the workitem circulating in the process instances.

Constant Summary collapse

DEF =
"__definition"
FIELD_DEF =
"field:#{DEF}"

Instance Attribute Summary collapse

Attributes inherited from WorkItem

#attributes, #last_modified

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from WorkItem

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

Constructor Details

#initialize(process_definition = nil) ⇒ LaunchItem

This constructor will build an empty LaunchItem.

If the optional parameter process_definition is set, the definition will be embedded in the launchitem attributes for retrieval by the engine.

There are several ways to specify the process definition. Here are some examples:

# Use a Ruby class that extends OpenWFE::ProcessDefinition
LaunchItem.new(MyProcessDefinition)

# Provide an XML process definition as a string
definition = """
  <process-definition name="x" revision="y">
    <sequence>
      <participant ref="alpha" />
      <participant ref="bravo" />
    </sequence>
  </process-definition>
""".strip
LaunchItem.new(definition)

# Load an XML process definition from a local file
require 'uri'
LaunchItem.new(URI.parse("file:///tmp/my_process_definition.xml"))

# If you initialized your engine with 
# {:remote_definitions_allowed => true}, then you can also load an
# XML process definition from a remote url
require 'uri'
LaunchItem.new(URI.parse("http://foo.bar/my_process_definition.xml"))


441
442
443
444
445
446
447
448
449
# File 'lib/openwfe/workitem.rb', line 441

def initialize (process_definition=nil)

    super()

    if process_definition
        @workflow_definition_url = FIELD_DEF
        @attributes[DEF] = process_definition
    end
end

Dynamic Method Handling

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

Instance Attribute Details

#workflow_definition_urlObject Also known as: wfdurl

Returns the value of attribute workflow_definition_url.



401
402
403
# File 'lib/openwfe/workitem.rb', line 401

def workflow_definition_url
  @workflow_definition_url
end

Class Method Details

.from_h(h) ⇒ Object



462
463
464
465
466
467
# File 'lib/openwfe/workitem.rb', line 462

def LaunchItem.from_h (h)

    li = super
    li.workflow_definition_url = h[:workflow_definition_url]
    li
end

Instance Method Details

#to_hObject

Turns the LaunchItem instance into a simple ‘hash’ (easily serializable to other formats).



455
456
457
458
459
460
# File 'lib/openwfe/workitem.rb', line 455

def to_h

    h = super
    h[:workflow_definition_url] = @workflow_definition_url
    h
end