Class: Qa::LinkedData::Mapper::ContextMapperService

Inherits:
Object
  • Object
show all
Defined in:
app/services/qa/linked_data/mapper/context_mapper_service.rb

Class Method Summary collapse

Class Method Details

.map_context(graph:, context_map:, subject_uri:) ⇒ <Hash<Symbol><Array<Object>>] mapped context values and information with hash of map key = array of object values for predicates identified in predicate_map.

Extract predicates specified in the predicate_map from the graph and return as a value map for a single subject URI.

Examples:

returned context map with one property defined

[{"group" => "group label,
  "property" => "property label",
  "values" => ["value 1","value 2"],
  "selectable" => true,
  "drillable" => false}]

Parameters:

  • graph (RDF::Graph)

    the graph from which to extract result values

  • context_map (Qa::LinkedData::Config::ContextMap)

    defines properties to extract from the graph to provide additional context

  • subject_uri (RDF::URI)

    the subject within the graph for which the values are being extracted

Returns:

  • (<Hash<Symbol><Array<Object>>] mapped context values and information with hash of map key = array of object values for predicates identified in predicate_map.)

    <Hash<Symbol><Array<Object>>] mapped context values and information with hash of map key = array of object values for predicates identified in predicate_map.



21
22
23
24
25
26
27
28
29
# File 'app/services/qa/linked_data/mapper/context_mapper_service.rb', line 21

def map_context(graph:, context_map:, subject_uri:)
  context = []
  context_map.properties.each do |property_map|
    populated_property_map = populate_property_map(context_map, property_map, graph, subject_uri)
    next if populated_property_map.blank?
    context << populated_property_map
  end
  context
end