Class: CMIS::Query
- Inherits:
-
Object
- Object
- CMIS::Query
- Defined in:
- lib/cmis/query.rb
Instance Method Summary collapse
- #debug_info ⇒ Object
- #do_token_query(max, token = nil) ⇒ Object
-
#each_page(options = {}, &block) ⇒ Object
Options: limit.
-
#each_result(options = {}, &block) ⇒ Object
Options: limit.
- #has_next? ⇒ Boolean
-
#initialize(repository, statement, options = {}) ⇒ Query
constructor
Options: from, page_size.
- #results ⇒ Object
- #total ⇒ Object
Constructor Details
#initialize(repository, statement, options = {}) ⇒ Query
Options: from, page_size
7 8 9 10 11 12 13 14 15 |
# File 'lib/cmis/query.rb', line 7 def initialize(repository, statement, = {}) @repository = repository @statement = statement @options = .symbolize_keys @total = -1 end |
Instance Method Details
#debug_info ⇒ Object
89 90 91 |
# File 'lib/cmis/query.rb', line 89 def debug_info @debug_info end |
#do_token_query(max, token = nil) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/cmis/query.rb', line 72 def do_token_query(max, token=nil) params = { repositoryId: @repository.id, maxItems: max } params[:nextToken] = token if token if @method == 'post' params.merge!(cmisselector: 'query', q: @statement) else params.merge!(cmisaction: 'query', statement: @statement) end result = @repository.server.execute!(params, @opts) { nextToken: result['nextToken'] , objects: result['results'].map { |r| ObjectFactory.create(r, @repository) } } end |
#each_page(options = {}, &block) ⇒ Object
Options: limit
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/cmis/query.rb', line 36 def each_page( = {}, &block) return enum_for(:each_page, ) unless block_given? limit = parse_limit() counter = 0 while has_next? break unless counter < limit yield r = results counter += r.size end end |
#each_result(options = {}, &block) ⇒ Object
Options: limit
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/cmis/query.rb', line 18 def each_result( = {}, &block) return enum_for(:each_result, ) unless block_given? limit = parse_limit() return if limit == 0 counter = 0 while has_next? results.each do |object| yield object counter = counter.next return unless counter < limit end end end |
#has_next? ⇒ Boolean
61 62 63 |
# File 'lib/cmis/query.rb', line 61 def has_next? @has_next end |
#results ⇒ Object
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/cmis/query.rb', line 50 def results result = do_query @skip_count += result.results.size @has_next = result.has_more_items @total = result.num_items @debug_info = result.debug_info result.results end |
#total ⇒ Object
65 66 67 68 69 70 |
# File 'lib/cmis/query.rb', line 65 def total result = do_query @debug_info = result.debug_info @total = @total == -1 ? result.num_items : @total # CMIS AWS trickery end |