Class: CmisServer::BaseType

Inherits:
Object
  • Object
show all
Defined in:
lib/cmis_server/base_objects/base_type.rb

Direct Known Subclasses

CmisServer::BaseObjects::Item, Document, Folder

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ BaseType

Returns a new instance of BaseType.



91
92
93
94
95
96
97
98
# File 'lib/cmis_server/base_objects/base_type.rb', line 91

def initialize(attrs={})
  initialize_properties

  attrs.to_h.each do |property,value|
    self.send(property.to_s.gsub(/[^0-9a-z]/i, '_').underscore+"=",value)
  end

end

Class Attribute Details

.base_idObject (readonly)

Should be overwrited by base types



54
55
56
# File 'lib/cmis_server/base_objects/base_type.rb', line 54

def base_id
  @base_id
end

.controllable_aclObject (readonly)

Returns the value of attribute controllable_acl.



5
6
7
# File 'lib/cmis_server/base_objects/base_type.rb', line 5

def controllable_acl
  @controllable_acl
end

.controllable_policyObject (readonly)

Returns the value of attribute controllable_policy.



5
6
7
# File 'lib/cmis_server/base_objects/base_type.rb', line 5

def controllable_policy
  @controllable_policy
end

.creatableObject (readonly)

Returns the value of attribute creatable.



5
6
7
# File 'lib/cmis_server/base_objects/base_type.rb', line 5

def creatable
  @creatable
end

.descriptionObject (readonly)

Returns the value of attribute description.



5
6
7
# File 'lib/cmis_server/base_objects/base_type.rb', line 5

def description
  @description
end

.display_nameObject (readonly)

Returns the value of attribute display_name.



5
6
7
# File 'lib/cmis_server/base_objects/base_type.rb', line 5

def display_name
  @display_name
end

.fileableObject (readonly)

Returns the value of attribute fileable.



5
6
7
# File 'lib/cmis_server/base_objects/base_type.rb', line 5

def fileable
  @fileable
end

.fulltext_indexedObject (readonly)

Returns the value of attribute fulltext_indexed.



5
6
7
# File 'lib/cmis_server/base_objects/base_type.rb', line 5

def fulltext_indexed
  @fulltext_indexed
end

.idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/cmis_server/base_objects/base_type.rb', line 5

def id
  @id
end

.included_in_supertype_queryObject (readonly)

Returns the value of attribute included_in_supertype_query.



5
6
7
# File 'lib/cmis_server/base_objects/base_type.rb', line 5

def included_in_supertype_query
  @included_in_supertype_query
end

.local_nameObject (readonly)

Returns the value of attribute local_name.



5
6
7
# File 'lib/cmis_server/base_objects/base_type.rb', line 5

def local_name
  @local_name
end

.local_namespaceObject (readonly)

Returns the value of attribute local_namespace.



5
6
7
# File 'lib/cmis_server/base_objects/base_type.rb', line 5

def local_namespace
  @local_namespace
end

.parent_typeObject (readonly)

Returns the value of attribute parent_type.



5
6
7
# File 'lib/cmis_server/base_objects/base_type.rb', line 5

def parent_type
  @parent_type
end

.query_nameObject (readonly)

Returns the value of attribute query_name.



5
6
7
# File 'lib/cmis_server/base_objects/base_type.rb', line 5

def query_name
  @query_name
end

.queryableObject (readonly)

Returns the value of attribute queryable.



5
6
7
# File 'lib/cmis_server/base_objects/base_type.rb', line 5

def queryable
  @queryable
end

.self_property_definitionsObject (readonly)

Returns the value of attribute self_property_definitions.



21
22
23
# File 'lib/cmis_server/base_objects/base_type.rb', line 21

def self_property_definitions
  @self_property_definitions
end

Instance Attribute Details

#base_idObject

Returns the value of attribute base_id.



89
90
91
# File 'lib/cmis_server/base_objects/base_type.rb', line 89

def base_id
  @base_id
end

#controllable_aclObject

Returns the value of attribute controllable_acl.



89
90
91
# File 'lib/cmis_server/base_objects/base_type.rb', line 89

def controllable_acl
  @controllable_acl
end

#controllable_policyObject

Returns the value of attribute controllable_policy.



89
90
91
# File 'lib/cmis_server/base_objects/base_type.rb', line 89

def controllable_policy
  @controllable_policy
end

#creatableObject

Returns the value of attribute creatable.



89
90
91
# File 'lib/cmis_server/base_objects/base_type.rb', line 89

def creatable
  @creatable
end

#descriptionObject

Returns the value of attribute description.



89
90
91
# File 'lib/cmis_server/base_objects/base_type.rb', line 89

def description
  @description
end

#display_nameObject

Returns the value of attribute display_name.



89
90
91
# File 'lib/cmis_server/base_objects/base_type.rb', line 89

def display_name
  @display_name
end

#fileableObject

Returns the value of attribute fileable.



89
90
91
# File 'lib/cmis_server/base_objects/base_type.rb', line 89

def fileable
  @fileable
end

#fulltext_indexedObject

Returns the value of attribute fulltext_indexed.



89
90
91
# File 'lib/cmis_server/base_objects/base_type.rb', line 89

def fulltext_indexed
  @fulltext_indexed
end

#idObject

Returns the value of attribute id.



89
90
91
# File 'lib/cmis_server/base_objects/base_type.rb', line 89

def id
  @id
end

#included_in_supertype_queryObject

Returns the value of attribute included_in_supertype_query.



89
90
91
# File 'lib/cmis_server/base_objects/base_type.rb', line 89

def included_in_supertype_query
  @included_in_supertype_query
end

#local_nameObject

Returns the value of attribute local_name.



89
90
91
# File 'lib/cmis_server/base_objects/base_type.rb', line 89

def local_name
  @local_name
end

#local_namespaceObject

Returns the value of attribute local_namespace.



89
90
91
# File 'lib/cmis_server/base_objects/base_type.rb', line 89

def local_namespace
  @local_namespace
end

#parent_typeObject

Returns the value of attribute parent_type.



89
90
91
# File 'lib/cmis_server/base_objects/base_type.rb', line 89

def parent_type
  @parent_type
end

#propertiesObject (readonly)

Returns the value of attribute properties.



88
89
90
# File 'lib/cmis_server/base_objects/base_type.rb', line 88

def properties
  @properties
end

#property_definitionsObject

Returns the value of attribute property_definitions.



89
90
91
# File 'lib/cmis_server/base_objects/base_type.rb', line 89

def property_definitions
  @property_definitions
end

#query_nameObject

Returns the value of attribute query_name.



89
90
91
# File 'lib/cmis_server/base_objects/base_type.rb', line 89

def query_name
  @query_name
end

#queryableObject

Returns the value of attribute queryable.



89
90
91
# File 'lib/cmis_server/base_objects/base_type.rb', line 89

def queryable
  @queryable
end

Class Method Details

.adapter_classObject



73
74
75
# File 'lib/cmis_server/base_objects/base_type.rb', line 73

def adapter_class
  "#{self.to_s}Adapter".constantize
end

.base_typeObject



45
46
47
# File 'lib/cmis_server/base_objects/base_type.rb', line 45

def base_type
  self.parent_type ? self.parent_type.base_type : self
end

.parent_idObject



49
50
51
# File 'lib/cmis_server/base_objects/base_type.rb', line 49

def parent_id
  self.parent_type&.id
end

.parent_property_definitionsObject



62
63
64
# File 'lib/cmis_server/base_objects/base_type.rb', line 62

def parent_property_definitions
  self.parent_type&.property_definitions.to_a
end

.property(id, opts) ⇒ Object



66
67
68
69
70
71
# File 'lib/cmis_server/base_objects/base_type.rb', line 66

def property(id,opts)
  pd=CmisServer::PropertyDefinition.register_property_definition({id:id.freeze}.merge(opts))
  @self_property_definitions||=[]
  @self_property_definitions<<pd
  define_properties_methods(pd)
end

.property_definitionsObject



58
59
60
# File 'lib/cmis_server/base_objects/base_type.rb', line 58

def property_definitions
  @self_property_definitions.to_a+parent_property_definitions
end

.type_definition(opts = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/cmis_server/base_objects/base_type.rb', line 23

def type_definition(opts={})

  @id                          = CmisServer::Id.new(opts.fetch(:id).to_s)
  CmisServer::TypeRegistry.register_type(self.id, self)

  @parent_type                 = opts.fetch(:parent_type)
  @local_name                  = opts.fetch(:local_name,id)
  @local_namespace             = opts.fetch(:local_namespace,'local')
  @query_name                  = opts.fetch(:query_name,id)
  @display_name                = opts.fetch(:display_name,id)
  @description                 = opts.fetch(:description,'No description provided')
  @creatable                   = opts.fetch(:creatable ,false)
  @fileable                    = opts.fetch(:fileable ,false)
  @queryable                   = opts.fetch(:queryable ,false)
  @controllable_policy         = opts.fetch(:controllable_policy ,false)
  @controllable_acl            = opts.fetch(:controllable_acl ,false)
  @fulltext_indexed            = opts.fetch(:fulltext_indexed ,false)
  @included_in_supertype_query = opts.fetch(:included_in_supertype_query,false)

  define_properties_methods(parent_property_definitions)
end

Instance Method Details

#==(other) ⇒ Object



108
109
110
# File 'lib/cmis_server/base_objects/base_type.rb', line 108

def ==(other)
  self.cmis_object_id == other.cmis_object_id
end

#adapter(context:) ⇒ Object



104
105
106
# File 'lib/cmis_server/base_objects/base_type.rb', line 104

def adapter(context:)
  adapter_class.new(self, context: context)
end

#adapter_classObject



100
101
102
# File 'lib/cmis_server/base_objects/base_type.rb', line 100

def adapter_class
  self.class.adapter_class
end

#copy_properties_values_of(object) ⇒ Object



112
113
114
# File 'lib/cmis_server/base_objects/base_type.rb', line 112

def copy_properties_values_of object
  self.properties.each{|_k,property| property.value=object.send(property.property_definition.getter_method_name)}
end

#initialize_propertiesObject



116
117
118
119
120
121
# File 'lib/cmis_server/base_objects/base_type.rb', line 116

def initialize_properties
  all_prop_defs = (self.class.property_definitions.to_a + (@property_definitions.to_a || []))
  @properties = all_prop_defs.map do |pd|
    [pd.id, Property.new(pd, pd.value, self)]
  end.to_h
end

#to_renderable_objectObject



123
124
125
# File 'lib/cmis_server/base_objects/base_type.rb', line 123

def to_renderable_object
  CmisServer::RenderableObject.new(base_object: self)
end