<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>.gitignore</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -176,7 +176,7 @@ class ProcessesController &lt; ApplicationController
         return OpenWFE::Xml::launchitem_from_xml(request.body.read) \
           if ct.match(/xml$/)
 
-        return OpenWFE::Json.launchitem_from_json(request.body.read) \
+        return OpenWFE::Json.launchitem_from_h(request.body.read) \
           if ct.match(/json$/)
 
         #
@@ -196,6 +196,7 @@ class ProcessesController &lt; ApplicationController
       rescue Exception =&gt; e
 
         logger.warn &quot;failed to parse launchitem : #{e}&quot;
+        #p e
 
         nil
       end</diff>
      <filename>app/controllers/processes_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -40,19 +40,24 @@ class WorkitemsController &lt; ApplicationController
 
   # GET /workitems
   #  or
-  # GET /workitems?wfid=:wfid
+  # GET /workitems?q=:q || GET /workitems?query=:q
   #  or
-  # GET /workitems?q=:q || GET /workitems?query=:query
+  # GET /workitems?p=:p || GET /workitems?participant=:p
+  #
+  # handles as well index_wfid()
   #
   def index
 
     @wfid = params[:wfid]
     @query = params[:q] || params[:query]
+    @participant = params[:p] || params[:participant]
 
-    @workitems = if @wfid
-      OpenWFE::Extras::Workitem.find_all_by_wfid(@wfid)
+    @workitems = if @participant
+      OpenWFE::Extras::Workitem.find_all_by_participant_name(@participant)
     elsif @query
       OpenWFE::Extras::Workitem.search(@query)
+    elsif @wfid
+      OpenWFE::Extras::Workitem.find_all_by_wfid(@wfdi)
     else
       OpenWFE::Extras::Workitem.find(:all)
     end
@@ -74,20 +79,27 @@ class WorkitemsController &lt; ApplicationController
     end
   end
 
-  # GET /workitems/:id/edit
+  # GET /workitems/:wfid
+  #
+  def index_wfid
+
+    index
+  end
+
+  # GET /workitems/:wfid/:expid/edit
   #
   def edit
 
-    @workitem = OpenWFE::Extras::Workitem.find(params[:id])
+    @workitem = find_workitem
 
     # only responds in HTML...
   end
 
-  # GET /workitems/:id
+  # GET /workitems/:wfid/:expid
   #
   def show
 
-    @workitem = OpenWFE::Extras::Workitem.find(params[:id])
+    @workitem = find_workitem
 
     respond_to do |format|
       format.html # =&gt; app/views/show.html.erb
@@ -98,11 +110,11 @@ class WorkitemsController &lt; ApplicationController
     end
   end
 
-  # PUT /workitems/:id
+  # PUT /workitems/:wfid/:expid
   #
   def update
 
-    wi = OpenWFE::Extras::Workitem.find(params[:id])
+    wi = find_workitem
     owi = wi.to_owfe_workitem
 
     wi1 = parse_workitem
@@ -141,6 +153,17 @@ class WorkitemsController &lt; ApplicationController
     end
 
     #
+    # assumes params :wfid and :expid are set and returns the corresponding
+    # workitem
+    #
+    def find_workitem
+
+      wfid = params[:wfid]
+      expid = params[:expid]
+      OpenWFE::Extras::Workitem.find_by_wfid_and_expid(wfid, expid)
+    end
+
+    #
     # parsing incoming workitems
     #
     def parse_workitem
@@ -177,7 +200,7 @@ class WorkitemsController &lt; ApplicationController
 
       rescue Exception =&gt; e
 
-        logger.warn &quot;failed to parse workitem : #{e}&quot;
+        logger.warn(&quot;failed to parse workitem : #{e}&quot;)
 
         nil
       end</diff>
      <filename>app/controllers/workitems_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -46,6 +46,7 @@ module ApplicationHelper
   end
 
   def comma_list (objects, accessor=:name)
+
     objects.collect { |o|
       name = o.send(accessor)
       path = send &quot;#{o.class.to_s.downcase}_path&quot;, o
@@ -53,13 +54,24 @@ module ApplicationHelper
     }.join(', ')
   end
 
+  #
+  # given a view, returns the link to the same view in another content type
+  # (xml / json)
+  #
   def as_x_href (format)
+
     href = [
       :protocol, :host, ':', :port,
       #:script_name
       :path_info, &quot;.#{format}?plain=true&quot;
     ].inject('') do |s, elt|
-      s &lt;&lt; (elt.is_a?(String) ? elt : request.send(elt).to_s)
+      s &lt;&lt; if elt.is_a?(String)
+        elt
+      elsif request.respond_to?(elt)
+        request.send(elt).to_s
+      else # shouldn't happen, so let's be verbose
+        elt.inspect
+      end
     end
     href &lt;&lt; &quot;&amp;#{request.query_string}&quot; if request.query_string.length &gt; 0
     href</diff>
      <filename>app/helpers/application_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -53,8 +53,7 @@ ActionController::Routing::Routes.draw do |map|
   # Note: These default routes make all actions in every controller accessible via GET requests. You should
   # consider removing the them or commenting them out if you're using named routes and resources.
 
-  map.resources :workitems
-
+  map.wfid_resources :workitems
   map.wfid_resources :expressions
 
   map.resources :definitions</diff>
      <filename>config/routes.rb</filename>
    </modified>
    <modified>
      <diff>@@ -31,7 +31,6 @@ ActiveRecord::Schema.define(:version =&gt; 20080926082146) do
   add_index &quot;fields&quot;, [&quot;fkey&quot;], :name =&gt; &quot;index_fields_on_fkey&quot;
   add_index &quot;fields&quot;, [&quot;svalue&quot;], :name =&gt; &quot;index_fields_on_svalue&quot;
   add_index &quot;fields&quot;, [&quot;vclass&quot;], :name =&gt; &quot;index_fields_on_vclass&quot;
-  add_index &quot;fields&quot;, [&quot;workitem_id&quot;, &quot;fkey&quot;], :name =&gt; &quot;index_fields_on_workitem_id_and_fkey&quot;, :unique =&gt; true
 
   create_table &quot;group_definitions&quot;, :force =&gt; true do |t|
     t.integer  &quot;group_id&quot;</diff>
      <filename>db/schema.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,6 +3,7 @@ one:
   id: 1
   fei: (fei 0.9.20 s_engine /Users/mettraux/ruote-web2/public/defs/truck_sell_0.rb TruckSell 0 20081003-gajoyususo participant 0.6.0)
   wfid: 20081003-gajoyususo
+  expid: 0.0.1
   wf_name: test
   wf_revision: 0
   participant_name: alpha</diff>
      <filename>test/fixtures/workitems.yml</filename>
    </modified>
    <modified>
      <diff>@@ -31,8 +31,18 @@ class ProcessesControllerTest &lt; ActionController::TestCase
     @request.env['HTTP_ACCEPT'] = 'application/xml'
     get :index
     assert_response :success
+    #puts @response.body
     assert_match(/href=&quot;http:\/\/test.host:80\/processes&quot;/, @response.body)
     assert_match(/count=&quot;0&quot;/, @response.body)
+    assert_equal(
+      %{
+&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
+&lt;processes count=&quot;0&quot;&gt;
+  &lt;link href=&quot;http://test.host:80/&quot; rel=&quot;via&quot;/&gt;
+  &lt;link href=&quot;http://test.host:80/processes&quot; rel=&quot;self&quot;/&gt;
+&lt;/processes&gt;
+      }.strip,
+      @response.body.strip)
   end
 
   def test_empty_process_list_json
@@ -40,7 +50,7 @@ class ProcessesControllerTest &lt; ActionController::TestCase
     @request.env['HTTP_ACCEPT'] = 'application/json'
     get :index
     assert_response :success
-    assert_equal '[]', @response.body
+    assert_equal '{&quot;elements&quot;: []}', @response.body
   end
 
   def test_launch_process_form</diff>
      <filename>test/functional/processes_controller_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -14,7 +14,7 @@ end
 class WorkitemsControllerTest &lt; ActionController::TestCase
 
   fixtures :users, :groups
-  fixtures :workitems
+  #fixtures :workitems
 
   def test_should_not_get_index
     get :index
@@ -29,13 +29,17 @@ class WorkitemsControllerTest &lt; ActionController::TestCase
 
   def test_should_show_workitem
     login_as :admin
-    get :show, :id =&gt; 1
+    get :show, :wfid =&gt; '20081003-gajoyususo', :expid =&gt; '0.0.1'
     assert_response :success
   end
 
   def test_should_save_workitem
     login_as :admin
-    put :update, { 'id' =&gt; 1, 'fields' =&gt; '{ &quot;type&quot;: &quot;petit bateau&quot; }' }
+    put(
+      :update,
+      { :wfid =&gt; '20081003-gajoyususo',
+        :expid =&gt; '0.0.1',
+        :fields =&gt; '{ &quot;type&quot;: &quot;petit bateau&quot; }' })
     assert_response 302
     assert_equal 'http://test.host/workitems', @response.headers['Location']
     wi = OpenWFE::Extras::Workitem.find(1).as_owfe_workitem
@@ -58,18 +62,38 @@ class WorkitemsControllerTest &lt; ActionController::TestCase
 
     workitems = ActiveSupport::JSON.decode(@response.body)
 
-    wi = workitems.find { |wi|
+    wi = workitems['elements'].find { |wi|
       wi['flow_expression_id']['workflow_instance_id'] == fei.wfid }
 
-    assert_not_nil wi['href']
+    assert_not_nil wi['links']
 
     assert_equal 'alice', wi['participant_name']
 
     atts = wi['attributes']
     atts['girl'] = 'Ukifune'
 
-    put :update, { 'state' =&gt; 'proceeded', 'fields' =&gt; atts }
+    p wi['flow_expression_id']['expression_id']
+
+    wfei = wi['flow_expression_id']
+
+    # timeout occurs during this put :
+    put(
+      :update,
+      { :wfid =&gt; wfei['workflow_instance_id'], :expid =&gt; wfei['expression_id'],
+        'state' =&gt; 'proceeded', 'fields' =&gt; atts })
+
     sleep 0.350
+
+    @request.env['HTTP_ACCEPT'] = 'application/json'
+    get :index
+    assert_response :success
+
+    workitems = ActiveSupport::JSON.decode(@response.body)
+
+    wi = workitems['elements'].find { |wi|
+      wi['flow_expression_id']['workflow_instance_id'] == fei.wfid }
+
+    assert_not_nil wi
   end
 end
 </diff>
      <filename>test/functional/workitems_controller_test.rb</filename>
    </modified>
    <modified>
      <diff>@@ -35,7 +35,7 @@ class Test::Unit::TestCase
   #
   # Note: You'll currently still have to declare fixtures explicitly in integration tests
   # -- they do not yet inherit this setting
-  fixtures :all
+  #fixtures :all
 
   # Add more helper methods to be used by all tests here...
 </diff>
      <filename>test/test_helper.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>d6907568e6e4195045e33515a595dcf4f7e61373</id>
    </parent>
  </parents>
  <author>
    <name>John Mettraux</name>
    <email>jmettraux@gmail.com</email>
  </author>
  <url>http://github.com/jmettraux/ruote-web2/commit/54e22ba395efa3498da35df7fb6c790b41633ffe</url>
  <id>54e22ba395efa3498da35df7fb6c790b41633ffe</id>
  <committed-date>2008-12-22T05:14:37-08:00</committed-date>
  <authored-date>2008-12-22T05:14:37-08:00</authored-date>
  <message>tst/func/workitems broken; good progress anyway</message>
  <tree>34b2544956cae7624a5ed396119f73222db7a7fd</tree>
  <committer>
    <name>John Mettraux</name>
    <email>jmettraux@gmail.com</email>
  </committer>
</commit>
