-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added missing method for BagIt parser (#516)
* added missing method for BagIt parser * added a conditional for rdf entries * WIP bagit rdfentry
- Loading branch information
Showing
4 changed files
with
45 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
module Bulkrax | ||
class RdfFileSetEntry < RdfEntry | ||
include FileSetEntryBehavior | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# frozen_string_literal: true | ||
|
||
module Bulkrax | ||
module FileSetEntryBehavior | ||
def factory_class | ||
::FileSet | ||
end | ||
|
||
def add_path_to_file | ||
parsed_metadata['file'].each_with_index do |filename, i| | ||
path_to_file = ::File.join(parser.path_to_files, filename) | ||
|
||
parsed_metadata['file'][i] = path_to_file | ||
end | ||
raise ::StandardError, "one or more file paths are invalid: #{parsed_metadata['file'].join(', ')}" unless parsed_metadata['file'].map { |file_path| ::File.file?(file_path) }.all? | ||
|
||
parsed_metadata['file'] | ||
end | ||
|
||
def validate_presence_of_filename! | ||
return if parsed_metadata&.[]('file')&.map(&:present?)&.any? | ||
|
||
raise StandardError, 'File set must have a filename' | ||
end | ||
|
||
def validate_presence_of_parent! | ||
return if parsed_metadata[related_parents_parsed_mapping]&.map(&:present?)&.any? | ||
|
||
raise StandardError, 'File set must be related to at least one work' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters