app/models/labeling/skos/base.rb in iqvoc-4.1.2 vs app/models/labeling/skos/base.rb in iqvoc-4.1.3
- old
+ new
@@ -44,15 +44,16 @@
def self.single_query(params = {})
query_str = build_query_string(params)
scope = includes(:target).order("LOWER(#{Label::Base.table_name}.value)")
+ languages = Array(params[:languages])
if params[:query].present?
- scope = scope.merge(Label::Base.by_query_value(query_str).by_language(params[:languages].to_a).published)
+ scope = scope.merge(Label::Base.by_query_value(query_str).by_language(languages).published)
else
- scope = scope.merge(Label::Base.by_language(params[:languages].to_a).published)
+ scope = scope.merge(Label::Base.by_language(languages).published)
end
if params[:collection_origin].present?
collection = Collection::Base.where(:origin => params[:collection_origin]).last
if collection
@@ -64,19 +65,19 @@
end
scope = scope.includes(:owner)
scope = case params[:for]
when 'concept'
- scope.where('concepts.type' => Iqvoc::Concept.base_class_name).merge(Concept::Base.published)
+ scope.where('concepts.type' => Iqvoc::Concept.base_class_name)
when 'collection'
scope.where('concepts.type' => Iqvoc::Collection.base_class_name)
else
# no additional conditions
scope
end
- scope
+ scope.merge(Concept::Base.published)
end
def self.search_result_partial_name
'partials/labeling/skos/search_result'
end
@@ -84,10 +85,14 @@
def self.build_from_rdf(rdf_subject, rdf_predicate, rdf_object)
raise "#{self.name}#build_from_rdf: Subject (#{rdf_subject}) must be a Concept." unless rdf_subject.is_a?(Concept::Base)
raise "#{self.name}#build_from_rdf: Object (#{rdf_object}) must be a string literal" unless rdf_object =~ /^"(.+)"(@(.+))?$/
lang = $3
- value = JSON.parse(%Q{["#{$1}"]})[0].gsub("\\n", "\n") # Trick to decode \uHHHHH chars
+ value = begin
+ JSON.parse(%Q{["#{$1}"]})[0].gsub("\\n", "\n") # Trick to decode \uHHHHH chars
+ rescue JSON::ParserError
+ $1
+ end
predicate_class = Iqvoc::RDFAPI::PREDICATE_DICTIONARY[rdf_predicate] || self
predicate_class.new(:target => self.label_class.new(:value => value, :language => lang)).tap do |labeling|
rdf_subject.send(predicate_class.name.to_relation_name) << labeling
end