Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Oct 13, 2022
2 parents d1d34dc + 835aefa commit 199f12e
Showing 1 changed file with 4 additions and 26 deletions.
30 changes: 4 additions & 26 deletions lib/goo/sparql/solutions_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,16 @@ def initialize(aggregate_projections, bnode_extraction, embed_struct,
@collection = options[:collection]
end

def map_each_solutions(select)


def map_each_solutions(select)

found = Set.new
objects_new = {}
var_set_hash = {}
list_attributes = Set.new(@klass.attributes(:list))
all_attributes = Set.new(@klass.attributes(:all))
@lang_filter = Goo::SPARQL::Solution::LanguageFilter.new

select.each_solution do |sol|
next if sol[:some_type] && @klass.type_uri(@collection) != sol[:some_type]
return sol[:count_var].object if @count
Expand Down Expand Up @@ -302,8 +301,8 @@ def include_bnodes(bnodes, models_by_id)
bnode_attrs = struct.new.to_h.keys
ids = bnodes.select { |x, y| y.attribute == attr }.map { |x, y| y.id }
@klass.where.models(models_by_id.select { |x, y| ids.include?(x) }.values)
.in(@collection)
.include(bnode: { attr => bnode_attrs }).all
.in(@collection)
.include(bnode: { attr => bnode_attrs }).all
end
end

Expand Down Expand Up @@ -362,26 +361,6 @@ def get_collection_value
collection_value
end

def model_map_attributes_values(id, object, sol, v)
#binding.pry if v.eql? :programs
if @models_by_id[id].respond_to?(:klass)
@models_by_id[id][v] = object if @models_by_id[id][v].nil?
else
model_attribute_val = @models_by_id[id].instance_variable_get("@#{v.to_s}")
if (!@models_by_id[id].class.handler?(v) || model_attribute_val.nil?) && v != :id
# if multiple language values are included for a given property, set the
# corresponding model attribute to the English language value - NCBO-1662
if sol[v].is_a?(RDF::Literal)
key = "#{v}#__#{id.to_s}"
models_by_id[id].send("#{v}=", object, on_load: true) unless var_set_hash[key]
lang = sol[v].language
var_set_hash[key] = true if %i[EN en EN en EN en].include?(lang)
else
models_by_id[id].send("#{v}=", object, on_load: true)
end
end
end
end

def object_to_array(id, klass_struct, models_by_id, object, predicate)
pre = if klass_struct
Expand Down Expand Up @@ -452,7 +431,6 @@ def get_pre_val(id, models_by_id, object, predicate)
pre_val
end


def add_unmapped_to_model(sol)
predicate = sol[:attributeProperty].to_s.to_sym
return unless @properties_to_include[predicate]
Expand Down

0 comments on commit 199f12e

Please sign in to comment.