Class: YACCL::Model::Repository

Inherits:
Object
  • Object
show all
Defined in:
lib/yaccl/model/repository.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw) ⇒ Repository

Returns a new instance of Repository.



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/yaccl/model/repository.rb', line 44

def initialize(raw)
  @id = raw[:repositoryId]
  @name = raw[:repositoryName]
  @description = raw[:repositoryDescription]
  @root_folder_id = raw[:rootFolderId]
  @capabilities = raw[:capabilities]
  @url = raw[:repositoryUrl]
  @latest_change_log_token = raw[:latestChangeLogToken]
  @vendor_name = raw[:vendorName]
  @cmis_version_supported = raw[:cmisVersionSupported]
  @acl_capabilities = raw[:aclCapabilities]
  @product_name = raw[:productName]
  @product_version = raw[:productVersion]
  @thin_client_uri = raw[:thinClientUri]
  @changes_on_type = raw[:changesOnType]
  @root_folder_url = raw[:rootFolderUrl]
end

Instance Attribute Details

#acl_capabilitiesObject (readonly)

Returns the value of attribute acl_capabilities.



13
14
15
# File 'lib/yaccl/model/repository.rb', line 13

def acl_capabilities
  @acl_capabilities
end

#capabilitiesObject (readonly)

Returns the value of attribute capabilities.



8
9
10
# File 'lib/yaccl/model/repository.rb', line 8

def capabilities
  @capabilities
end

#changes_on_typeObject (readonly)

Returns the value of attribute changes_on_type.



17
18
19
# File 'lib/yaccl/model/repository.rb', line 17

def changes_on_type
  @changes_on_type
end

#cmis_version_supportedObject (readonly)

Returns the value of attribute cmis_version_supported.



12
13
14
# File 'lib/yaccl/model/repository.rb', line 12

def cmis_version_supported
  @cmis_version_supported
end

#descriptionObject (readonly)

Returns the value of attribute description.



6
7
8
# File 'lib/yaccl/model/repository.rb', line 6

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/yaccl/model/repository.rb', line 4

def id
  @id
end

#latest_change_log_tokenObject (readonly)

Returns the value of attribute latest_change_log_token.



10
11
12
# File 'lib/yaccl/model/repository.rb', line 10

def latest_change_log_token
  @latest_change_log_token
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/yaccl/model/repository.rb', line 5

def name
  @name
end

#product_nameObject (readonly)

Returns the value of attribute product_name.



14
15
16
# File 'lib/yaccl/model/repository.rb', line 14

def product_name
  @product_name
end

#product_versionObject (readonly)

Returns the value of attribute product_version.



15
16
17
# File 'lib/yaccl/model/repository.rb', line 15

def product_version
  @product_version
end

#root_folder_idObject (readonly)

Returns the value of attribute root_folder_id.



7
8
9
# File 'lib/yaccl/model/repository.rb', line 7

def root_folder_id
  @root_folder_id
end

#root_folder_urlObject (readonly)

Returns the value of attribute root_folder_url.



18
19
20
# File 'lib/yaccl/model/repository.rb', line 18

def root_folder_url
  @root_folder_url
end

#thin_client_uriObject (readonly)

Returns the value of attribute thin_client_uri.



16
17
18
# File 'lib/yaccl/model/repository.rb', line 16

def thin_client_uri
  @thin_client_uri
end

#urlObject (readonly)

Returns the value of attribute url.



9
10
11
# File 'lib/yaccl/model/repository.rb', line 9

def url
  @url
end

#vendor_nameObject (readonly)

Returns the value of attribute vendor_name.



11
12
13
# File 'lib/yaccl/model/repository.rb', line 11

def vendor_name
  @vendor_name
end

Class Method Details

.create(raw_repository) ⇒ Object



40
41
42
# File 'lib/yaccl/model/repository.rb', line 40

def self.create(raw_repository)
  Repository.new(raw_repository)
end

.exist?(repository_id) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
33
34
35
36
37
38
# File 'lib/yaccl/model/repository.rb', line 30

def self.exist?(repository_id)
  found = true
  begin
    Services.get_repository_info(repository_id, true)
  rescue ObjectNotFoundError
    found = false
  end
  found
end

Instance Method Details

#==(other) ⇒ Object



20
21
22
23
24
# File 'lib/yaccl/model/repository.rb', line 20

def ==(other)
  return true if other.equal?(self)
  return false unless other.kind_of?(self.class)
  id == other.id
end

#content_changes(change_log_token) ⇒ Object



149
150
151
# File 'lib/yaccl/model/repository.rb', line 149

def content_changes(change_log_token)
  Services.get_content_changes(id, change_log_token, nil, nil, nil, nil)
end

#create(object) ⇒ Object

relationship



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/yaccl/model/repository.rb', line 108

def create(object)
  properties = object.create_properties
  if object.is_a? Folder
    raise 'create object in folder'
  elsif object.is_a? Document
    raise 'create document in folder'
  elsif object.is_a? Relationship
    o = Services.create_relationship(id, properties, nil, nil, nil)
  elsif object.is_a? Policy
    raise 'create policy in folder'
  elsif object.is_a? Item
    raise 'create item in folder'
  else
    raise "Unexpected base_type_id: #{object.base_type_id}"
  end
  ObjectFactory.create(id, o)
end

#create_type(type) ⇒ Object



102
103
104
# File 'lib/yaccl/model/repository.rb', line 102

def create_type(type)
  Type.create(id, Services.create_type(id, type.to_hash))
end

#new_documentObject



66
67
68
# File 'lib/yaccl/model/repository.rb', line 66

def new_document
  Document.new(id)
end

#new_folderObject



62
63
64
# File 'lib/yaccl/model/repository.rb', line 62

def new_folder
  Folder.new(id)
end

#new_itemObject



78
79
80
# File 'lib/yaccl/model/repository.rb', line 78

def new_item
  Item.new(id)
end

#new_policyObject



74
75
76
# File 'lib/yaccl/model/repository.rb', line 74

def new_policy
  Policy.new(id)
end

#new_relationshipObject



70
71
72
# File 'lib/yaccl/model/repository.rb', line 70

def new_relationship
  Relationship.new(id)
end

#object(cmis_object_id) ⇒ Object



88
89
90
# File 'lib/yaccl/model/repository.rb', line 88

def object(cmis_object_id)
  ObjectFactory.create(id, Services.get_object(id, cmis_object_id, nil, false, nil, nil, false, false))
end

#query(statement, max_items = nil, skip_count = nil) {|result| ... } ⇒ Object

discovery

Yields:

  • (result)


128
129
130
131
132
133
134
135
136
# File 'lib/yaccl/model/repository.rb', line 128

def query(statement, max_items=nil, skip_count=nil, &block)
  result = Services.query(id, statement, nil, nil, nil, nil, max_items, skip_count)
  result[:results].map! { |o| ObjectFactory.create(id, o) }
  result[:num_items] = result.delete(:numItems)
  result[:has_more_items] = result.delete(:hasMoreItems)

  yield(result) if block_given?
  result[:results]
end

#query_for_each_chunk(statement, chunk_size, &block) ⇒ Object



138
139
140
141
142
143
144
145
146
147
# File 'lib/yaccl/model/repository.rb', line 138

def query_for_each_chunk(statement, chunk_size, &block)
  skip_count = 0
  has_more_items = true
  while has_more_items
    result = Services.query(id, statement, nil, nil, nil, nil, chunk_size, skip_count)
    yield(result[:results].map! { |o| ObjectFactory.create(id, o) }) unless result[:results].empty?
    has_more_items = result[:hasMoreItems]
    skip_count += result[:results].size
  end
end

#rootObject

object



84
85
86
# File 'lib/yaccl/model/repository.rb', line 84

def root
  ObjectFactory.create(id, Services.get_object(id, root_folder_id, nil, false, nil, nil, false, false))
end

#to_sObject



26
27
28
# File 'lib/yaccl/model/repository.rb', line 26

def to_s
  name
end

#type(type_id) ⇒ Object

type



94
95
96
# File 'lib/yaccl/model/repository.rb', line 94

def type(type_id)
  Type.create(id, Services.get_type_definition(id, type_id))
end

#typesObject



98
99
100
# File 'lib/yaccl/model/repository.rb', line 98

def types
  _types(Services.get_type_descendants(id, nil, nil, true))
end