Class: Bplmodels::RelationBase
- Inherits:
-
ActiveFedora::Base
- Object
- ActiveFedora::Base
- Bplmodels::RelationBase
- Includes:
- ActiveFedora::Auditable, Hydra::AccessControls::Permissions, Hydra::ModelMethods
- Defined in:
- app/models/bplmodels/relation_base.rb
Direct Known Subclasses
Instance Method Summary collapse
- #apply_default_permissions ⇒ Object
-
#assert_content_model ⇒ Object
def save super() end.
-
#convert_to(klass) ⇒ Object
Rough initial attempt at this implementation use test2.relationships(:has_model)?.
- #to_solr(doc = {}) ⇒ Object
Instance Method Details
#apply_default_permissions ⇒ Object
37 38 39 40 |
# File 'app/models/bplmodels/relation_base.rb', line 37 def self.datastreams["rightsMetadata"].( "group"=>{"Repository Administrators"=>"edit"} ) self.save end |
#assert_content_model ⇒ Object
def save
super()
end
71 72 73 74 75 76 77 78 |
# File 'app/models/bplmodels/relation_base.rb', line 71 def assert_content_model super() object_superclass = self.class.superclass until object_superclass == ActiveFedora::Base || object_superclass == Object do add_relationship(:has_model, object_superclass.to_class_uri) object_superclass = object_superclass.superclass end end |
#convert_to(klass) ⇒ Object
Rough initial attempt at this implementation use test2.relationships(:has_model)?
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'app/models/bplmodels/relation_base.rb', line 82 def convert_to(klass) #if !self.instance_of?(klass) adapted_object = self.adapt_to(klass) self.relationships.each_statement do |statement| if statement.predicate == "info:fedora/fedora-system:def/model#hasModel" self.remove_relationship(:has_model, statement.object) end end adapted_object.assert_content_model adapted_object.save #end end |
#to_solr(doc = {}) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/models/bplmodels/relation_base.rb', line 42 def to_solr(doc = {} ) doc = super(doc) doc['label_ssim'] = self.label #FIXME if self.class.to_s == 'Bplmodels::Institution' || self.class.to_s == 'Bplmodels::Collection' doc['active_fedora_model_suffix_ssi'] = self.class.to_s.gsub(/\A[\w]*::/,'') else doc['active_fedora_model_suffix_ssi'] = self.class.superclass.to_s.gsub(/\A[\w]*::/,'') end # title fields title_prefix = self.descMetadata.mods(0).title_info(0).nonSort[0].presence || '' main_title = self.descMetadata.mods(0).title_info(0).main_title[0] doc['title_info_primary_tsi'] = title_prefix + main_title doc['title_info_primary_ssort'] = main_title if self.workflowMetadata doc['workflow_state_ssi'] = self.workflowMetadata.item_status.state end puts self.pid doc end |