# File lib/ruote/part/storage_participant.rb, line 290
    def query(criteria)

      cr = Ruote.keys_to_s(criteria)

      if @context.storage.respond_to?(:query_workitems)
        return @context.storage.query_workitems(cr)
      end

      opts = {}
      opts[:skip] = cr.delete('offset') || cr.delete('skip')
      opts[:limit] = cr.delete('limit')
      opts[:count] = cr.delete('count')

      wfid = cr.delete('wfid')

      count = opts[:count]

      pname = cr.delete('participant_name') || cr.delete('participant')
      opts.delete(:count) if pname

      hwis = wfid ?
        @context.storage.get_many('workitems', wfid, opts) : fetch_all(opts)

      return hwis unless hwis.is_a?(Array)

      hwis = hwis.select { |hwi|
        Ruote::StorageParticipant.matches?(hwi, pname, cr)
      }

      count ? hwis.size : wis(hwis)
    end