Skip to content

Instantly share code, notes, and snippets.

@jendiamond
Last active September 11, 2019 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jendiamond/dc2a4b74495279de4f95619d045676e6 to your computer and use it in GitHub Desktop.
Save jendiamond/dc2a4b74495279de4f95619d045676e6 to your computer and use it in GitHub Desktop.

DAY 3

Add Metadata to search results and facets

  1. Write a high level feature test first but don't make any changes so it still passes. (write a behavior that already exists

Continent
GIS data


Samvera Camp

DAY 1 | DAY 2 |

LESSONS

  • Hyrax Stack Walkthrough
  • RailsBridge Intro To Rails
  • Run Test Suite
  • New Metadata Field
  • Add Field to Views & Index
  • Search & Browse a Field
  • Collaborative Development
  • Team Development

REFERENCE

  • Preparation & Logistics
  • Common Tasks
  • Daily Standup
  • Building from Scratch
  • Additional Resources
  • Building from Scratch

Day One Morning - MONDAY

Initial Docker Setup Hyrax Stack Walkthrough

Day One Afternoon

RailsBridge Intro To Rails

$ docker-comnpose run web rails db:setup

Fedora - http://localhost:8983/solr/#/ http://localhost:8984 SOLR - http://localhost:8984/rest/dev

Fedora

http://localhost:3000/concern/images/gq67jr16q

c = Image.find('gq67jr16q')
c.uri
=> #<RDF::URI:0x2af187ad24f8 URI:http://fedora:8080/rest/dev/gq/67/jr/16/gq67jr16q>

http://localhost:8984/rest/dev/gq/67/jr/16/gq67jr16q

Created at 2019-09-09T18:41:05.385Z by bypassAdmin Last Modified at 2019-09-09T19:08:45.199Z by bypassAdmin Children 8 http://localhost:8984/rest/dev/e0/4a/70/09/e04a7009-24a1-46f8-869b-516f0fe41ae5 http://localhost:8984/rest/dev/gq/67/jr/16/gq67jr16q http://localhost:8984/rest/dev/qv/33/rw/64/qv33rw64w http://localhost:8984/rest/dev/e6/ba/55/bc/e6ba55bc-8166-4f1b-9257-ea99c79cb71e http://localhost:8984/rest/dev/0k/22/5b/04/0k225b04p http://localhost:8984/rest/dev/ad/mi/n_/se/admin_set/default http://localhost:8984/rest/dev/ed/07/26/38/ed072638-220d-49fe-9ae2-091e76bb597d http://localhost:8984/rest/dev/28/5b/a3/ae/285ba3ae-bedb-4647-8d53-e017564690b3


SOLR

: =

constructing SOLR query - https://www.google.com/search?q=construct+solr+query&rlz=1C5CHFA_enUS818US818&oq=construct+solr+query&aqs=chrome..69i57.7550j0j0&sourceid=chrome&ie=UTF-8

id:work_id = id:38741827384

i.file_sets.first.files.first


Hydra


OCFL - Oxford Common File Layout

admin set - administrative grouping of thing - every Object in a Samvera repo must belong to an admin set and can only have one. default permission scheme the workflow creation It has two part one in the software and one in the database.


Rails Console

The console in Rails is nothing more than an irb (see Section 2.4, “irb”) built around the Rails environment. Rails Console Shortcuts, Tips, and Tricks

Work.count
Collection.count

i = Image.find('')
i.uri
`i.file_sets.first.files.first`

HydaAccessControl- controlls access


The Rails Command Line The Rails Console - Ruby on Rails Books Active Record Team Treehouse https://medium.com/@lfv89/rails-console-magic-tricks-da1fdd657d32

characterization


https://github.com/RepoCamp/ucla2019/wiki/Hyrax-Stack-Walkthrough#exercises

What other fields are available? Does what you see in the User Interface match the code at hyrax/basic_metadata.rb? Also see: https://github.com/no-reply/sufia-profile/blob/master/profile.md

Show predicate mappings inherited from Hydra::Works::Characterization::ImageSchema https://github.com/samvera/hydra-works/blob/master/lib/hydra/works/characterization/schema/image_schema.rb



Day2 Morning

Run Test Suite

https://github.com/RepoCamp/ucla2019/wiki/Run-Test-Suite

  • Compare the structure of our /spec directory to our /app directory
  • What is a rake task?
    • Rake allows you to write tasks in the Ruby language and execute them on the command line.
    • It is a Domain Specific Language (DSL), which means you can only use it for things related to Ruby.
    • Rake is a task runner.
    • It runs small tasks.
    • It is a software task management and build automation tool.
    • It allows the user to specify tasks and describe dependencies as well as to group tasks in a namespace.
    • There are rake tasks natively built into Ruby and Rails that perform common functions such as rake db:migrate
    • To view your local rake tasks: $ rake --tasks
  • Rake Tutorials + https://www.rubyguides.com/2019/02/ruby-rake/ + https://lukaszwrobel.pl/blog/rake-tutorial/ + https://web.archive.org/web/20071024171055/http://www.railsenvy.com/2007/6/11/ruby-on-rails-rake-tutorial
  • What kinds of jobs make good tasks?
    • Making a backup of your database
    • Running your tests
    • Gathering & reporting stats
  • What are the advantages of having the CI task launch Solr and Fedora test instances vs. leaving them running? + CI - Continuously runs your test suite when an event happens in your repo.
  • What does "pending" mean in the context of our test suite?
    • The test is not running. It is just a sketch.
  • What does that Randomized with seed line mean? What are we randomizing and why?
    rspec spec --seed 1234 In the default configuration, RSpec runs its tests a random order. This is actually a good practice because tests should be independent of each other. Running them in a random order helps to find tests that only pass when they are run in a specific order and fail in another order.

But the problem is: If RSpec runs the test in a random order and then fails, how can you re-run the test in the same order again to debug the issue? That can be done by telling RSpec to use the same seed for its randomness as it was using before.


Add a Metadata field

https://github.com/RepoCamp/ucla2019/wiki/Add-a-metadata-field,-with-feature-and-unit-tests

semantic web - linked data - predicate


hyrax_images_controller.rb

Term

Active Record is the M in MVC - the model - which is the layer of the system responsible for representing business data and logic. Active Record facilitates the creation and use of business objects whose data requires persistent storage to a database. https://www.rubydoc.info/gems/solrizer/4.1.0

Active Fedora Association looks like an Array i.description = ["cat", "llama] NOT i.description.push("cat")

Predicates

models/ucla_metadata.rb

property :author, predicate: ::RDF::URI.intern('http://id.loc.gov/vocabulary/relators/aut') do |index|
  index.as :stored_searchable
end

Intern
https://en.wikipedia.org/wiki/String_interning

@jendiamond
Copy link
Author

jendiamond commented Sep 10, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment