Class: CmisServer::DiscoveryService

Inherits:
Object
  • Object
show all
Defined in:
app/services/cmis_server/discovery_service.rb

Instance Method Summary collapse

Constructor Details

#initialize(repository, context) ⇒ DiscoveryService

Returns a new instance of DiscoveryService.



4
5
6
7
# File 'app/services/cmis_server/discovery_service.rb', line 4

def initialize(repository, context)
  @repository= repository.is_a?(Repository) ? repository : CmisServer::Repository.find(repository)
  @context   =context
end

Instance Method Details

#query(statement, search_all_versions: false, include_relationships: :none, rendition_filter: "cmis:none", include_allowable_actions: false, max_items: 10, skip_count: 0) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/services/cmis_server/discovery_service.rb', line 10

def query(statement, search_all_versions: false, include_relationships: :none, rendition_filter: "cmis:none", include_allowable_actions: false, max_items: 10, skip_count: 0)

  query_statement=CmisServer::Query::Parser.parse(statement)

  #Verify that there is only one Table
  table=query_statement.query_expression.from.tables.first
  raise "Join are not supported" unless table.is_a? CmisServer::Query::Statement::Table
  target_klass=TypeAdapter.find(table.name)

  objects=target_klass.adapter_class.class_adapter(context: @context).where(query_statement.query_expression.where.to_h, limit: 10, offset: 0)

  {
      query_results:  objects.map { |o| o.to_renderable_object },
      has_more_items: false, #ToDO
      num_items: nil, #ToDO
  }


end