Module: ActiveFedora::FileManagement
- Extended by:
- ActiveSupport::Concern, Deprecation
- Defined in:
- lib/active_fedora/file_management.rb
Instance Method Summary collapse
-
#collection_members_append(obj) ⇒ ActiveFedora::Base
Add the given obj as a collection member to the current object using an outbound has_collection_member relationship.
- #collection_members_remove ⇒ Object
-
#file_objects(opts = {}) ⇒ Array of ActiveFedora objects, ...
List the objects that assert isPartOf pointing at this object plus all objects that this object asserts hasPart for Note: Previous versions of ActiveFedora used hasCollectionMember to represent this type of relationship.
-
#file_objects_append(obj) ⇒ Boolean
Add the given obj as a child to the current object using an inbound is_part_of relationship.
Instance Method Details
#collection_members_append(obj) ⇒ ActiveFedora::Base
Add the given obj as a collection member to the current object using an outbound has_collection_member relationship.
67 68 69 70 |
# File 'lib/active_fedora/file_management.rb', line 67 def collection_members_append(obj) add_relationship(:has_collection_member, obj) return self end |
#collection_members_remove ⇒ Object
72 73 74 |
# File 'lib/active_fedora/file_management.rb', line 72 def collection_members_remove() # will rely on SemanticNode.remove_relationship once it is implemented end |
#file_objects(opts = {}) ⇒ Array of ActiveFedora objects, ...
List the objects that assert isPartOf pointing at this object plus all objects that this object asserts hasPart for
Note: Previous versions of ActiveFedora used hasCollectionMember to represent this type of relationship.
To accommodate this, until active-fedora-1.3, .file_assets will also return anything that this asserts hasCollectionMember for and will output a warning in the logs.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/active_fedora/file_management.rb', line 22 def file_objects(opts={}) cm_array = collection_members(:response_format=>:id_array) if !cm_array.empty? logger.warn "This object has collection member assertions. hasCollectionMember will no longer be used to track file_object relationships after active_fedora 1.3. Use isPartOf assertions in the RELS-EXT of child objects instead." if opts[:response_format] == :solr || opts[:response_format] == :load_from_solr logger.warn ":solr and :load_from_solr response formats for file_objects search only uses parts relationships (usage of hasCollectionMember is no longer supported)" result = parts(opts) else cm_result = collection_members(opts) parts_result = parts(opts) ary = cm_result+parts_result result = ary.uniq end else result = parts(opts) end return result end |
#file_objects_append(obj) ⇒ Boolean
Add the given obj as a child to the current object using an inbound is_part_of relationship
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/active_fedora/file_management.rb', line 48 def file_objects_append(obj) # collection_members_append(obj) unless obj.kind_of? ActiveFedora::Base begin obj = ActiveFedora::Base.find(obj) rescue ActiveFedora::ObjectNotFoundError "You must provide either an ActiveFedora object or a valid pid to add it as a file object. You submitted #{obj.inspect}" end end obj.add_relationship(:is_part_of, self) obj.save end |