Class: YACCL::Model::Folder

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

Instance Attribute Summary collapse

Attributes inherited from Object

#base_type_id, #change_token, #cmis_object_id, #created_by, #creation_date, #description, #last_modification_date, #last_modified_by, #name, #object_type_id, #properties, #repository_id, #secondary_object_type_ids

Instance Method Summary collapse

Methods inherited from Object

#acls, #add_aces, #allowable_actions, #can_be_deleted?, #can_get_parents?, #can_update_properties, #create_properties, #delete, #detached?, #method_missing, #move, #object_id, #object_type, #parents, #policies, #relationships, #remove_aces, #repository, #unfile, #update_change_token, #update_properties

Constructor Details

#initialize(repository_id, raw = {}) ⇒ Folder

Returns a new instance of Folder.



8
9
10
11
12
13
# File 'lib/yaccl/model/folder.rb', line 8

def initialize(repository_id, raw={})
  super
  @parent_id = @properties[:'cmis:parentId']
  @path = @properties[:'cmis:path']
  @allowed_child_object_type_ids = @properties[:'cmis:allowedChildObjectTypeIds']
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class YACCL::Model::Object

Instance Attribute Details

#allowed_child_object_type_idsObject (readonly)

Returns the value of attribute allowed_child_object_type_ids.



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

def allowed_child_object_type_ids
  @allowed_child_object_type_ids
end

#parent_idObject (readonly)

Returns the value of attribute parent_id.



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

def parent_id
  @parent_id
end

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

Instance Method Details

#add(object) ⇒ Object



65
66
67
# File 'lib/yaccl/model/folder.rb', line 65

def add(object)
  Services.add_object_to_folder(repository_id, object.cmis_object_id, cmis_object_id, nil)
end

#allowed_child_object_typesObject



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

def allowed_child_object_types
  return nil if allowed_child_object_type_ids.nil?
  allowed_child_object_type_ids.map do |type_id|
    repository.type(type_id)
  end
end

#children(options = {}) {|children| ... } ⇒ Object

Yields:



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/yaccl/model/folder.rb', line 26

def children(options={})
  children = Services.get_children(repository_id, cmis_object_id, options[:filter], options[:order_by], options[:include_allowable_actions], options[:include_relations], options[:rendition_filter], options[:include_path_segment], options[:max_items], options[:skip_count])
  if children[:objects]
    children[:objects].map! { |o| ObjectFactory.create(repository_id, o[:object]) }
  else
    children[:objects] = []
  end
  children[:num_items] = children.delete(:numItems).to_i
  children[:has_more_items] = children.delete(:hasMoreItems)

  yield(children) if block_given?
  children[:objects]
end

#create(object) ⇒ Object



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

def create(object)
  properties = object.create_properties
  if object.is_a? Folder
    o = Services.create_folder(repository_id, properties, cmis_object_id, nil, nil, nil)
  elsif object.is_a? Document
    return object.create_in_folder(cmis_object_id)
  elsif object.is_a? Relationship
    raise 'relationship is not fileable'
  elsif object.is_a? Policy
    o = Services.create_policy(repository_id, properties, cmis_object_id, nil, nil, nil)
  elsif object.is_a? Item
    o = Services.create_item(repository_id, properties, cmis_object_id, nil, nil, nil)
  else
    raise "Unexpected base_type_id: #{object.base_type_id}"
  end
  ObjectFactory.create(repository_id, o)
end

#delete_treeObject



61
62
63
# File 'lib/yaccl/model/folder.rb', line 61

def delete_tree
  Services.delete_tree(repository_id, cmis_object_id, nil, nil, nil)
end

#parentObject



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

def parent
  repository.object(parent_id) unless parent_id.nil?
end

#remove(object) ⇒ Object



69
70
71
# File 'lib/yaccl/model/folder.rb', line 69

def remove(object)
  Services.remove_object_from_folder(repository_id, object.cmis_object_id, cmis_object_id)
end

#tree(depth) ⇒ Object



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

def tree(depth)
end