Class: Graffiti::RdfPropertyMap

Inherits:
Object
  • Object
show all
Defined in:
lib/graffiti/rdf_property_map.rb

Overview

Map of an internal RDF property into relational storage

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(property, table, field) ⇒ RdfPropertyMap

Returns a new instance of RdfPropertyMap.



36
37
38
39
40
41
# File 'lib/graffiti/rdf_property_map.rb', line 36

def initialize(property, table, field)
  # fixme: support ambiguous mappings
  @property = property
  @table = table
  @field = field
end

Instance Attribute Details

#fieldObject (readonly)

name of the field into which the property is mapped

if property range is not a literal, the field is a reference to the resource table



57
58
59
# File 'lib/graffiti/rdf_property_map.rb', line 57

def field
  @field
end

#propertyObject (readonly)

expanded uriref of the mapped property



45
46
47
# File 'lib/graffiti/rdf_property_map.rb', line 45

def property
  @property
end

#subproperty_ofObject

expanded uriref of the property which this property is a subproperty of

if set, this property maps into the same table and field as its superproperty, and is qualified by an additional field named <field>_subproperty which refers to a uriref resource holding uriref of this subproperty



66
67
68
# File 'lib/graffiti/rdf_property_map.rb', line 66

def subproperty_of
  @subproperty_of
end

#superproperty=(value) ⇒ Object (writeonly)

Sets the attribute superproperty

Parameters:

  • value

    the value to set the attribute superproperty to.



68
69
70
# File 'lib/graffiti/rdf_property_map.rb', line 68

def superproperty=(value)
  @superproperty = value
end

#tableObject (readonly)

name of the table into which the property is mapped (property domain is an internal resource class mapped into this table)



50
51
52
# File 'lib/graffiti/rdf_property_map.rb', line 50

def table
  @table
end

#transitive_closureObject

name of transitive closure table for a transitive property

the format of a transitive closure table is:

- 'resource' field refers to the subject resource id
- '<field>' property field and '<field>_subproperty' qualifier field (in
  case of subproperty) have the same name as in the main table
- 'distance' field holds the distance from subject to object in the RDF
  graph

the transitive closure table is automatically updated by a trigger on every update of the main table



89
90
91
# File 'lib/graffiti/rdf_property_map.rb', line 89

def transitive_closure
  @transitive_closure
end

Class Method Details

.qualifier_field(field, type = 'subproperty') ⇒ Object

special qualifier field



32
33
34
# File 'lib/graffiti/rdf_property_map.rb', line 32

def RdfPropertyMap.qualifier_field(field, type = 'subproperty')
  field + '_' + type
end

.qualifier_property(property, type = 'subproperty') ⇒ Object

special qualifier map

‘ ’ is added to the property name to make sure it can’t clash with any valid property uriref



26
27
28
# File 'lib/graffiti/rdf_property_map.rb', line 26

def RdfPropertyMap.qualifier_property(property, type = 'subproperty')
  property + ' ' + type
end

Instance Method Details

#superproperty?Boolean

set to true if this property has subproperties

Returns:

  • (Boolean)


72
73
74
# File 'lib/graffiti/rdf_property_map.rb', line 72

def superproperty?
  @superproperty or false
end