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
user = User.find_by(:email => "depositor@wpi.edu") | |
options = { title: 'Nestable Collection', description: 'Sample collection type that allows nesting of collections.', nestable: true, discoverable: true, sharable: true, allow_multiple_membership: true, require_membership: true } | |
def create_collection_type(machine_id, options) | |
coltype = Hyrax::CollectionType.find_by_machine_id(machine_id) | |
return coltype if coltype.present? | |
default_options = { | |
nestable: false, discoverable: false, sharable: false, allow_multiple_membership: false, | |
require_membership: false, assigns_workflow: false, assigns_visibility: false, | |
participants: [{ agent_type: Hyrax::CollectionTypeParticipant::GROUP_TYPE, agent_id: ::Ability.admin_group_name, access: Hyrax::CollectionTypeParticipant::MANAGE_ACCESS }, | |
{ agent_type: Hyrax::CollectionTypeParticipant::GROUP_TYPE, agent_id: ::Ability.registered_group_name, access: Hyrax::CollectionTypeParticipant::CREATE_ACCESS }] |
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
gf = GenericFile.find("abc123") | |
file = File.open("file name") | |
content = file.read | |
gf.content.content = content | |
gf.create_derivatives | |
gf.visibility = "open" | |
gf.save |
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
# Checks the shasum of each version and current content in old production | |
# and compares it to those in new production. | |
# | |
# To run the report, go to the Rails console and copy-in the two classes in the file. | |
# Then run: | |
# | |
# > report = ChecksumReport.new | |
# | |
# The report is an array of hashes, each of which looks like: | |
# |
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
c = Collection.find('d504rk335') | |
work_ids = [] | |
c.member_objects.each do |member| | |
work_ids << member.id | |
end | |
new_edit_users = ["user1@example.com", "user2@example.com"] | |
def change_edit_users(work_ids, new_edit_users) | |
work_ids.each do |pid| |
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
# Inspired by https://gist.github.com/3166610 | |
require 'google/api_client' | |
require 'date' | |
API_VERSION = 'v3' | |
CACHED_API_FILE = "analytics-#{API_VERSION}.cache" | |
# Update these to match your own apps credentials | |
service_account_email = 'foobar@developer.gserviceaccount.com' # Email of service account | |
key_file = '/tmp/foobar-privatekey.p12' # File containing your private key |
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
2.2.1 :003 > ActiveFedora::Noid::Service.new.mint | |
seed is 271030524290525531404955989783767342781 | |
counters size is 293 | |
@rand.rand(counters.size) is 261 | |
counters[261] is {:value=>6300353125, :max=>6324492408} | |
counters[261][:value] is 6300353125 | |
counters[261][:value] is now 6300353126 | |
=> "vt150j25g" | |
2.2.1 :004 > ActiveFedora::Noid::Service.new.mint | |
seed is 271030524290525531404955989783767342781 |
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
class Book < ActiveFedora::Base | |
include Hydra::Works::Work | |
end | |
class Page < ActiveFedora::Base | |
include Hydra::Works::Work | |
end | |
book = Book.new | |
page = Page.new |
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
fs = FileSet.find('mp48sc83h') | |
file_name = 'tmp/uploads/mp/48/sc/83/letz_01_0020_019.tif' | |
service = Hydra::Works::CharacterizationService.new(fs, file_name, {}) | |
fits_output = service.send(:extract_metadata, file_name) | |
terms = service.send(:parse_metadata, fits_output) |
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
irb(main):006:0> local_file = File.open('spec/fixtures/images/world.png') => #<File:spec/fixtures/images/world.png> | |
irb(main):007:0> local_file = Hydra::Derivatives::IoDecorator.new(local_file) | |
=> #<File:spec/fixtures/images/world.png> | |
irb(main):008:0> local_file.mime_type = 'application/foo' | |
=> "application/foo" | |
irb(main):009:0> local_file.original_name = 'world.png' | |
=> "world.png" | |
irb(main):010:0> Hydra::Works::AddFileToFileSet.call(fs, local_file, :original_file, versioning: false) | |
Unable to check /var/folders/9t/rygbnddx0b1ckw6tjs3m18qm0000gq/T/20160531-85153-cfleh6 for viruses because no virus scanner is defined | |
=> #<FileSet id: "ww72bb63r", label: nil, relative_path: nil, import_url: nil, part_of: [], resource_type: [], creator: [], contributor: [], description: [], keyword: [], rights: [], publisher: [], date_created: [], subject: [], language: [], identifier: [], based_near: [], related_url: [], bibliographic_citation: [], source: [], head: [], tail: [], depositor: "jcoyne", title: [], date_uploaded: |
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
worktype = Etd | |
all_specified_works = worktype.where({:resource_type => 'thesis'}) #the select is something like '{:resource_type => "thesis"}' | |
col = Collection.find('gps') | |
col.reindex_extent = Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX | |
all_specified_works.each do |work| | |
if work.member_of_collections.empty? | |
work.member_of_collections += [col] | |
end | |
year = work.date_created[0].split("-")[0] | |
if not work.year.present? |
NewerOlder