module Hydra::Works # This module provides all of the Behaviors of a Hydra::Works::GenericFile # # behavior: # 1) Hydra::Works::FileSet can contain (pcdm:hasFile) Hydra::PCDM::File (inherits from Hydra::PCDM::Object) # 2) Hydra::Works::FileSet can contain (pcdm:hasRelatedFile) Hydra::PCDM::File (inherits from Hydra::PCDM::Object) # 3) Hydra::Works::FileSet can aggregate (pcdm:hasMember) Hydra::Works::FileSet # 4) Hydra::Works::FileSet can NOT aggregate anything other than Hydra::Works::FileSets # 5) Hydra::Works::FileSet can have descriptive metadata # 6) Hydra::Works::FileSet can have access metadata module FileSetBehavior extend ActiveSupport::Concern include Hydra::PCDM::ObjectBehavior included do type [Hydra::PCDM::Vocab::PCDMTerms.Object, Vocab::WorksTerms.FileSet] include Hydra::Works::ContainedFiles include Hydra::Works::Derivatives include Hydra::Works::MimeTypes include Hydra::Works::VersionedContent before_destroy :remove_from_works end # @return [Boolean] whether this instance is a Hydra::Works Collection. def collection? false end # @return [Boolean] whether this instance is a Hydra::Works Generic Work. def work? false end # @return [Boolean] whether this instance is a Hydra::Works::FileSet. def file_set? true end def in_works ordered_by.select { |parent| parent.class.included_modules.include?(Hydra::Works::WorkBehavior) }.to_a end private def remove_from_works in_works.each do |parent| parent.ordered_members.delete(self) # Delete the list node parent.members.delete(self) # Delete the indirect container Proxy parent.save! # record the changes to the ordered members end end end end