After thinking about all possible options, I try this. In worklist
model I add this function:

########### START CODE ##############
  def workitems_by_type_and_by_space(type, space)
    workitem_list = []

    store_names.each do |store_name|

      workitems = workitems(store_name)

      workitems.each_with_index do |workitem, i|
        type_mach = false
        space_mach = false
        workitem.fields_hash.each do |k, v|
          if (k == "type")
            type_mach = true
          end
          if (k == "space")
            space_mach = true
          end
        end

        if type_mach and space_mach
          workitem_list << workitem
        end
      end

    end

    workitem_list
  end
###### END CODE ##############

It seems to work fine. I hope this helps to someone.

Diego.

On 14 mayo, 14:12, "John Mettraux" <[EMAIL PROTECTED]> wrote:
> On Wed, May 14, 2008 at 6:41 PM, Diego Moreno <[EMAIL PROTECTED]> wrote:
>
> >  @worklist = Worklist.new(session[:user])
> >  string_query = "what?"
> >  workitems_by_type_and_space = @worklist.search(string_query)
>
> Hello Diego,
>
> this search feature is very primitive, the piece of code you have here
> will return all the workitems whose participants matches what? plus
> all workitems that contain a field with the string what? in its name
> or in its value.
>
> http://github.com/jmettraux/ruote/tree/master/lib/openwfe/extras/part...http://github.com/jmettraux/ruote/tree/master/lib/openwfe/extras/part...
>
> You might probably want to write a custom [ActiveRecord based]
> function for searching by type and namespace like
>
> OpenWFE::Extras::Field.find_by_fkey_and_svalue("type", my_type)
>
> or write a custom SQL query
>
> or load all workitems in a store and programatically extract the ones
> that match your criteria
>
> or have a composite field "#{type}_#{spacename}" and lookup for things
> like "fruit_spaceout" or "vegetable_spaceshuttle"
>
> or store your data in traditional table with a reference to a workitem
> id (if in a process), query the data and then lookup the referenced
> workitems.
>
> It all depends on your use case.
>
> Best regards, I hope this helps,
>
> --
> John Mettraux -http://jmettraux.wordpress.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"OpenWFEru users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/openwferu-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to