Class: RoadForest::RDF::UpdateManager

Inherits:
SplitManager show all
Defined in:
lib/roadforest/rdf/access-manager.rb

Constant Summary

Constants included from Normalization

Normalization::Vocabs

Instance Attribute Summary collapse

Attributes inherited from SplitManager

#target_graph

Attributes inherited from ReadOnlyManager

#resource, #rigor, #source_graph

Instance Method Summary collapse

Methods inherited from SplitManager

#relevant_prefixes

Methods inherited from ReadOnlyManager

#build_query, #each, #query_execute, #query_pattern, #relevant_prefixes

Methods included from Normalization

#expand_curie, #expand_curie_pair, #interned_uri, #literal, #normalize_context, #normalize_property, #normalize_resource, #normalize_statement, #normalize_term, #normalize_tuple, #normalize_uri, #relevant_prefixes_for_graph, #root_url, #uri, #vocabularies_in_graph

Constructor Details

#initializeUpdateManager

Returns a new instance of UpdateManager.



96
97
98
# File 'lib/roadforest/rdf/access-manager.rb', line 96

def initialize
  @copied_contexts = {}
end

Instance Attribute Details

#copied_contextsObject

Returns the value of attribute copied_contexts.



100
101
102
# File 'lib/roadforest/rdf/access-manager.rb', line 100

def copied_contexts
  @copied_contexts
end

Instance Method Details

#copy_contextObject



136
137
138
139
140
141
142
143
# File 'lib/roadforest/rdf/access-manager.rb', line 136

def copy_context
  return if copied_contexts[resource]
  parceller.graph_for(resource).each_statement do |statement|
    statement.context = resource
    destination_graph << statement
  end
  copied_contexts[resource] = true
end

#delete(statement) ⇒ Object



122
123
124
125
# File 'lib/roadforest/rdf/access-manager.rb', line 122

def delete(statement)
  copy_context
  super
end

#dupObject



102
103
104
105
106
# File 'lib/roadforest/rdf/access-manager.rb', line 102

def dup
  other = super
  other.copied_contexts = self.copied_contexts
  return other
end

#execute_search(search, &block) ⇒ Object



108
109
110
111
112
113
114
115
# File 'lib/roadforest/rdf/access-manager.rb', line 108

def execute_search(search, &block)
  enum = search.execute(destination_graph)
  if enum.any?{ true }
    enum.each(&block)
    return enum
  end
  search.execute(origin_graph, &block)
end

#insert(statement) ⇒ Object



117
118
119
120
# File 'lib/roadforest/rdf/access-manager.rb', line 117

def insert(statement)
  copy_context
  super
end

#parcellerObject



127
128
129
130
131
132
133
134
# File 'lib/roadforest/rdf/access-manager.rb', line 127

def parceller
  @parceller ||=
    begin
      parceller = Parcel.new
      parceller.graph = source_graph
      parceller
    end
end