Developer Cheatsheet - UVicLibrary/Spotlight2_custom GitHub Wiki
Definitions
resource
is aSpotlight::Resource
objectdocument
is aSolrDocument
(sometimes::SolrDocument
) objectblacklight_url
is the link to the Spotlight Solr instance
Commands
- Create a new imported resource
- Get a resource's file type (image, compound object, etc.)
- Get the file type of a compound object
- Check if a resource/document is imported or uploaded
- Check if a compound object is imported or uploaded
- Delete a resource and document
- Get URLs for Vault resources
Create a new imported resource
Mandatory attributes:
url
= The url to an IIIF manifestexhibit_id
Optional attributes:
file_name
Note:resource.file_type
won't work if this is emptydata
= metadata for the resource. If this is pre-filled, Spotlight will use this data. If blank, it will autofill based on the source manifest.
Spotlight::Resources::IiifHarvester.create( url: url, exhibit_id: exhibit.id, file_name: "default.jpg", data: row)
See create method for imported resources | See VaultIiifManifest for what gets indexed to Solr or saved in resource, document, and sidecar
Get a resource's file type (image, compound object, etc.)
Returns one of the following: "image"
, "compound_object"
, "video/audio"
, "video"
, "audio"
, "pdf"
,"model"
, "unknown"
resource.file_type
#=> "image"
Get the file type of a compound object
resource.made_of?
# => "image"
Check if a resource/document is imported or uploaded
resource.imported? #=> true/false
document.uploaded_resource? #=> true/false
See .imported? definition | See .uploaded_resource? definition
Check if a compound object is imported or uploaded
resource.imported_compound_object?
#=> true/false
Delete a resource, document
This is what the delete button does in Curation > Items view. First we delete the document:
solr = RSolr.connect :url => 'blacklight_url'
doc_id = resource.compound_id
solr.delete_by_id doc_id
solr.commit
Destroy the resource:
resource.destroy
See the full method defined in the destroy action.
Get URLs for Vault Resources
document["content_metadata_image_iiif_info_ssm"]