Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: projecthydra-deprecated/hypatia
base: 6b305928a9
...
head fork: projecthydra-deprecated/hypatia
compare: c5bb763473
Checking mergeability… Don't worry, you can still create the pull request.
  • 8 commits
  • 9 files changed
  • 0 commit comments
  • 1 contributor
View
8 app/models/hypatia_collection.rb
@@ -0,0 +1,8 @@
+# a Fedora object for the Hypatia SET hydra content type
+class HypatiaCollection < ActiveFedora::Base
+ has_metadata :name => "descMetadata", :type=> HypatiaSetDescMetadataDS
+ has_metadata :name => "rightsMetadata", :type => Hydra::RightsMetadata
+
+ has_relationship "members", :is_member_of, :inbound=>true
+ has_relationship "sets", :is_member_of, :type => HypatiaSet
+end
View
1  app/models/hypatia_disk_image_item.rb
@@ -5,4 +5,5 @@ class HypatiaDiskImageItem < ActiveFedora::Base
has_metadata :name => "rightsMetadata", :type => Hydra::RightsMetadata
has_bidirectional_relationship "part_of", :is_part_of, :has_part
has_bidirectional_relationship "sets", :is_member_of, :has_member
+ has_relationship "collections", :is_member_of_collection, :type => HypatiaCollection
end
View
2  app/models/hypatia_ftk_item.rb
@@ -4,6 +4,6 @@ class HypatiaFtkItem < ActiveFedora::Base
has_metadata :name => "contentMetadata", :type=> HypatiaItemContentMetadataDS
has_metadata :name => "rightsMetadata", :type => Hydra::RightsMetadata
has_relationship "sets", :is_member_of, :type => HypatiaSet
- has_relationship "collections", :is_member_of_collection, :type => HypatiaSet
+ has_relationship "collections", :is_member_of_collection, :type => HypatiaCollection
has_relationship "parts", :is_part_of, :inbound => true
end
View
2  fedora/conf/fedora.fcfg
@@ -350,7 +350,7 @@
</module>
<module role="org.fcrepo.server.resourceIndex.ResourceIndex" class="org.fcrepo.server.resourceIndex.ResourceIndexModule">
<comment>Supports the ResourceIndex.</comment>
- <param name="level" value="0">
+ <param name="level" value="1">
<comment>(required)
Index level. Currently, only 0, and 1 are supported levels.
0 = off and 1 = on.
View
18 lib/ftk_disk_image_item_assembler.rb
@@ -6,6 +6,7 @@ class FtkDiskImageItemAssembler
attr_accessor :disk_image_files_dir # The directory containing the disk images
attr_accessor :computer_media_photos_dir # The directory containing photos of the physical media (e.g., floppy disks)
attr_reader :filehash # The hash were we store the files we're processing
+ attr_accessor :collection_pid # What collection are these files part of?
def initialize(args)
@logger = Logger.new('log/ftk_disk_image_item_assembler.log')
@@ -15,6 +16,8 @@ def initialize(args)
@disk_image_files_dir = args[:disk_image_files_dir]
raise "Can't find directory #{args[:computer_media_photos_dir]}" unless File.directory? args[:computer_media_photos_dir]
@computer_media_photos_dir = args[:computer_media_photos_dir]
+ @collection_pid = args[:collection_pid]
+
@filehash = {}
build_file_hash
end
@@ -41,10 +44,9 @@ def process
# Sometimes we don't have a .txt file describing a disk, and we have to
# extrapolate the disk number from the filepath
# @param [String] filepath
- # @return [String] disk_number
- # @example
+ # @return [String] disk_number
def get_disk_number(filepath)
-
+ # not written yet
end
# Read in all the files in @disk_image_files_dir.
@@ -147,6 +149,7 @@ def buildRightsMetadata
def build_object(fdi)
hypatia_disk_image_item = HypatiaDiskImageItem.new
hypatia_disk_image_item.label="#{fdi.disk_type} #{fdi.disk_number}"
+ hypatia_disk_image_item.add_relationship(:is_member_of_collection,@collection_pid)
hypatia_disk_image_item.save
dd_file = create_dd_file_asset(hypatia_disk_image_item,fdi)
build_ng_xml_datastream(hypatia_disk_image_item, "descMetadata", buildDescMetadata(fdi))
@@ -164,8 +167,13 @@ def create_dd_file_asset(hypatia_disk_image_item,fdi)
dd_file = FileAsset.new
dd_file.label="fileAsset for FTK disk image #{fdi.disk_type} #{fdi.disk_number}"
dd_file.add_relationship(:is_part_of,hypatia_disk_image_item)
- file = File.new(@filehash[fdi.disk_number.to_sym][:dd])
- dd_file.add_file_datastream(file, {:dsid => "content", :label => "Disk image file for #{fdi.disk_type} #{fdi.disk_number}"})
+
+ # For now, only add the dd file for the Xanadu collection
+ if @collection_pid =~ /xanadu/
+ file = File.new(@filehash[fdi.disk_number.to_sym][:dd])
+ dd_file.add_file_datastream(file, {:dsid => "content", :label => "Disk image file for #{fdi.disk_type} #{fdi.disk_number}"})
+ end
+
add_photos_to_dd_file_asset(dd_file,fdi)
dd_file.save
return dd_file
View
130 lib/tasks/ftk_item_builder_unoptimized.rake
@@ -11,65 +11,111 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "/../../vendor/plugins/hydr
GIT_RESET_WAIT = 7
namespace :hypatia do
+
namespace :load do
+
+ ##########################
+ # Gould collection loading
+ ##########################
namespace :gould do
+ gould_collection_pid = "hypatia:gould_collection"
+
+ desc "Load all Gould data"
+ task :all do
+ Rake::Task["hypatia:load:gould:ftk_disk_items"].invoke
+ Rake::Task["hypatia:load:gould:ftk_file_items"].invoke
+ end
+
+ desc "Build disk objects (do this first)"
+ task :ftk_disk_items do
+ disk_image_files_dir = "/data_raw/Stanford/M1437\ Gould/Disk\ Image"
+ computer_media_photos_dir = "/data_raw/Stanford/M1437\ Gould/Computer\ Media\ Photo"
+ assembler = FtkDiskImageItemAssembler.new(:collection_pid => gould_collection_pid, :disk_image_files_dir => disk_image_files_dir, :computer_media_photos_dir => computer_media_photos_dir)
+ assembler.process
+ end
desc "Build ftk objects"
- task :build_ftk_file_items do
- collection_pid = "hypatia:gould_collection"
- f = FtkItemAssembler.new(:collection_pid => collection_pid)
- gould_report = "/usr/local/projects/hypatia_data/Stanford/M1437\ Gould/FTK\ xml/Report.xml"
- file_dir = "/usr/local/projects/hypatia_data/Stanford/M1437\ Gould/FTK\ xml/"
- display_derivative_dir = "/usr/local/projects/hypatia_data/Stanford/M1437\ Gould/Display\ Derivatives"
+ task :ftk_file_items do
+ f = FtkItemAssembler.new(:collection_pid => gould_collection_pid)
+ gould_report = "/data_raw/Stanford/M1437\ Gould/FTK\ xml/Report.xml"
+ file_dir = "/data_raw/Stanford/M1437\ Gould/FTK\ xml/"
+ display_derivative_dir = "/data_raw/Stanford/M1437\ Gould/Display\ Derivatives"
f.process(gould_report,file_dir,display_derivative_dir)
end
- # desc "Build disk objects (do this first)"
- # task :build_ftk_disk_items do
- # disk_image_files_dir = "/usr/local/projects/hypatia_data/Stanford/M1437\ Gould/Disk\ Image"
- # computer_media_photos_dir = "/usr/local/projects/hypatia_data/Stanford/M1437\ Gould/Computer\ Media\ Photo"
- # assembler = FtkDiskImageItemAssembler.new(:disk_image_files_dir => disk_image_files_dir, :computer_media_photos_dir => computer_media_photos_dir)
- # assembler.process
- # end
end
+ ###########################
+ # Xanadu collection loading
+ ###########################
namespace :xanadu do
- desc "Build Xanadu disk objects"
- task :ftk_disk_items do
- disk_image_files_dir = "/usr/local/projects/hypatia_data/Stanford/M1292\ Xanadu/Disk\ Image"
- computer_media_photos_dir = "/usr/local/projects/hypatia_data/Stanford/M1292\ Xanadu/Computer\ Media\ Photo"
- assembler = FtkDiskImageItemAssembler.new(:disk_image_files_dir => disk_image_files_dir, :computer_media_photos_dir => computer_media_photos_dir)
- assembler.process
- end
+ xanadu_collection_pid = "hypatia:xanadu_collection"
+
+ desc "Load all Xanadu data"
+ task :all do
+ Rake::Task["hypatia:load:xanadu:ftk_disk_items"].invoke
+ end
+
+ desc "Build Xanadu disk objects"
+ task :ftk_disk_items do
+ disk_image_files_dir = "/data_raw/Stanford/M1292\ Xanadu/Disk\ Image"
+ computer_media_photos_dir = "/data_raw/Stanford/M1292\ Xanadu/Computer\ Media\ Photo"
+ assembler = FtkDiskImageItemAssembler.new(:collection_pid => xanadu_collection_pid, :disk_image_files_dir => disk_image_files_dir, :computer_media_photos_dir => computer_media_photos_dir)
+ assembler.process
+ end
end
+
+ ###########################
+ # Cheuse collection loading
+ ###########################
namespace :cheuse do
- # desc "Build disk objects (do this first)"
- # task :build_ftk_disk_items do
- # disk_image_files_dir = "/usr/local/projects/hypatia_data/Virginia/cheuse/oldFiles/diskImages"
- # computer_media_photos_dir = "/usr/local/projects/hypatia_data/Virginia/cheuse/oldFiles/photos"
- # assembler = FtkDiskImageItemAssembler.new(:disk_image_files_dir => disk_image_files_dir, :computer_media_photos_dir => computer_media_photos_dir)
- # assembler.process
- # end
+
+ cheuse_collection_pid = "hypatia:cheuse_collection"
+
+ desc "Load all Cheuse data"
+ task :all do
+ Rake::Task["hypatia:load:cheuse:ftk_disk_items"].invoke
+ Rake::Task["hypatia:load:cheuse:ftk_file_items"].invoke
+ end
+
+ desc "Build disk objects (do this first)"
+ task :ftk_disk_items do
+ disk_image_files_dir = "/data_raw/Virginia/cheuse/oldFiles/diskImages"
+ computer_media_photos_dir = "/data_raw/Virginia/cheuse/oldFiles/photos"
+ assembler = FtkDiskImageItemAssembler.new(:collection_pid => cheuse_collection_pid, :disk_image_files_dir => disk_image_files_dir, :computer_media_photos_dir => computer_media_photos_dir)
+ assembler.process
+ end
desc "Build Cheuse ftk file objects"
task :ftk_file_items do
- collection_pid = "hypatia:cheuse_collection"
- f = FtkItemAssembler.new(:collection_pid => collection_pid)
- report = "/usr/local/projects/hypatia_data/Virginia/cheuse/CheuseFTKReport/Report.xml"
- file_dir = "/usr/local/projects/hypatia_data/Virginia/cheuse/CheuseFTKReport"
+ f = FtkItemAssembler.new(:collection_pid => cheuse_collection_pid)
+ report = "/data_raw/Virginia/cheuse/CheuseFTKReport/Report.xml"
+ file_dir = "/data_raw/Virginia/cheuse/CheuseFTKReport"
f.process(report,file_dir)
end
end
+
+ ############################
+ # Creeley collection loading
+ ############################
namespace :creeley do
- # desc "Build disk objects (do this first)"
- # task :build_ftk_disk_items do
- # disk_image_files_dir = "/data_raw/Stanford/M0662\ Creeley/Disk\ Image/"
- # computer_media_photos_dir = "/data_raw/Stanford/M0662\ Creeley/Computer\ Media\ Photo"
- # assembler = FtkDiskImageItemAssembler.new(:disk_image_files_dir => disk_image_files_dir, :computer_media_photos_dir => computer_media_photos_dir)
- # assembler.process
- # end
+
+ creeley_collection_pid = "hypatia:creeley_collection"
+
+ desc "Load all Creeley data"
+ task :all do
+ Rake::Task["hypatia:load:creeley:ftk_disk_items"].invoke
+ Rake::Task["hypatia:load:creeley:ftk_file_items"].invoke
+ end
+
+ desc "Build disk objects (do this first)"
+ task :ftk_disk_items do
+ disk_image_files_dir = "/data_raw/Stanford/M0662\ Creeley/Disk\ Image/"
+ computer_media_photos_dir = "/data_raw/Stanford/M0662\ Creeley/Computer\ Media\ Photo"
+ assembler = FtkDiskImageItemAssembler.new(:collection_pid => creeley_collection_pid, :disk_image_files_dir => disk_image_files_dir, :computer_media_photos_dir => computer_media_photos_dir)
+ assembler.process
+ end
desc "Build Creeley ftk file objects"
task :ftk_file_items do
- collection_pid = "hypatia:creeley_collection"
- f = FtkItemAssembler.new(:collection_pid => collection_pid)
+ f = FtkItemAssembler.new(:collection_pid => creeley_collection_pid)
report = "/data_raw/Stanford/M0662\ Creeley/FTK\ xml/Report.xml"
file_dir = "/data_raw/Stanford/M0662\ Creeley/FTK\ xml/files/"
display_derivative_dir = "/data_raw/Stanford/M0662\ Creeley/Display\ Derivatives/"
@@ -77,6 +123,4 @@ namespace :hypatia do
end
end
end
-end
-
-# copy down the data from sul-brick & point this task at it
+end
View
22 spec/lib/ftk_disk_image_item_assembler_spec.rb
@@ -4,13 +4,22 @@
describe FtkDiskImageItemAssembler do
context "basic behavior" do
before(:all) do
+ delete_fixture("hypatia:fixture_xanadu_collection")
+ import_fixture("hypatia:fixture_xanadu_collection")
+ @collection_pid = "hypatia:fixture_xanadu_collection"
@disk_image_files_dir = File.join(File.dirname(__FILE__), "/../fixtures/ftk/disk_images")
@computer_media_photos_dir = File.join(File.dirname(__FILE__), "/../fixtures/ftk/computer_media_photos")
- @foo = FtkDiskImageItemAssembler.new(:disk_image_files_dir => @disk_image_files_dir, :computer_media_photos_dir => @computer_media_photos_dir)
+ @foo = FtkDiskImageItemAssembler.new(:collection_pid => @collection_pid,:disk_image_files_dir => @disk_image_files_dir, :computer_media_photos_dir => @computer_media_photos_dir)
+ end
+ after(:all) do
+ delete_fixture("hypatia:fixture_xanadu_collection")
end
it "has a source of disk image files" do
@foo.disk_image_files_dir.should eql(@disk_image_files_dir)
end
+ it "knows what collection the objects belong to" do
+ @foo.collection_pid.should eql(@collection_pid)
+ end
it "has a source of computer media photos" do
@foo.computer_media_photos_dir.should eql(@computer_media_photos_dir)
end
@@ -55,21 +64,28 @@
end
context "building an object" do
before(:all) do
+ delete_fixture("hypatia:fixture_xanadu_collection")
+ import_fixture("hypatia:fixture_xanadu_collection")
+ @collection_pid = "hypatia:fixture_xanadu_collection"
@disk_image_files_dir = File.join(File.dirname(__FILE__), "/../fixtures/ftk/disk_images")
@computer_media_photos_dir = File.join(File.dirname(__FILE__), "/../fixtures/ftk/computer_media_photos")
@txt_file = File.join(@disk_image_files_dir, "/CM5551212.001.txt")
- @assembler = FtkDiskImageItemAssembler.new(:disk_image_files_dir => @disk_image_files_dir, :computer_media_photos_dir => @computer_media_photos_dir)
+ @assembler = FtkDiskImageItemAssembler.new(:collection_pid => @collection_pid, :disk_image_files_dir => @disk_image_files_dir, :computer_media_photos_dir => @computer_media_photos_dir)
@fdi = FtkDiskImage.new(:txt_file => @txt_file)
@item = @assembler.build_object(@fdi)
end
after(:all) do
+ delete_fixture("hypatia:fixture_xanadu_collection")
@item.parts.first.delete
@item.delete
end
it "builds an object" do
@item.should be_kind_of(HypatiaDiskImageItem)
end
- it "has a FileAsset" do
+ it "the object has an isMemberOfCollection relationship with the collection object" do
+ @item.relationships[:self][:is_member_of_collection].first.gsub("info:fedora/",'').should eql(@assembler.collection_pid)
+ end
+ it "the object has a FileAsset" do
@item.parts.first.should be_kind_of(FileAsset)
end
it "has a binary disk image attached to the FileAsset" do
View
25 spec/lib/ftk_item_assembler_spec.rb
@@ -223,29 +223,4 @@ def clean_fixture_disk_objects
solr_response.docs.each do |doc|
ActiveFedora::Base.load_instance(doc[:id]).delete
end
-end
-
-# import a fixture
-def import_fixture(pid)
- filename = File.join(File.dirname(__FILE__), "/../fixtures/#{pid.gsub(":","_")}.foxml.xml")
- file = File.new(filename, "r")
- result = Fedora::Repository.instance.ingest(file.read)
- if result
- if !pid.nil?
- solrizer = Solrizer::Fedora::Solrizer.new
- solrizer.solrize(pid)
- end
- else
- raise "Failed to ingest the fixture."
- end
-end
-
-# delete a fixture
-def delete_fixture(pid)
- begin
- ActiveFedora::Base.load_instance(pid).delete
- rescue ActiveFedora::ObjectNotFoundError
- rescue Errno::ECONNREFUSED => e
- raise "Can't connect to Fedora! Are you sure jetty is running?"
- end
end
View
25 spec/spec_helper.rb
@@ -87,4 +87,29 @@ def active_fedora_fixture(file)
File.new(File.join(File.dirname(__FILE__), 'fixtures', file))
end
+ # import a fixture
+ def import_fixture(pid)
+ filename = File.join(File.dirname(__FILE__), "/fixtures/#{pid.gsub(":","_")}.foxml.xml")
+ file = File.new(filename, "r")
+ result = Fedora::Repository.instance.ingest(file.read)
+ if result
+ if !pid.nil?
+ solrizer = Solrizer::Fedora::Solrizer.new
+ solrizer.solrize(pid)
+ end
+ else
+ raise "Failed to ingest the fixture."
+ end
+ end
+
+ # delete a fixture
+ def delete_fixture(pid)
+ begin
+ ActiveFedora::Base.load_instance(pid).delete
+ rescue ActiveFedora::ObjectNotFoundError
+ rescue Errno::ECONNREFUSED => e
+ raise "Can't connect to Fedora! Are you sure jetty is running?"
+ end
+ end
+
end

No commit comments for this range

Something went wrong with that request. Please try again.