Class: YACCL::Model::Object

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

Direct Known Subclasses

Document, Folder, Item, Policy, Relationship

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Object.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/yaccl/model/object.rb', line 18

def initialize(repository_id, raw={})
  @repository_id = repository_id
  @properties = get_properties_map(raw)

  @properties[:'cmis:creationDate'] = Time.at(@properties[:'cmis:creationDate'] / 1000) unless @properties[:'cmis:creationDate'].nil?
  @properties[:'cmis:lastModificationDate'] = Time.at(@properties[:'cmis:lastModificationDate'] / 1000) unless @properties[:'cmis:lastModificationDate'].nil?

  @object_id = @properties[:'cmis:objectId']
  @base_type_id = @properties[:'cmis:baseTypeId']
  @object_type_id = @properties[:'cmis:objectTypeId']
  @secondary_object_type_ids = @properties[:'cmis:secondaryObjectTypeId']
  @name = @properties[:'cmis:name']
  @description = @properties[:'cmis:description']
  @created_by = @properties[:'cmis:createdBy']
  @creation_date = @properties[:'cmis:creationDate']
  @last_modified_by = @properties[:'cmis:lastModifiedBy']
  @last_modification_date = @properties[:'cmis:lastModificationDate']
  @change_token = @properties[:'cmis:changeToken']
end

Instance Attribute Details

#base_type_idObject (readonly)

Returns the value of attribute base_type_id.



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

def base_type_id
  @base_type_id
end

#change_tokenObject (readonly)

Returns the value of attribute change_token.



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

def change_token
  @change_token
end

#created_byObject (readonly)

Returns the value of attribute created_by.



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

def created_by
  @created_by
end

#creation_dateObject (readonly)

Returns the value of attribute creation_date.



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

def creation_date
  @creation_date
end

#descriptionObject (readonly)

Returns the value of attribute description.



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

def description
  @description
end

#last_modification_dateObject (readonly)

Returns the value of attribute last_modification_date.



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

def last_modification_date
  @last_modification_date
end

#last_modified_byObject (readonly)

Returns the value of attribute last_modified_by.



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

def last_modified_by
  @last_modified_by
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#object_idObject (readonly)

Returns the value of attribute object_id.



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

def object_id
  @object_id
end

#object_type_idObject

Returns the value of attribute object_type_id.



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

def object_type_id
  @object_type_id
end

#propertiesObject

Returns the value of attribute properties.



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

def properties
  @properties
end

#repository_idObject (readonly)

Returns the value of attribute repository_id.



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

def repository_id
  @repository_id
end

#secondary_object_type_idsObject (readonly)

Returns the value of attribute secondary_object_type_ids.



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

def secondary_object_type_ids
  @secondary_object_type_ids
end

Instance Method Details

#aclsObject



80
81
82
# File 'lib/yaccl/model/object.rb', line 80

def acls
  Services.get_acl(repository_id, object_id, nil)
end

#add_aces(aces) ⇒ Object



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

def add_aces(aces)
  Services.apply_acl(repository_id, object_id, aces, nil, nil)
end

#allowable_actionsObject



60
61
62
# File 'lib/yaccl/model/object.rb', line 60

def allowable_actions
  Services.get_allowable_actions(repository_id, object_id)
end

#deleteObject



46
47
48
# File 'lib/yaccl/model/object.rb', line 46

def delete
  Services.delete_object(repository_id, object_id, true)
end

#object_typeObject



42
43
44
# File 'lib/yaccl/model/object.rb', line 42

def object_type
  repository.type(object_type_id)
end

#parentsObject



54
55
56
57
58
# File 'lib/yaccl/model/object.rb', line 54

def parents
  Services.get_object_parents(repository_id, object_id, nil, nil, nil, nil, nil).map do |o|
    ObjectFactory.create(repository_id, o[:object])
  end
end

#policiesObject



69
70
71
72
73
# File 'lib/yaccl/model/object.rb', line 69

def policies
  Services.get_applied_policies(repository_id, object_id, nil).map do |policy|
    Policy.create(repository_id, policy)
  end
end

#relationships(direction = :either) ⇒ Object



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

def relationships(direction=:either)
  result = Services.get_object_relationships(repository_id, object_id, nil, direction, nil, nil, false, nil, nil)
  result[:objects].map { |r| Relationship.create(repository_id, r) }
end

#remove_aces(aces) ⇒ Object



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

def remove_aces(aces)
  Services.apply_acl(repository_id, object_id, nil, aces, nil)
end

#repositoryObject



38
39
40
# File 'lib/yaccl/model/object.rb', line 38

def repository
  Server.repository(repository_id)
end

#unfileObject

remove from all folders



76
77
78
# File 'lib/yaccl/model/object.rb', line 76

def unfile
  Services.remove_object_from_folder(repository_id, object_id, nil)
end

#update_properties(properties) ⇒ Object



50
51
52
# File 'lib/yaccl/model/object.rb', line 50

def update_properties(properties)
  Services.update_properties(repository_id, object_id, nil, properties)
end