-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ability to download and import data sets via seeds
- Loading branch information
1 parent
f0f05fc
commit 569595d
Showing
5 changed files
with
77 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env ruby | ||
|
||
# ./bin/export_from_fedora NAME SOURCE_URL | ||
# This exports straight from Fedora in the format expected for import_from_fedora | ||
# It is meant to copy FCREPO from one Samvera app to another | ||
# NAME should be the name of the account | ||
# SOURCE_URL should be a full fedora repo path such as | ||
# http://fcrepo:8080/fcrepo/rest/ea85bcf6-b590-4d40-9541-d15134cb2694 | ||
|
||
|
||
def run(cmd) | ||
puts cmd | ||
system(cmd, out: $stdout, err: $stderr) | ||
end | ||
|
||
name = ARGV[0] | ||
source_url = ARGV[1] | ||
basename = File.basename(source_url) | ||
|
||
cmd = "java -jar fcrepo-import-export-0.3.0.jar --mode export --resource #{source_url} --dir ./hyrax-webapp/tmp/export --binaries" | ||
run cmd | ||
|
||
cmd = "tar zcfv data/#{name}~#{basename}.tgz tmp/export" | ||
run cmd |
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,10 @@ | ||
#!/usr/bin/env ruby | ||
%x{git fetch -ap} | ||
branches = %x{git branch --merged main}.split("\n").collect {|b| b.gsub('*', '').strip} | ||
|
||
branches -= ['main'] | ||
|
||
puts branches.inspect | ||
branches.each do |branch| | ||
puts %x{git branch -d #{branch}} | ||
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,33 @@ | ||
#!/usr/bin/env ruby | ||
|
||
# ./bin/import_from_fedora FILE_PATH DESTINATION_URL | ||
# This imports straight in to Fedora and then performes a complete reindex. | ||
# It is meant to copy FCREPO from one Samvera app to another | ||
# FILE_PATH = the path to a properly formated tgz. Currently files in data must | ||
# extract to tmp/export and must be of sourced from fcrepo:8080/fcrepo/rest/FILENAME | ||
# DESINTATION_URL should be a full fedora repo path such as | ||
# http://fcrepo:8080/rest/ea85bcf6-b590-4d40-9541-d15134cb2694 | ||
|
||
|
||
def run(cmd) | ||
puts cmd | ||
system(cmd, out: $stdout, err: $stderr) | ||
end | ||
|
||
|
||
file = ARGV[0] | ||
source_name, source_basename = File.basename(file).delete('.tgz').split("~") | ||
destination_url = ARGV[1] | ||
source_url = "http://fcrepo:8080/fcrepo/rest/#{source_basename}" | ||
|
||
cmd = "wget https://github.com/fcrepo-exts/fcrepo-import-export/releases/download/fcrepo-import-export-0.3.0/fcrepo-import-export-0.3.0.jar" | ||
run cmd | ||
|
||
cmd = "tar zxfv #{file}" | ||
run cmd | ||
|
||
cmd = "java -jar fcrepo-import-export-0.3.0.jar --mode import --resource #{destination_url} --dir ./tmp/export --binaries --map #{source_url},#{destination_url} --legacyMode" | ||
run cmd | ||
|
||
cmd = %Q{bundle exec rails runner 'Apartment::Tenant.switch!(Account.find_by(name: "#{name}").tenant); ActiveFedora::Base.reindex_everything'} | ||
run cmd |
Empty file.
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