Skip to content

Adding new Vocabularies and Controlled Vocabularies

Brandon R. Straley edited this page Jun 27, 2019 · 1 revision

Introduction

Here is where the process for generating a new Controlled Vocabulary and new Vocabularies in the system.

A Controlled Vocabulary is described in the metadata found here

The Controlled Vocabulary is a class name attributed to a specific property which will allow that property to accept a URI and return and index a label.

You will have to override the form field here

This maps to the property name and you will have to make the field a as: :controlled_vocabulary field.

The rest of the system should flow naturally as long as you follow the steps lain out in this document.

Controlled Vocabularies

The Controlled Vocabulary mechanism is relatively simple. Controlled Vocabularies exist here: lib/oregon_digital/controlled_vocabularies

A Controlled Vocabulary needs to inherit from our base object called Resource which contains many helper methods, which allow the Controlled Vocabularies to function correctly in the system. These methods includes ones to serialize themselves into normalized solr data, to check to see if a Controlled Vocabularies uri and label are the same, take a query and return the proper Vocabulary, interface with our Blazegraph triplestore, and several more. These shouldn't have to be messed with much.

A new Controlled Vocabulary will require one method. This method is #self.all_endpoints. This method will contain the Vocabularies in which will be used by this Controlled Vocabulary. A Controlled Vocabulary needs to know which endpoints are valid. If a user puts in a uri from an invalid endpoint, it will notify the user that it was an incorrect URI.

Vocabularies

Vocabularies are a 1:1 translation between the system and a vocabulary endpoint (such as id.loc.gov). These 1:1 translations exist in the system and are utilized by a Controlled Vocabulary so that a Controlled Vocabulary knows which endpoints are valid ones.

For example, the `Controlled Vocabulary` "Subject" can use id.loc.gov, but not opaquenamespace.org/repository

This is defined Here

Each Vocabulary is a singular endpoint and needs to have a few methods. One method to verify the uri used against the allowed endpoint self.expression, it needs to know how to dig into the response data and pull out a label self.label(data) and it needs to take a uri and negotiate it into a proper query on the endpoint self.as_query(q). If these three things are covered, then it will query the endpoint iff the used uri matches the endpoints uri, take the response and pull the label out of the response and return that.