On Mon, Oct 03, 2011 at 06:18:26PM -0700, catalina cordoba wrote:
>
> I'm newbie and I don't knwo if a I can manipulate workitems inside the
> process definition.

Hello and welcome,

yes, you can, it's usually done via

  http://ruote.rubyforge.org/exp/set.html
  http://ruote.rubyforge.org/exp/restore.html

But most of the time you want to limit workitem manipulation to participants 
and only decide on which route to take within the process definition by reading 
workitem fields.


> What I exactly need to do is to get data from a workitem and then
> parse it with REXML to use the data as XML.
>
> Can I do that within the process definition?

you could but that would seriously diminish the process definition readability.

What about (https://gist.github.com/1260723) ?

---8<---
require 'rexml/document'
require 'pp'
require 'rubygems'
require 'ruote'

engine = Ruote::Engine.new(Ruote::Worker.new(Ruote::HashStorage.new()))

class FetchData
  include Ruote::LocalParticipant

  def consume(workitem)

    workitem.fields['xml'] = %{
<?xml version='1.0?>
<car color="blue"><constructor name="nissan"/></car>
    }.strip

    reply_to_engine(workitem)
  end

  def cancel(fei, flavour)
    # nothing to do
  end
end

class ProcessData
  include Ruote::LocalParticipant

  def consume(workitem)

    xml = REXML::Document.new(workitem.fields['xml'])
    constructor = REXML::XPath.first(xml, '//constructor')
    workitem.fields['constructor'] = constructor.attribute('name').value

    pp workitem.fields

    reply_to_engine(workitem)
  end

  def cancel(fei, flavour)
    # nothing to do
  end
end

engine.register 'fetch_data', FetchData
engine.register 'process_data', ProcessData

pdef = Ruote.define do
  fetch_data
  process_data
end

engine.noisy = true

wfid = engine.launch(pdef)
r = engine.wait_for(wfid)
--->8---

All the XML details are in the participant and the process definition just does 
the participant orchestration work, as should be.

Also, please remember that in an ideal world, participants are reusable among 
process definitions.


Best regards,

--
John Mettraux - http://lambda.io/processi

-- 
you received this message because you are subscribed to the "ruote users" group.
to post : send email to [email protected]
to unsubscribe : send email to [email protected]
more options : http://groups.google.com/group/openwferu-users?hl=en

Reply via email to