helpers/search_helper.rb
##
# Populate an array of classes. Returns a hash where the key is ontology_uri + class_id:
# "http://data.bioontology.org/ontologies/ONThttp://ont.org/class1" => cls
Populate an array of classes.
Populate an array of classes .
def populate_classes_from_search(classes, ontology_acronyms=nil)
        class_ids = []
        acronyms = (ontology_acronyms.nil?) ? [] : ontology_acronyms
        classes.each {|c| class_ids << c.id.to_s; acronyms << c.submission.ontology.acronym.to_s unless ontology_acronyms}
        acronyms.uniq!
        old_classes_hash = Hash[classes.map {|cls| [cls.submission.ontology.id.to_s + cls.id.to_s, cls]}]
        params = {"ontology_acronyms" => acronyms}
        get_term_search_query("avoid_search_mangling", params)
        params.delete("ontology_acronyms")
        params.delete("q")
        params["qf"] = "resource_id"
        params["fq"] << " AND #{get_quoted_field_query_param(class_ids, "OR", "resource_id")}"
        params["rows"] = 99999
        resp = LinkedData::Models::Class.search("*:*", params)
        classes_hash = {}
        resp["response"]["docs"].each do |doc|
          doc = doc.symbolize_keys
          resource_id = doc[:resource_id]
          doc.delete :resource_id
          doc[:id] = resource_id
          ontology_uri = doc[:ontologyId].sub(/\/submissions\/.*/, "")
          ont_uri_class_uri = ontology_uri + resource_id
          old_class = old_classes_hash[ont_uri_class_uri]
          next unless old_class
          doc[:submission] = old_class.submission
          doc[:properties] = MultiJson.load(doc.delete(:propertyRaw)) if include_param_contains?(:properties)
          instance = LinkedData::Models::Class.read_only(doc)
          classes_hash[ont_uri_class_uri] = instance
        end
        classes_hash
      end
def populate_classes_from_search ( classes , ontology_acronyms = nil ) class_ids = [ ] acronyms = ( ontology_acronyms . nil? ) ? [ ] : ontology_acronyms classes . each { | c | class_ids << c . id . to_s ; acronyms << c . submission . ontology . acronym . to_s unless ontology_acronyms } acronyms . uniq! old_classes_hash = Hash [ classes . map { | cls | [ cls . submission . ontology . id . to_s + cls . id . to_s , cls ] } ] params = { "ontology_acronyms" => acronyms } get_term_search_query ( "avoid_search_mangling" , params ) params . delete ( "ontology_acronyms" ) params . delete ( "q" ) params [ "qf" ] = "resource_id" params [ "fq" ] << " AND #{get_quoted_field_query_param(class_ids, "OR", "resource_id")}" params [ "rows" ] = 99999 resp = LinkedData :: Models :: Class . search ( "*:*" , params ) classes_hash = { } resp [ "response" ] [ "docs" ] . each do | doc | doc = doc . symbolize_keys resource_id = doc [ :resource_id ] doc . delete :resource_id doc [ :id ] = resource_id ontology_uri = doc [ :ontologyId ] . sub ( / \/ submissions \/ .* / , "" ) ont_uri_class_uri = ontology_uri + resource_id old_class = old_classes_hash [ ont_uri_class_uri ] next unless old_class doc [ :submission ] = old_class . submission doc [ :properties ] = MultiJson . load ( doc . delete ( :propertyRaw ) ) if include_param_contains? ( :properties ) instance = LinkedData :: Models :: Class . read_only ( doc ) classes_hash [ ont_uri_class_uri ] = instance end classes_hash end
Populate an array of classes.
Populate an array of classes .
# Use a fake phrase because we want a normal wildcard query, not the suggest. # Replace this with a wildcard below. # Replace fake query with wildcard
classes
<not_specific>
ontology_acronyms
<not_specific>