Sha256: 24d1684b860c2057ca314b6a60a61122367ef31f40edd62719c1bde43ca07dca

Contents?: true

Size: 1.12 KB

Versions: 22

Compression:

Stored size: 1.12 KB

Contents

require 'json'

module FcrepoAdmin
  module SolrDocumentExtension

    def object_profile
      @object_profile ||= JSON.parse(self[ActiveFedora::Base.profile_solr_name].first)
    end

    def datastreams
      object_profile["datastreams"]
    end
    
    def has_datastream?(dsID)
      !datastreams[dsID].blank?
    end

    def has_admin_policy?
      !admin_policy_uri.blank?
    end

    def admin_policy_uri
      get ActiveFedora::SolrService.solr_name('is_governed_by', :symbol)
    end

    def admin_policy_pid
      uri = admin_policy_uri
      uri &&= ActiveFedora::Base.pids_from_uris(uri)
    end

    def has_parent?
      !parent_uri
    end

    def parent_uri
      get(ActiveFedora::SolrService.solr_name('is_part_of', :symbol)) || get(ActiveFedora::SolrService.solr_name('is_member_of', :symbol)) || get(ActiveFedora::SolrService.solr_name('is_member_of_collection', :symbol))
    end

    def parent_pid
      uri = parent_uri
      uri &&= ActiveFedora::Base.pids_from_uris(uri)
    end

    def active_fedora_model
      get(ActiveFedora::SolrService.solr_name('active_fedora_model', :symbol))
    end
    
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
fcrepo_admin-0.1.1 lib/fcrepo_admin/solr_document_extension.rb
fcrepo_admin-0.1.0 lib/fcrepo_admin/solr_document_extension.rb