Skip to content

Hyrax Stack Walkthrough

Andrew Benedict Wallace edited this page Feb 1, 2019 · 40 revisions

This guide assumes you are starting with a template-generated instance of Hyrax and running your application inside a set of docker containers.

Goals:

  • Understand the way an item in Hyrax
    • is displayed in the User Interface,
    • is represented in the application Code
    • is stored in Fedora
    • is indexed in Solr

Lesson Setup

TIP: If you system has more than 4GB of memory, increases the memory limit for containers in your docker preferences

  • Open a terminal window and clone this repository and check out the lesson:

     git clone https://github.com/RepoCamp/ucla2019.git hyrax_demo
     cd hyrax_demo
     git checkout walkthrough
  • Start the docker containers

    # from the hyrax_demo directory
    docker-compose pull
    docker-compose up --build --force-recreate

    This launches containers running Solr, Fedora, Redis, a database, and your web application server. You'll leave the containers running for the rest of this lesson. Logs from all of the containers will display in this window, so you can check back here if you want to see log output during any part of the lesson.

  • Open a new terminal window and connect to the main samvera web application container

    # in new terminal window
    cd hyrax_demo
    docker-compose run web bash

    This should give you a prompt something like root@5b7d9b5c4b0d:/hyrax_demo#

  • Update dependencies:
    bundle install

  • Run migrations:
    rails db:migrate

  • Create the default Admin Set (an administrative collection -- every work instance deposited must belong to one and only one Admin Set):
    rails hyrax:default_admin_set:create

  • Check that your application is running by visiting http://localhost:3000

Steps

  1. Inspect an empty repository You rarely see this in the real world...

    • User Interface: go to http://localhost:3000, click on the blue search button labeled Go you should see a message like "No results found for your search"
    • Code: in a new terminal window, rails console, then enter Image.count, then Collection.count both should return 0
    • Fedora: go to http://localhost:8984/rest/dev check the number of children - what does it look like they are?
    • Solr: go to http://localhost:8983/solr/#/hyrax note the document counts under "Statistics" - what shows up when you search Solr?
  2. Set up a user and create a work using the User Interface

    1. Go to http://localhost:3000, click on the Login link in the upper right-hand corner
    2. If you haven't created a user yet, click the Sign up link just below the login button
    3. Enter your chosen e-mail and password
    4. From your Dashboard, click on the Works link in the left-hand navigation bar
    5. Click on the Add new work button to add a new item to the repository Notice the Requirements section in the SAVE WORK panel
    6. Fill out the fields marked with blue required labels Notice the Requirements section in the SAVE WORK panel
    7. Click on the Files tab
    8. Click on the + Add Files button and select a file to upload NOTE: if you copied files from a thumb-drive, there are sample files to use in your tutorial/vagrant/samples-assets folder Notice the Requirements section in the SAVE WORK panel
    9. Click the checkbox for the deposit agreement and click the SAVE button
    10. Wait a second and take a look at your new Work!
  3. Now that you have something in your repository, let's take a look at it

    • User Interface: go to http://localhost:3000, click on the search icon you should see your new item listed in the results along with a facet list to the left
    • Code: from the Rails console, check Image.count, then Collection.count again you now have 1 work and no collections
    • Fedora: go to http://localhost:8984/rest/dev note the number of new children in this container - can you figure out what any of them are?
    • Solr: go to http://localhost:8983/solr/#/hyrax check whether the document counts under "Statistics" has changed
  4. Find a work by its identifier Do a search from the user interface and click on your work, you can read the id from the work's URL

Exercises

  1. Add an optional field using the User Interface

    • Verify the change in the Code. HINT use the ID in the url and use it to find the item using the console. You might need to use the .reload method on your work to refresh attributes in memory.
    • Verify the change in Fedora.
    • Verify the change in Solr.
  2. 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

  3. What happens when you add multiple entries for a field?

  4. What happens when you remove all the entries for a field?

  5. Add a second description using the console. HINT you'll need to use the .save method to make changes in memory persist to Solr and Fedora.

    • Verify the change in the User Interface.
    • Verify the change in Fedora.
    • Verify the change in Solr.
  6. Find the access controls in Fedora

    • Change the access control (visibility) using the User Interface
    • What changes in Fedora
  7. Create an empty Collection using the User Interface

    • since this an out of the box hyrax you need to create a collection type first
      • run in a console (vagrant@camper:/vagrant/berlin2018$)
        rails hyrax:default_collection_types:create
    • Verify that Collection.count has changed in the rails console
    • What does the collection look like in Code?
    • What does the collection look like in Fedora?
    • What does the collection look like in Solr?
  8. Add a new Work to your collection using the User Interface

    • What does the Work look like in CODE
    • What does the collection look like now in Code?
    • What does the collection look like now in Fedora?
    • What does the collection look like now in Solr?
    • What does the Work look like in Solr?
  9. Attach an image to a Work using the UI. Then look at FileSets (i.file_sets) and Files (i.files) in the Rails console. Then try i.file_sets.first.files to see the files attached to the first file_set.

  10. Interact with a File object. You can get a File object like this: file = i.file_sets.first.files.first

    1. Find the original file_name (file.file_name)
    2. Display the width, height, color_space, profile_name, size, mime_type, fits_version
    3. Inspect the content
    4. 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