Class: YACCL::Model::Type

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository_id, hash = {}) ⇒ Type

Returns a new instance of Type.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/yaccl/model/type.rb', line 32

def initialize(repository_id, hash={})
  @repository_id = repository_id

  @id = hash[:id]
  @local_name = hash[:localName]
  @local_namespace = hash[:localNamespace]
  @query_name = hash[:queryName]
  @display_name = hash[:displayName]
  @base_id = hash[:baseId]
  @parent_id = hash[:parentId]
  @description = hash[:description]
  @creatable = hash[:creatable]
  @fileable = hash[:fileable]
  @queryable = hash[:queryable]
  @controllable_policy = hash[:controllablePolicy]
  @controllable_acl = hash[:controllableACL]
  @fulltext_indexed = hash[:fulltextIndexed]
  @included_in_supertype_query = hash[:includedInSupertype_query]
  @property_definitions = hash[:propertyDefinitions] || {}
  # document type
  @versionable = hash[:versionable]
  @content_stream_allowed = hash[:contentStreamAllowed]
  # relationship type
  @allowed_source_types = hash[:allowedSourceTypes]
  @allowed_target_types = hash[:allowedTargetTypes]
end

Instance Attribute Details

#allowed_source_typesObject

relationship type



25
26
27
# File 'lib/yaccl/model/type.rb', line 25

def allowed_source_types
  @allowed_source_types
end

#allowed_target_typesObject

Returns the value of attribute allowed_target_types.



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

def allowed_target_types
  @allowed_target_types
end

#base_idObject

Returns the value of attribute base_id.



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

def base_id
  @base_id
end

#content_stream_allowedObject

Returns the value of attribute content_stream_allowed.



23
24
25
# File 'lib/yaccl/model/type.rb', line 23

def content_stream_allowed
  @content_stream_allowed
end

#controllable_aclObject

Returns the value of attribute controllable_acl.



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

def controllable_acl
  @controllable_acl
end

#controllable_policyObject

Returns the value of attribute controllable_policy.



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

def controllable_policy
  @controllable_policy
end

#creatableObject

Returns the value of attribute creatable.



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

def creatable
  @creatable
end

#descriptionObject

Returns the value of attribute description.



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

def description
  @description
end

#display_nameObject

Returns the value of attribute display_name.



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

def display_name
  @display_name
end

#fileableObject

Returns the value of attribute fileable.



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

def fileable
  @fileable
end

#fulltext_indexedObject

Returns the value of attribute fulltext_indexed.



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

def fulltext_indexed
  @fulltext_indexed
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#included_in_supertype_queryObject

Returns the value of attribute included_in_supertype_query.



19
20
21
# File 'lib/yaccl/model/type.rb', line 19

def included_in_supertype_query
  @included_in_supertype_query
end

#local_nameObject

Returns the value of attribute local_name.



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

def local_name
  @local_name
end

#local_namespaceObject

Returns the value of attribute local_namespace.



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

def local_namespace
  @local_namespace
end

#parent_idObject

Returns the value of attribute parent_id.



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

def parent_id
  @parent_id
end

#property_definitionsObject

Returns the value of attribute property_definitions.



20
21
22
# File 'lib/yaccl/model/type.rb', line 20

def property_definitions
  @property_definitions
end

#query_nameObject

Returns the value of attribute query_name.



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

def query_name
  @query_name
end

#queryableObject

Returns the value of attribute queryable.



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

def queryable
  @queryable
end

#repository_idObject (readonly)

Returns the value of attribute repository_id.



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

def repository_id
  @repository_id
end

#versionableObject

document type



22
23
24
# File 'lib/yaccl/model/type.rb', line 22

def versionable
  @versionable
end

Class Method Details

.create(repository_id, raw) ⇒ Object



28
29
30
# File 'lib/yaccl/model/type.rb', line 28

def self.create(repository_id, raw)
  Type.new(repository_id, raw)
end

Instance Method Details

#add_property_definition(property) ⇒ Object



59
60
61
# File 'lib/yaccl/model/type.rb', line 59

def add_property_definition(property)
  @property_definitions[property[:id]] = property
end

#new_objectObject



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/yaccl/model/type.rb', line 63

def new_object
  object = case base_id
  when 'cmis:document'
    Document.new(repository_id)
  when 'cmis:folder'
    Folder.new(repository_id)
  when 'cmis:relationship'
    Relationship.new(repository_id)
  when 'cmis:policy'
    Policy.new(repository_id)
  when 'cmis:item'
    Item.new(repository_id)
  else
    raise "Unsupported base type: #{base_id}"
  end
  object.object_type_id = id
  object
end

#to_hashObject



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/yaccl/model/type.rb', line 82

def to_hash
  hash = {}
  hash[:id] = id
  hash[:localName] = local_name
  hash[:localNamespace] = local_namespace
  hash[:queryName]= query_name
  hash[:displayName]= display_name
  hash[:baseId]= base_id
  hash[:parentId]= parent_id
  hash[:description]= description
  hash[:creatable]= creatable
  hash[:fileable]= fileable
  hash[:queryable]= queryable
  hash[:controllablePolicy]= controllable_policy
  hash[:controllableACL]= controllable_acl
  hash[:fulltextIndexed]= fulltext_indexed
  hash[:includedInSupertypeQuery]= included_in_supertype_query
  hash[:propertyDefinitions]= property_definitions
  # document type
  hash[:versionable] = versionable unless versionable.nil?
  hash[:contentStreamAllowed] = content_stream_allowed unless content_stream_allowed.nil?
  # relationship type
  hash[:allowedSourceTypes] = allowed_source_types unless allowed_source_types.nil?
  hash[:allowedTargetTypes] = allowed_target_types unless allowed_target_types.nil?
  hash
end