Class: CMIS::Repository
- Inherits:
-
Object
- Object
- CMIS::Repository
- Defined in:
- lib/cmis/repository.rb
Instance Attribute Summary collapse
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Instance Method Summary collapse
- #content_changes(change_log_token, opts = {}) ⇒ Object
- #count_objects(type_id, properties = {}, opts = {}) ⇒ Object
- #create_relationship(object, opts = {}) ⇒ Object
- #create_type(type, opts = {}) ⇒ Object
- #find_object(type_id, properties = {}, opts = {}) ⇒ Object
-
#initialize(raw, server) ⇒ Repository
constructor
A new instance of Repository.
- #inspect ⇒ Object
- #new_document ⇒ Object
- #new_folder ⇒ Object
- #new_item ⇒ Object
- #new_policy ⇒ Object
- #new_relationship ⇒ Object
- #new_type ⇒ Object
- #object(cmis_object_id, opts = {}) ⇒ Object
- #query(statement, opts = {}) ⇒ Object
- #root(opts = {}) ⇒ Object
- #type(type_id, opts = {}) ⇒ Object
- #type?(type_id) ⇒ Boolean
- #types(opts = {}) ⇒ Object
- #update_objects(type_id, conditions, properties) ⇒ Object
Constructor Details
#initialize(raw, server) ⇒ Repository
Returns a new instance of Repository.
9 10 11 12 13 14 15 16 17 |
# File 'lib/cmis/repository.rb', line 9 def initialize(raw, server) @hash = raw @hash.each_key do |key| self.class.class_eval "def #{key.as_ruby_property};@hash['#{key}'];end" self.class.class_eval "def #{key.gsub('repository', '').as_ruby_property};@hash['#{key}'];end" if key =~ /^repository/ end @server = server end |
Instance Attribute Details
#server ⇒ Object (readonly)
Returns the value of attribute server.
7 8 9 |
# File 'lib/cmis/repository.rb', line 7 def server @server end |
Instance Method Details
#content_changes(change_log_token, opts = {}) ⇒ Object
96 97 98 99 100 |
# File 'lib/cmis/repository.rb', line 96 def content_changes(change_log_token, opts = {}) server.execute!({ cmisselector: 'contentChanges', repositoryId: id, changeLogToken: change_log_token }, opts) end |
#count_objects(type_id, properties = {}, opts = {}) ⇒ Object
112 113 114 115 116 |
# File 'lib/cmis/repository.rb', line 112 def count_objects(type_id, properties = {}, opts = {}) opts.merge!(page_size: 0) statement = Utils.build_query_statement(type_id, properties, 'cmis:objectId') query(statement, opts).total end |
#create_relationship(object, opts = {}) ⇒ Object
86 87 88 89 90 91 92 93 94 |
# File 'lib/cmis/repository.rb', line 86 def create_relationship(object, opts = {}) raise 'Object is not a Relationship' unless object.is_a?(Relationship) result = server.execute!({ cmisaction: 'createRelationship', repositoryId: id, properties: object.properties }, opts) ObjectFactory.create(result, self) end |
#create_type(type, opts = {}) ⇒ Object
82 83 84 |
# File 'lib/cmis/repository.rb', line 82 def create_type(type, opts = {}) type.create(opts) end |
#find_object(type_id, properties = {}, opts = {}) ⇒ Object
106 107 108 109 110 |
# File 'lib/cmis/repository.rb', line 106 def find_object(type_id, properties = {}, opts = {}) opts.merge!(page_size: 1) statement = Utils.build_query_statement(type_id, properties) query(statement, opts).results.first end |
#inspect ⇒ Object
132 133 134 |
# File 'lib/cmis/repository.rb', line 132 def inspect "#{self.class}[#{id}] @ #{server.inspect}" end |
#new_document ⇒ Object
19 20 21 |
# File 'lib/cmis/repository.rb', line 19 def new_document Document.new({}, self) end |
#new_folder ⇒ Object
23 24 25 |
# File 'lib/cmis/repository.rb', line 23 def new_folder Folder.new({}, self) end |
#new_item ⇒ Object
31 32 33 |
# File 'lib/cmis/repository.rb', line 31 def new_item Item.new({}, self) end |
#new_policy ⇒ Object
35 36 37 |
# File 'lib/cmis/repository.rb', line 35 def new_policy Policy.new({}, self) end |
#new_relationship ⇒ Object
27 28 29 |
# File 'lib/cmis/repository.rb', line 27 def new_relationship Relationship.new({}, self) end |
#new_type ⇒ Object
39 40 41 |
# File 'lib/cmis/repository.rb', line 39 def new_type Type.new({}, self) end |
#object(cmis_object_id, opts = {}) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/cmis/repository.rb', line 51 def object(cmis_object_id, opts = {}) result = server.execute!({ cmisselector: 'object', repositoryId: id, objectId: cmis_object_id }, opts) ObjectFactory.create(result, self) end |
#query(statement, opts = {}) ⇒ Object
102 103 104 |
# File 'lib/cmis/repository.rb', line 102 def query(statement, opts = {}) Query.new(self, statement, opts) end |
#root(opts = {}) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/cmis/repository.rb', line 43 def root(opts = {}) result = server.execute!({ cmisselector: 'object', repositoryId: id, objectId: root_folder_id }, opts) ObjectFactory.create(result, self) end |
#type(type_id, opts = {}) ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/cmis/repository.rb', line 67 def type(type_id, opts = {}) result = server.execute!({ cmisselector: 'typeDefinition', repositoryId: id, typeId: type_id }, opts) Type.new(result, self) end |
#type?(type_id) ⇒ Boolean
75 76 77 78 79 80 |
# File 'lib/cmis/repository.rb', line 75 def type?(type_id) type(type_id) true rescue Exceptions::ObjectNotFound false end |
#types(opts = {}) ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/cmis/repository.rb', line 59 def types(opts = {}) result = server.execute!({ cmisselector: 'typeDescendants', repositoryId: id, includePropertyDefinitions: true }, opts) construct_types(result) end |
#update_objects(type_id, conditions, properties) ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/cmis/repository.rb', line 118 def update_objects(type_id, conditions, properties) statement = Utils.build_query_statement(type_id, conditions, 'cmis:objectId', 'cmis:changeToken') object_ids_and_change_tokens = [] query(statement).each_result(limit: :all) do |r| object_ids_and_change_tokens << [r.cmis_object_id, r.change_token] end unless object_ids_and_change_tokens.empty? server.execute!({ cmisaction: 'bulkUpdate', repositoryId: id, objectIdAndChangeToken: object_ids_and_change_tokens, properties: properties }) end end |