Skip to content

Instantly share code, notes, and snippets.

View jcoyne's full-sized avatar

Justin Coyne jcoyne

  • Stanford University Libraries
  • Minneapolis, MN
View GitHub Profile
#!/usr/bin/env ruby
puts "Loading environment"
require File.expand_path('../../config/environment', __FILE__)
class Foo < ActiveFedora::Base
include ::CurationConcerns::WorkBehavior
property :depositor, predicate: ::RDF::DC.creator, multiple: false
end
i = Foo.create! { |f| f.apply_depositor_metadata 'jcoyne' }
class Foo < ActiveFedora::Base
property :title, predicate: ::RDF::DC.title
validates_presence_of :title
end
irb(main):006:0> f = Foo.new
=> #<Foo id: nil, title: []>
irb(main):007:0> f.valid?
=> false
irb(main):008:0> f.errors
query = "proxyIn_ssim:1n79h430f AND -next_ssim:[* TO *]"
results = ActiveFedora::SolrService.query(query)
ActiveFedora::SolrService.query(query).map { |res| res.slice('proxyIn_ssim', 'proxyFor_ssim', 'id') }
# => [{"proxyIn_ssim"=>["1n79h430f"], "proxyFor_ssim"=>["8w32r5659"], "id"=>"1n79h430f/members/37fe7adb-828e-4114-9c20-b71ae02efb6d"},
# {"proxyIn_ssim"=>["1n79h430f"], "proxyFor_ssim"=>["8w32r5659"], "id"=>"1n79h430f/members/07b0926e-97a8-456f-bf4d-4a926608de94"}]
query2 = "proxyIn_ssim:1n79h430f"
ActiveFedora::SolrService.count(query2)
#=> 642
@jcoyne
jcoyne / characterization.rb
Last active January 19, 2020 03:52
Test characterization hydra pcdm goldenseal curationexperts
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)
undefined method `pcdm_object?' for nil:NilClass
/opt/goldenseal/shared/bundle/ruby/2.2.0/bundler/gems/hydra-pcdm-463d73a2fd4b/lib/hydra/pcdm/models/concerns/object_behavior.rb:43:in `select'
/opt/goldenseal/shared/bundle/ruby/2.2.0/bundler/gems/hydra-pcdm-463d73a2fd4b/lib/hydra/pcdm/models/concerns/object_behavior.rb:43:in `in_objects'
/opt/goldenseal/shared/bundle/ruby/2.2.0/bundler/gems/curation_concerns-dd2881379fd2/curation_concerns-models/app/models/concerns/curation_concerns/file_set/belongs_to_works.rb:11:in `generic_works'
/opt/goldenseal/shared/bundle/ruby/2.2.0/bundler/gems/curation_concerns-dd2881379fd2/curation_concerns-models/app/models/concerns/curation_concerns/file_set/belongs_to_works.rb:16:in `generic_work_ids'
/opt/goldenseal/shared/bundle/ruby/2.2.0/bundler/gems/curation_concerns-dd2881379fd2/curation_concerns-models/app/indexers/curation_concerns/file_set_indexing_service.rb:16:in `block in generate_solr_document'
/opt/goldenseal/shared/bundle/ruby/2.2.0/bundler/gems/curation_concerns-dd
fs.height
=> ["381"]
irb(main):033:0> fs.save
=> true
irb(main):034:0> fs.reload
=> #<FileSet id: "jh343s34j", filename: "tmp/uploads/6d/56/zw/65/MS002.002.DO.04436.basic.jpg", format_label: [], file_size: [], well_formed: [], valid: [], date_created: [], last_modified: [], fits_version: [], exif_version: [], original_checksum: [], mime_type: "image/jpeg", byte_order: "big endian", compression: "JPEG (old-style)", height: [], width: [], color_space: "YCbCr", profile_name: [], profile_version: [], orientation: nil, color_map: [], image_producer: [], capture_device: [], scanning_software: [], gps_timestamp: [], latitude: [], longitude: [], bit_depth: [], channels: [], data_format: [], frame_rate: [], duration: [], sample_rate: [], file_title: [], file_author: [], page_count: [], file_language: [], word_count: [], character_count: [], line_count: [], character_set: [], markup_basis: [], markup_language: [], paragraph_count: [], table_count: [], graphics_count: [], label: "MS002.002.DO.04436.basic.jpg", depositor
<?xml version="1.0" encoding="UTF-8"?>
<fits xmlns="http://hul.harvard.edu/ois/xml/ns/fits/fits_output" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://hul.harvard.edu/ois/xml/ns/fits/fits_output http://hul.harvard.edu/ois/xml/xsd/fits/fits_output.xsd" version="0.6.2" timestamp="10/13/15 9:37 PM">
<identification>
<identity format="JPEG File Interchange Format" mimetype="image/jpeg" toolname="FITS" toolversion="0.6.2">
<tool toolname="Jhove" toolversion="1.5" />
<tool toolname="file utility" toolversion="5.11" />
<tool toolname="Exiftool" toolversion="9.06" />
<tool toolname="Droid" toolversion="3.0" />
<tool toolname="NLNZ Metadata Extractor" toolversion="3.4GA" />
<version toolname="Jhove" toolversion="1.5">1.02</version>
Hydra::Derivatives::PdfDerivatives.create(filename,
outputs: [{ label: :thumbnail, format: 'jpg', size: '338x493', url: derivative_url('thumbnail') }])
Hydra::Derivatives::FullTextExtract.create(filename,
outputs: [{ format: 'txt', url: derivative_url('fulltext') }])
curl -H "Accept: text/turtle" -I http://fedoraAdmin:fedoraAdmin@localhost:8983/fedora/rest/test/le/w1/87/3./lew1873.0001.003
HTTP/1.1 200 OK
ETag: "de69d091923361d932ea5ec5f24fd79757d89275"
Last-Modified: Mon, 28 Sep 2015 17:48:16 GMT
Link: <http://www.w3.org/ns/ldp#Resource>;rel="type"
Link: <http://www.w3.org/ns/ldp#Container>;rel="type"
Link: <http://www.w3.org/ns/ldp#BasicContainer>;rel="type"
Accept-Patch: application/sparql-update
Accept-Post: text/turtle,text/rdf+n3,text/n3,application/rdf+xml,application/n-triples,multipart/form-data,application/sparql-update
Allow: MOVE,COPY,DELETE,POST,HEAD,GET,PUT,PATCH,OPTIONS
@jcoyne
jcoyne / works.rb
Created September 17, 2015 17:00
class Book < ActiveFedora::Base
include Hydra::Works::Work
end
class Page < ActiveFedora::Base
include Hydra::Works::Work
end
book = Book.new
page = Page.new