class Graffiti::RdfConfig
Configuration of relational RDF storage (see examples)
Attributes
map[R]
map internal property names with expanded namespaces to RdfPropertyMap
objects
ns[R]
hash of namespaces
Public Class Methods
new(config)
click to toggle source
# File lib/graffiti/rdf_config.rb, line 22 def initialize(config) @ns = config['ns'] @map = {} config['map'].each_pair do |p, m| table, field = m.to_a.first p = ns_expand(p) @map[p] = RdfPropertyMap.new(p, table, field) end if config['subproperties'].kind_of? Hash config['subproperties'].each_pair do |p, subproperties| p = ns_expand(p) map = @map[p] or raise RuntimeError, "Incorrect RDF storage configuration: superproperty #{p} must be mapped" map.superproperty = true qualifier = RdfPropertyMap.qualifier_property(p) @map[qualifier] = RdfPropertyMap.new( qualifier, map.table, RdfPropertyMap.qualifier_field(map.field)) subproperties.each do |subp| subp = ns_expand(subp) @map[subp] = RdfPropertyMap.new(subp, map.table, map.field) @map[subp].subproperty_of = p end end end if config['transitive_closure'].kind_of? Hash config['transitive_closure'].each_pair do |p, table| @map[ ns_expand(p) ].transitive_closure = table if config['subproperties'].kind_of?(Hash) and config['subproperties'][p] config['subproperties'][p].each do |subp| @map[ ns_expand(subp) ].transitive_closure = table end end end end end
Public Instance Methods
ns_expand(p)
click to toggle source
# File lib/graffiti/rdf_config.rb, line 73 def ns_expand(p) p and p.sub(/\A(\S+?)::/) { @ns[$1] } end