Class: Sinicum::Jcr::Node
- Inherits:
-
Object
- Object
- Sinicum::Jcr::Node
show all
- Extended by:
- ActiveModel::Naming, ActiveModel::Translation, ActiveSupport::Inflector
- Includes:
- ActiveModel::AttributeMethods, ActiveModel::Conversion, ActiveModel::Validations, Mgnl4Compatibility, NodeQueries
- Defined in:
- lib/sinicum/jcr/node.rb
Overview
Public: Base class to handle objects from the JCR store.
Constant Summary
collapse
- ISO_8601_REGEX =
/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}[+-]\d{2}:\d{2}/
- ISO_8601_DATE_REGEX =
/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z/
- IMPLICIT_ARRAY_REGEX =
/^\d+$/
- BOOL_TRUE_STRING_VALUE =
"true"
- BOOL_FALSE_STRING_VALUE =
"false"
- METADATA_NODE_NAME =
"MetaData"
- META_KEY =
"meta"
- PROPERTIES_KEY =
"properties"
- NODES_KEY =
"nodes"
- ARRAY_CHILD_NODE_PATTERN =
/^\d+$/
- SETABLE_JCR_PROPERTIES =
:jcr_path, :jcr_name, :jcr_primary_type, :jcr_primary_type,
:jcr_super_types, :jcr_workspace, :jcr_mixin_node_types
- PROHIBITED_JCR_PROPERTIES =
:uuid, :jcr_depth, :created_at, :updated_at, :lastaction_at
- SETABLE_MGNL_PROPERTIES =
[:mgnl_template, :mgnl_created_by]
- PROHIBITED_MGNL_PROPERTIES =
:mgnl_authorid, :mgnl_activatorid
Constants included
from NodeQueries
Sinicum::Jcr::NodeQueries::BINARY_PREFIX, Sinicum::Jcr::NodeQueries::PATH_DELIMITER, Sinicum::Jcr::NodeQueries::UUID_PREFIX
Instance Method Summary
collapse
#mgnl_activatorid, #mgnl_authorid
Constructor Details
#initialize(params = {}) ⇒ Node
Returns a new instance of Node.
35
36
37
38
39
40
41
42
|
# File 'lib/sinicum/jcr/node.rb', line 35
def initialize(params = {})
if params.key?(:json_response)
@__json_response = params[:json_response]
initialize_properties_from_json
else
initialize_from_hash(params)
end
end
|
Instance Method Details
#[](property_name) ⇒ Object
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/sinicum/jcr/node.rb', line 60
def [](property_name)
result = nil
property_key = property_name.to_s
if jcr_properties && jcr_properties.key?(property_key)
result = transform_jcr_types(jcr_properties[property_key])
elsif node_cache.key?(property_key) || (jcr_nodes && jcr_nodes.key?(property_key))
result = return_child_node(property_key)
end
result
end
|
#children ⇒ Object
71
72
73
74
75
76
77
78
|
# File 'lib/sinicum/jcr/node.rb', line 71
def children
children = []
jcr_nodes.each do |child|
next if child && child[0] == "MetaData"
children << NodeInitializer.initialize_node_from_json(child[1])
end
children
end
|
#id ⇒ Object
44
45
46
|
# File 'lib/sinicum/jcr/node.rb', line 44
def id
uuid
end
|
#inspect ⇒ Object
92
93
94
95
96
97
98
|
# File 'lib/sinicum/jcr/node.rb', line 92
def inspect
properties = []
jcr_properties.each_key { |key| properties << key } if jcr_properties
nodes = []
jcr_nodes.each_key { |key| nodes << key } if jcr_nodes
to_s + ", properties: #{properties}, nodes: #{nodes}\n"
end
|
#parent ⇒ Object
80
81
82
83
84
85
86
|
# File 'lib/sinicum/jcr/node.rb', line 80
def parent
fetch_from_parent_cache do
current_node_path = path.split("/")
current_node_path.slice!(-1) if current_node_path.size > 1
Sinicum::Jcr::Node.find_by_path(jcr_workspace, current_node_path.join("/"))
end
end
|
#path(options = {}) ⇒ Object
48
49
50
|
# File 'lib/sinicum/jcr/node.rb', line 48
def path(options = {})
jcr_path
end
|
#persisted? ⇒ Boolean
56
57
58
|
# File 'lib/sinicum/jcr/node.rb', line 56
def persisted?
!!@persisted
end
|
#to_model ⇒ Object
52
53
54
|
# File 'lib/sinicum/jcr/node.rb', line 52
def to_model
self
end
|
#to_s ⇒ Object
88
89
90
|
# File 'lib/sinicum/jcr/node.rb', line 88
def to_s
"#{self.class.name}, uuid: '#{uuid}', path: '#{jcr_path}'"
end
|