Class: RoadForest::Interface::RDF

Inherits:
Application
  • Object
show all
Includes:
Graph::Etagging, Graph::Helpers::Focus
Defined in:
lib/roadforest/interface/rdf.rb

Instance Attribute Summary

Attributes inherited from Application

#services

Instance Method Summary collapse

Methods included from Graph::Helpers::Focus

#start_focus

Methods included from Graph::Etagging

#blank_mapped, #etag_from, #sorted_quads

Methods inherited from Application

#canonical_host, #default_content_engine, #dispatcher, #initialize

Constructor Details

This class inherits a constructor from RoadForest::Application

Instance Method Details

#add_child(focus) ⇒ Object



120
121
122
# File 'lib/roadforest/interface/rdf.rb', line 120

def add_child(focus)
  new_graph
end

#add_graph_child(graph) ⇒ Object



113
114
115
116
117
118
# File 'lib/roadforest/interface/rdf.rb', line 113

def add_graph_child(graph)
  start_focus(graph) do |focus|
    add_child(focus)
  end
  new_graph #XXX?
end

#augment_graph(graph) ⇒ Object



160
161
162
# File 'lib/roadforest/interface/rdf.rb', line 160

def augment_graph(graph)
  services.augmenter.augment(graph)
end

#copy_interface(node, route_name, params = nil) {|copier| ... } ⇒ Object

Yields:

  • (copier)


137
138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/roadforest/interface/rdf.rb', line 137

def copy_interface(node, route_name, params=nil)
  params ||= {}

  url = url_for(route_name, params)
  source_interface = interface_for(route_name, params)

  access = RoadForest::Graph::CopyManager.new
  access.source_graph = source_interface.current_graph
  access.target_graph = node.access_manager.destination_graph
  copier = RoadForest::Graph::GraphFocus.new(access, url)

  yield copier if block_given?
  copier
end

#current_graphObject



164
165
166
167
# File 'lib/roadforest/interface/rdf.rb', line 164

def current_graph
  return response_data if response_values.has_key?(:data)
  new_graph
end

#error_data(status) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/roadforest/interface/rdf.rb', line 90

def error_data(status)
  case status
  when 401
    begin
      perm_list_pattern = pattern_for(:perm_list, {}, [:username])

      graph = ::RDF::Graph.new
      perm_aff = ::RDF::Node.new
      perm_pattern = ::RDF::Node.new
      graph << [perm_aff, ::RDF.type, Graph::Af.Navigate]
      graph << [perm_aff, Graph::Af.target, perm_pattern]
      graph << [perm_pattern, Graph::Af.pattern, perm_list_pattern]

    rescue KeyError
      nil
    end
  end
end

#etagObject



152
153
154
# File 'lib/roadforest/interface/rdf.rb', line 152

def etag
  @etag ||= etag_from(etag_graph)
end

#etag_graphObject



156
157
158
# File 'lib/roadforest/interface/rdf.rb', line 156

def etag_graph
  current_graph
end

#fill_graph(graph) ⇒ Object



128
129
# File 'lib/roadforest/interface/rdf.rb', line 128

def fill_graph(graph)
end

#graph_update(focus) ⇒ Object



109
110
111
# File 'lib/roadforest/interface/rdf.rb', line 109

def graph_update(focus)
  fill_graph(focus)
end

#new_graphObject



169
170
171
172
173
# File 'lib/roadforest/interface/rdf.rb', line 169

def new_graph
  self.response_data = augment_graph(start_focus do |focus|
    fill_graph(focus)
  end)
end

#payload_focus(&block) ⇒ Object



131
132
133
134
135
# File 'lib/roadforest/interface/rdf.rb', line 131

def payload_focus(&block)
  payload_pair do |root, graph|
    start_focus(graph, root, &block)
  end
end

#payload_pair {|root_node, graph| ... } ⇒ Object

Utility method, useful for overriding #update_payload and #create_payload

Yields:

  • (root_node, graph)


76
77
78
79
80
81
82
# File 'lib/roadforest/interface/rdf.rb', line 76

def payload_pair
  root_node = ::RDF::Node.new
  graph = ::RDF::Graph.new
  graph << [root_node, ::RDF.type, Graph::Path.Root]
  yield root_node, graph
  return Payload.new(root_node, graph)
end

#retrieveObject



124
125
126
# File 'lib/roadforest/interface/rdf.rb', line 124

def retrieve
  new_graph
end

#update(graph) ⇒ Object



84
85
86
87
88
# File 'lib/roadforest/interface/rdf.rb', line 84

def update(graph)
  start_focus(graph) do |focus|
    graph_update(focus)
  end
end