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.
- #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
Constructor Details
#initialize(raw, server) ⇒ Repository
Returns a new instance of Repository.
8 9 10 11 12 13 14 15 16 |
# File 'lib/cmis/repository.rb', line 8 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.
6 7 8 |
# File 'lib/cmis/repository.rb', line 6 def server @server end |
Instance Method Details
#content_changes(change_log_token, opts = {}) ⇒ Object
99 100 101 102 103 |
# File 'lib/cmis/repository.rb', line 99 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
115 116 117 118 119 |
# File 'lib/cmis/repository.rb', line 115 def count_objects(type_id, properties = {}, opts = {}) opts.merge!(page_size: 0) statement = construct_statement(type_id, properties) query(statement, opts).total end |
#create_relationship(object, opts = {}) ⇒ Object
89 90 91 92 93 94 95 96 97 |
# File 'lib/cmis/repository.rb', line 89 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
81 82 83 84 85 86 87 |
# File 'lib/cmis/repository.rb', line 81 def create_type(type, opts = {}) result = server.execute!({ cmisaction: 'createType', repositoryId: id, type: JSON.generate(type.to_hash) }, opts) Type.new(result, self) end |
#find_object(type_id, properties = {}, opts = {}) ⇒ Object
109 110 111 112 113 |
# File 'lib/cmis/repository.rb', line 109 def find_object(type_id, properties = {}, opts = {}) opts.merge!(page_size: 1) statement = construct_statement(type_id, properties) query(statement, opts).results.first end |
#new_document ⇒ Object
18 19 20 |
# File 'lib/cmis/repository.rb', line 18 def new_document Document.new({}, self) end |
#new_folder ⇒ Object
22 23 24 |
# File 'lib/cmis/repository.rb', line 22 def new_folder Folder.new({}, self) end |
#new_item ⇒ Object
30 31 32 |
# File 'lib/cmis/repository.rb', line 30 def new_item Item.new({}, self) end |
#new_policy ⇒ Object
34 35 36 |
# File 'lib/cmis/repository.rb', line 34 def new_policy Policy.new({}, self) end |
#new_relationship ⇒ Object
26 27 28 |
# File 'lib/cmis/repository.rb', line 26 def new_relationship Relationship.new({}, self) end |
#new_type ⇒ Object
38 39 40 |
# File 'lib/cmis/repository.rb', line 38 def new_type Type.new({}, self) end |
#object(cmis_object_id, opts = {}) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/cmis/repository.rb', line 50 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
105 106 107 |
# File 'lib/cmis/repository.rb', line 105 def query(statement, opts = {}) Query.new(self, statement, opts) end |
#root(opts = {}) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/cmis/repository.rb', line 42 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
66 67 68 69 70 71 72 |
# File 'lib/cmis/repository.rb', line 66 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
74 75 76 77 78 79 |
# File 'lib/cmis/repository.rb', line 74 def type?(type_id) type(type_id) true rescue Exceptions::ObjectNotFound false end |
#types(opts = {}) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/cmis/repository.rb', line 58 def types(opts = {}) result = server.execute!({ cmisselector: 'typeDescendants', repositoryId: id, includePropertyDefinitions: true }, opts) construct_types(result) end |