Module: ActiveFedora::Rdf::Indexing

Extended by:
ActiveSupport::Concern, Deprecation
Included in:
ActiveFedora::RDFDatastream
Defined in:
lib/active_fedora/rdf/indexing.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#apply_prefix(name) ⇒ Object

In active_fedora 8, we can get the prefix part from Datastream.prefix



8
9
10
# File 'lib/active_fedora/rdf/indexing.rb', line 8

def apply_prefix(name)
  "#{dsid.underscore}__#{name}"
end

#prefix(name) ⇒ Object



12
13
14
15
# File 'lib/active_fedora/rdf/indexing.rb', line 12

def prefix(name)
  Deprecation.warn Indexing, "prefix is deprecated. Use apply_prefix instead. In active-fedora 8, the prefix method will just return the prefix to be applied, and will not do the applying.  This will enable conformity between OmDatastream and RdfDatastream"
  apply_prefix(name)
end

#primary_solr_name(field) ⇒ Object

Gives the primary solr name for a column. If there is more than one indexer on the field definition, it gives the first



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/active_fedora/rdf/indexing.rb', line 33

def primary_solr_name(field)
  config = self.class.config_for_term_or_uri(field)
  return nil unless config # punt on index names for deep nodes!
  if behaviors = config.behaviors
    behaviors.each do |behavior|
      result = ActiveFedora::SolrService.solr_name(apply_prefix(field), behavior, type: config.type)
      return result if Solrizer::DefaultDescriptors.send(behavior).evaluate_suffix(:text).stored?
    end
    raise RuntimeError "no stored fields were found"
  end
end

#to_solr(solr_doc = Hash.new) ⇒ Object

:nodoc:



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/active_fedora/rdf/indexing.rb', line 17

def to_solr(solr_doc = Hash.new) # :nodoc:
  fields.each do |field_key, field_info|
    values = resource.get_values(field_key)
    Array(values).each do |val|
      if val.kind_of? RDF::URI
        val = val.to_s 
      elsif val.kind_of? ActiveTriples::Resource
        val = val.solrize
      end
      self.class.create_and_insert_terms(apply_prefix(field_key), val, field_info[:behaviors], solr_doc)
    end
  end
  solr_doc
end