On Thu, May 06, 2010 at 11:07:12AM -0700, hansen wang wrote:
> 
>    I'm a new user for ruote,and i have to Integrate Ruote,Ruote-
> kit,Rails,I know there is a
> Ruote-on-rails sample.But now I want to know how can i use Ruote-kit
> in   Ruote-on-rails.

Hello,

Eric has been preparing a sample application, but it's still very early :

  http://github.com/threetee/ruote-rails-test

> eg:
>    I create a controller,model in the ruote-on-rails. but how to start
> with Ruote-kit.
>     1.how to register a participant?

It generally happens in config/initializers/ruote.rb

Here is a simple example :

---8<---
require 'ruote/couch'

RuoteKit.configure do |c|

  c.run_worker = true unless $RAKE_TASK

  uri = File.read(Rails.root.join('config', 'couch_url.txt')).strip
  uri = URI.parse(uri)

  c.set_storage(
    Ruote::Couch::CouchStorage,
    uri.host, uri.port,
    'couch_prefix' => "roma_#{Rails.env}", 'couch_timeout' => 60)

  c.register do
    catchall Ruote::StorageParticipant
  end
end
--->8---

This example show how the engine is configured and how a unique "catchall" 
participant is registered.

It uses ruote-couch as a storage, it's a bit "advanced", for a beginning, using 
the fs_storage is the best thing.

In another application, I have

---8<---
  c.register do

    participant(
      'create_audit', Capua::Participants::CreateAudit)
    participant(
      'un_suspend_annual_augit', Capua::Participants::SuspendAnnualAudit)

    catchall Ruote::StorageParticipant
  end
--->8---

Where the participants are located under lib/capua/participants/

---8<---
module Capua
module Participants

  # Creates an audit resource for a given project
  #
  class CreateAudit
    include Ruote::LocalParticipant

    def initialize (opts)
      @opts = opts
    end

    def consume (workitem)
      puts "hello #{workitem.fields['name']}, creating an audit..."
      reply_to_engine(workitem)
    end
  end
end
end
--->8---

>     2.how to understand and use  Ruote::StorageParticipant in the
> rails app.

The code of the storage participant is at :

  
http://github.com/jmettraux/ruote/blob/ruote2.1/lib/ruote/part/storage_participant.rb

The interesting methods are :

  - all ()
  - [] / fetch (fei)
  - reply (workitem)
  - size
  - by_participant (name)
  - by_field (field, value=nil)
  - update (workitem)

You can grab the storage participant from your controller with :

---8<---
  RuoteKit.storage_participant

  # for example :
  @workitems = RuoteKit.storage_participant.all
--->8---

The update methods saves back a workitem into the storage participant, the 
reply method removes it from the participant and gives it back to the engine so 
that the process instance resumes.

>     3.Is there somebody could give me a detail code sample.

I hope these "hints" are sufficient for now.

Your questions are welcome.


Best regards,

-- 
John Mettraux - http://jmettraux.wordpress.com

-- 
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