Sha256: 4588827d5e5e358f40b0d74639aa0b9fd7fe85719d56fa2bbacd3a9b86e39653

Contents?: true

Size: 1.26 KB

Versions: 63

Compression:

Stored size: 1.26 KB

Contents

module ActiveFedora
  module Associations
    class DirectlyContainsAssociation < ContainsAssociation #:nodoc:
      def insert_record(record, force = true, validate = true)
        container.save!
        super
      end

      def find_target
        query_node = if container_predicate = options[:has_member_relation]
                       owner
                     else
                       container_predicate = ::RDF::Vocab::LDP.contains
                       container
                     end

        uris = query_node.resource.query(predicate: container_predicate).map { |r| r.object.to_s }

        uris.map { |object_uri| klass.find(klass.uri_to_id(object_uri)) }
      end

      def container
        @container ||= begin
          DirectContainer.find_or_initialize(ActiveFedora::Base.uri_to_id(uri)).tap do |container|
            container.parent = @owner
            container.has_member_relation = Array(options[:has_member_relation])
            container.is_member_of_relation = Array(options[:is_member_of_relation])
          end
        end
      end

      protected

        def initialize_attributes(record) #:nodoc:
          record.uri = ActiveFedora::Base.id_to_uri(container.mint_id)
          set_inverse_instance(record)
        end
    end
  end
end

Version data entries

63 entries across 63 versions & 1 rubygems

Version Path
active-fedora-12.1.1 lib/active_fedora/associations/directly_contains_association.rb
active-fedora-12.1.0 lib/active_fedora/associations/directly_contains_association.rb
active-fedora-11.5.4 lib/active_fedora/associations/directly_contains_association.rb
active-fedora-11.5.3 lib/active_fedora/associations/directly_contains_association.rb
active-fedora-12.0.2 lib/active_fedora/associations/directly_contains_association.rb
active-fedora-12.0.1 lib/active_fedora/associations/directly_contains_association.rb
active-fedora-11.5.2 lib/active_fedora/associations/directly_contains_association.rb
active-fedora-12.0.0 lib/active_fedora/associations/directly_contains_association.rb
active-fedora-11.5.0 lib/active_fedora/associations/directly_contains_association.rb
active-fedora-11.4.1 lib/active_fedora/associations/directly_contains_association.rb
active-fedora-11.4.0 lib/active_fedora/associations/directly_contains_association.rb
active-fedora-11.3.1 lib/active_fedora/associations/directly_contains_association.rb
active-fedora-11.3.0 lib/active_fedora/associations/directly_contains_association.rb
active-fedora-11.2.0 lib/active_fedora/associations/directly_contains_association.rb
active-fedora-11.1.6 lib/active_fedora/associations/directly_contains_association.rb
active-fedora-11.1.5 lib/active_fedora/associations/directly_contains_association.rb
active-fedora-11.1.4 lib/active_fedora/associations/directly_contains_association.rb
active-fedora-11.1.3 lib/active_fedora/associations/directly_contains_association.rb
active-fedora-11.1.2 lib/active_fedora/associations/directly_contains_association.rb
active-fedora-11.1.1 lib/active_fedora/associations/directly_contains_association.rb