Module

LinkedArtHelpers

This file contains helpers for working with LinkedArt JSON-LD data

Author:
  • Adam Brin, Pamela Lam, Alyx Rossetti, Charles Webb, Selina Zawacki, Nabil Kashyap

View Source LinkedArtHelpers.js, line 1

Methods

# static getAssignedBy(object, assignedProperty) → {Array}

Gets all of the objects from a LinkedArt Object's 'assigned_by' attribute which have
an 'assigned_property' attribute that matches the assignedProperty parameter.

Parameters:
Name Type Description
object Object

the LinkedArt Object

assignedProperty String

the assigned properly (optional)

View Source LinkedArtHelpers.js, line 611

the list of values that map to the attributed value

Array
Example
getAssignedBy(object, 'identified_by') would return the object with 'type': 'Name'
from the example object below
 {
  "assigned_by": [
     {
       "id": "https://data.getty.edu/museum/collection/object/5be2eb9f-1b4e-49f6-bfc4-0fc7ab67a1c5/name/f04fde5c-e645-4b4d-986c-443d7c6aa2ef/attribute-assignment",
       "type": "AttributeAssignment",
       "assigned_property": "identified_by",
       "assigned": {
         "id": "https://data.getty.edu/museum/collection/object/5be2eb9f-1b4e-49f6-bfc4-0fc7ab67a1c5/name/f04fde5c-e645-4b4d-986c-443d7c6aa2ef",
         "type": "Name",
         "content": "Initial B: David Playing the Harp",
         "classified_as": [
         ]
       },
     }]
     }

# static getAttributedBy(object, assignedProperty) → {Array}

Gets all of the objects from a LinkedArt Object's 'attributed_by' attribute which have
an 'assigned_property' attribute that matches the assignedProperty parameter.

Parameters:
Name Type Description
object Object

the LinkedArt Object

assignedProperty String

the assigned property

View Source LinkedArtHelpers.js, line 575

the list of values that map to the attributed value

Array
Example
getAttributedBy(object, 'identified_by') would return the object with 'type': 'Name'
from the example object below
{
 "attributed_by": [
     {
       "id": "https://data.getty.edu/museum/collection/object/5be2eb9f-1b4e-49f6-bfc4-0fc7ab67a1c5/name/f04fde5c-e645-4b4d-986c-443d7c6aa2ef/attribute-assignment",
       "type": "AttributeAssignment",
       "assigned_property": "identified_by",
       "assigned": {
         "id": "https://data.getty.edu/museum/collection/object/5be2eb9f-1b4e-49f6-bfc4-0fc7ab67a1c5/name/f04fde5c-e645-4b4d-986c-443d7c6aa2ef",
         "type": "Name",
         "content": "Initial B: David Playing the Harp",
         "classified_as": [
         ]
       },
     }]
   }

# static getClassified(submittedResource, requestedClassifications, classificationField, options) → {Array}

Given an object or an array of objects, find all objects that with classifications
that match either all of the requestedClassifications or any of the requestedClassifications.

Parameters:
Name Type Description
submittedResource Object | Array

the object to inspect

requestedClassifications String | Array

either a string or an array of classification strings

classificationField String

the field to investigate for an object's classification (e.g. classified_as, classified_by)

options Object

additional options

language String

limits the results to just a specific language (or leave undefined for all results)

languageOptions Object

any additional options when working with language(s) @see LanguageHelpers.doesObjectLanguageMatch

operator String

a boolean operator (AND|OR) for how to treat the nested classifications

View Source LinkedArtHelpers.js, line 363

an array of objects that match

Array
Examples
for the submittedResource:
[
  {content: 'Irises', classified_as: [{id: 'title'}]},
  {content: 'Blue Irises', classified_as: [{id: 'title'}, {id: 'description'}]},
  {content: 'Van Gogh painting', classified_as: [{id: 'description'}]}
]
getClassified(submittedResource, ['title', 'description']) would return the second object in the array
for the submittedResource:
[
  {content: 'Irises', classified_as: [{id: 'title'}]},
  {content: 'Blue Irises', classified_as: [{id: 'title'}, {id: 'description'}]},
  {content: 'Van Gogh painting', classified_as: [{id: 'description'}]}
]
getClassified(submittedResource, ['title', 'description'], 'classified_as', undefined, {}, 'OR')
would return all objects in the array

# static getClassifiedAs(submittedResource, requestedClassifications, options) → {Array}

Given an object or an array of objects, find all entries that have an object in their classified_as
field with an id that matches the requestedClassification.

Parameters:
Name Type Description
submittedResource Object | Array

the object to inspect

requestedClassifications String | Array

the classification ID/IDS to match

options Object

additional options

language String

limits the results to just a specific language (or leave undefined for all results)

languageOptions Object

any additional options when working with language(s) @see LanguageHelpers.doesObjectLanguageMatch

operator String

a boolean operator (AND|OR) for how to treat the nested classifications

View Source LinkedArtHelpers.js, line 54

an array of objects that match

Array
Example
for the submittedResource:
[
  {content: 'Irises', classified_by: [{id: 'title'}]},
  {content: 'Blue Irises', classified_by: [{id: 'title', classified_by: 'descriptive title'}]},
  {content: 'Van Gogh painting', classified_as: [{id: 'description', classified_as: 'descriptive title'}]}
]
getClassifiedAs(submittedResource, 'description') would return the third object in the array

# static getClassifiedAsWithClassification(submittedResource, nestedClassification, options) → {Array}

Given an object or an array of objects, find all classification objects that are classified as
with the nestedClassification. (e.g. for Visual Items we need to get the rights statement
classification object, which we identify by its own classification see VisualItems.getClearanceLevel)

Parameters:
Name Type Description
submittedResource Object | Array

the object to inspect

nestedClassification String | Array

the classification ID/IDS to match

options Object

additional options

language String

limits the results to just a specific language (or leave undefined for all results)

languageOptions Object

any additional options when working with language(s) @see LanguageHelpers.doesObjectLanguageMatch

operator String

a boolean operator (AND|OR) for how to treat the nested classifications

View Source LinkedArtHelpers.js, line 124

an array of objects that match

Array
Example
for the submittedResource:
[
  {content: 'Irises', classified_by: [{id: 'title'}]},
  {content: 'Blue Irises', classified_by: [{id: 'title', classified_by: 'descriptive title'}]},
  {content: 'Van Gogh painting', classified_as: [{id: 'description', classified_as: 'descriptive title'}]}
]
getClassifiedByWithClassification(submittedResource, 'descriptive title') would return the classification with
'id': 'description' from the 'classified_as' attribute of the third object in the array

# static getClassifiedBy(submittedResource, requestedClassifications, options) → {Array}

Given an object or an array of objects, find all entries that have an object in their classified_by
field with an id that matches the requestedClassification.

Parameters:
Name Type Description
submittedResource Object | Array

the object to inspect

requestedClassifications String | Array

the classification ID/IDS to match

options Object

additional options

language String

limits the results to just a specific language (or leave undefined for all results)

languageOptions Object

any additional options when working with language(s) @see LanguageHelpers.doesObjectLanguageMatch

operator String

a boolean operator (AND|OR) for how to treat the nested classifications

View Source LinkedArtHelpers.js, line 88

an array of objects that match

Array
Example
for the submittedResource:
[
  {content: 'Irises', classified_by: [{id: 'title'}]},
  {content: 'Blue Irises', classified_by: [{id: 'title', classified_by: 'descriptive title'}]},
  {content: 'Van Gogh painting', classified_as: [{id: 'description', classified_as: 'descriptive title'}]}
]
getClassifiedBy(submittedResource, 'title') would return the first and second objects in the array

# static getClassifiedByWithClassification(submittedResource, nestedClassification, options) → {Array}

Given an object or an array of objects, find all classification objects that are classified by
with the nestedClassification. (e.g. for Visual Items we need to get the rights statement
classification object, which we identify by its own classification see VisualItems.getClearanceLevel)

Parameters:
Name Type Description
submittedResource Object | Array

the object to inspect

nestedClassification String | Array

the classification ID/IDS to match

options Object

additional options

language String

limits the results to just a specific language (or leave undefined for all results)

languageOptions Object

any additional options when working with language(s) @see LanguageHelpers.doesObjectLanguageMatch

operator String

a boolean operator (AND|OR) for how to treat the nested classifications

View Source LinkedArtHelpers.js, line 160

an array of objects that match

Array
Example
for the submittedResource:
[
  {content: 'Irises', classified_by: [{id: 'title'}]},
  {content: 'Blue Irises', classified_by: [{id: 'title', classified_by: 'descriptive title'}]},
  {content: 'Van Gogh painting', classified_as: [{id: 'description', classified_as: 'descriptive title'}]}
]
getClassifiedByWithClassification(submittedResource, 'descriptive title') would return the classification with
'id': 'title' from the 'classified_by' attribute of the second object in the array

# static getDescriptions(submittedResource, options) → {Array}

Gets the descriptions(s) associated with an object if available.

Parameters:
Name Type Description
submittedResource Object

JSON-LD object

options Object

additional options

requestedClassifications String | Array

AAT descriptions (default: aat.DESCRIPTION)

language String

limits the results to just a specific language (or leave undefined for all results)

languageOptions Object

any additional options when working with language(s) @see LanguageHelpers.doesObjectLanguageMatch

View Source LinkedArtHelpers.js, line 922

content of descriptions(s)

Array
Examples
getDescriptions(object) // gets descriptions(s) using defaults
getDescriptions(object, {language:'fr'}) // gets descriptions(s) in French

# static getFieldPartSubfield(object, field, subfield) → {Array}

Helper function that returns an array of requested production/creation information, tries to reconcile where the production may have parts.
This can be useful to get the Timespan for a creation, or the creator, or other nested fields

Parameters:
Name Type Description
object Object

the JSON-LD HumanMadeObject or InformationObject

field String

the data field in the object to look for the subfield

subfield String

the subfield to look for

View Source LinkedArtHelpers.js, line 870

an array of the matching values

Array
Example
gets the subfield regardless of whether the field has parts or not
 getFieldPartSubfield({produced_by: { part: [{carried_out_by: {id:123}}}]}, 'produced_by', 'carried_out_by'),  would return an array with one item [{id:123}]

# static getFieldValuesByClassifications(submittedResource, field, requestedClassifications, options) → {Array}

Builds on getValuesByClassification to look inside a field for those values, e.g. "referred_to_by" or "identified_by" and returns the entries classified by the values

Parameters:
Name Type Description
submittedResource Object

the JSON-LD Object

field String

the field to look in (e.g. referred_to_by)

requestedClassifications String | Array

the AAT or local classifications

options Object

additional options

language String

limits the results to just a specific language (or leave undefined for all results)

languageOptions Object

any additional options when working with language(s) @see LanguageHelpers.doesObjectLanguageMatch

operator String

a boolean operator (AND|OR) for how to treat the nested classifications

View Source LinkedArtHelpers.js, line 896

an array of objects

Array
Example
getFieldValuesByClassifications(object, "referred_to_by", aat.ACKNOWLEDGEMENTS, 'ja') // would return all of the acknowledgement entries in japanese

# static getObjectParts(object, field) → {Array}

Checks to see if an object's requested field has a part and returns the value. Otherwise,
returns either the requested field (if available) or an empty array (if neither is available)

Parameters:
Name Type Description
object Object

the LinkedArt Object

field String

the requested field to search for parts

View Source LinkedArtHelpers.js, line 668

If the value of the object's field has a 'part' attribute, return it. If not,
return the value of the object's field as an array. If the object does not have an attribute
matching the field parameter return an empty array.

Array
Example
(an example of the data)
 "produced_by": {
      "id": "https://data.getty.edu/museum/collection/object/f8fd6961-6da3-4c39-94ad-e8e9367fa51b/production",
      "type": "Production",
      "_label": "Production of Artwork",
      "part": [
        {
          "id": "https://data.getty.edu/museum/collection/object/f8fd6961-6da3-4c39-94ad-e8e9367fa51b/production/1663467e-66d8-4170-91b0-2937ba6447e6/producer-description",
          "type": "LinguisticObject",
          "_label": "Artist/Maker (Producer) Description",
          "classified_as": [
          ]
        },
      ]
    }

# static getObjectsClassifiedAsWithClassification(submittedResource, nestedClassification, options) → {Array}

Given an object or an array of objects, find all objects that are classified as an object
which is classified by nestedClassification

Parameters:
Name Type Description
submittedResource Object | Array

the object to inspect

nestedClassification String | Array

the classification ID/IDS to match

options Object

additional options

language String

limits the results to just a specific language (or leave undefined for all results)

languageOptions Object

any additional options when working with language(s) @see LanguageHelpers.doesObjectLanguageMatch

operator String

a boolean operator (AND|OR) for how to treat the nested classifications

View Source LinkedArtHelpers.js, line 195

an array of objects that match

Array
Example
for the submittedResource:
[
  {content: 'Irises', classified_by: [{id: 'title'}]},
  {content: 'Blue Irises', classified_by: [{id: 'title', classified_by: 'descriptive title'}]},
  {content: 'Van Gogh painting', classified_as: [{id: 'description', classified_as: 'descriptive title'}]}
]
getObjectsClassifiedByWithClassification(submittedResource, 'descriptive title') would return the
third object in the array

# static getObjectsClassifiedByWithClassification(submittedResource, nestedClassification, options) → {Array}

Given an object or an array of objects, find all objects that are classified by an object
which is classified by nestedClassification

Parameters:
Name Type Description
submittedResource Object | Array

the object to inspect

nestedClassification String | Array

the classification ID/IDS to match

options Object

additional options

language String

limits the results to just a specific language (or leave undefined for all results)

languageOptions Object

any additional options when working with language(s) @see LanguageHelpers.doesObjectLanguageMatch

operator String

a boolean operator (AND|OR) for how to treat the nested classifications

View Source LinkedArtHelpers.js, line 230

an array of objects that match

Array
Example
for the submittedResource:
[
  {content: 'Irises', classified_by: [{id: 'title'}]},
  {content: 'Blue Irises', classified_by: [{id: 'title', classified_by: 'descriptive title'}]},
  {content: 'Van Gogh painting', classified_as: [{id: 'description', classified_as: 'descriptive title'}]}
]
getObjectsClassifiedByWithClassification(submittedResource, 'descriptive title') would return the
second object in the array

# static getPrimaryName(submittedResource, options) → {String}

Gets the primary name of the JSON-LD object based on an AAT value or other qualifier, uses the AAT value of Preferred Term as the default

Parameters:
Name Type Description
submittedResource Object

the JSON-LD object

options Object

additional options

requestedClassifications String | Array

the requested classifications (default is aat.PRIMARY_TERM)

language String

the requested language (default undefined)

languageOptions Object

additional language options

languageOptions.lookupMap Object

a map of terms -> values for translating language keys (eg. "en": "aat:11111")

languageOptions.fallbackLanguage String

if a language is specified, this provides a fallback language if that language is not available in the data, e.g. use english if there is no french

View Source LinkedArtHelpers.js, line 260

of items identified as primary names

String
Examples
gets the primary name using defaults getPrimaryName(object)
gets the primary name in french getPrimaryName(object, {language:'fr'})
gets the primary name using a different AAT term getPrimaryName(object, {requestedClassifications: 'http://vocab.getty.edu/aat/300417193'})

# static getPrimaryNames(submittedResource, options) → {Array}

Gets the primary names of the JSON-LD object based on an AAT value or other qualifier, uses the AAT value of Preferred Term as the default

Parameters:
Name Type Description
submittedResource Object

the JSON-LD object

options Object

additional options

requestedClassifications String | Array

the requested classifications (default is aat.PRIMARY_TERM)

language String

the requested language (default undefined)

languageOptions Object

additional language options

languageOptions.lookupMap Object

a map of terms -> values for translating language keys (eg. "en": "aat:11111")

languageOptions.fallbackLanguage String

if a language is specified, this provides a fallback language if that language is not available in the data, e.g. use english if there is no french

View Source LinkedArtHelpers.js, line 293

of items identified as primary names

Array
Examples
gets the primary name using defaults getPrimaryName(object)
gets the primary name in french getPrimaryName(object, {language:'fr'})
gets the primary name using a different AAT term getPrimaryName(object, {requestedClassifications: 'http://vocab.getty.edu/aat/300417193'})

# static getReferredToByClassification(object, classification) → {String}

Gets all the values of objects in a LinkedArt object's 'referred_to_by' field
which are classified by the classification parameter.

Parameters:
Name Type Description
object Object

the Actor object to inspect

classification String | Array

the classification

View Source LinkedArtHelpers.js, line 540

or undefined

String
Example
for the object:
{
 'referred_to_by': [
    {content: 'Irises', classified_as: [{id: 'title'}]},
    {content: 'Van Gogh painting', classified_as: [{id: 'description'}]}
  ]
}
getReferredToByClassification(object, 'title') would return ['Irises']

# static getValueByClassification(submittedResource, requestedClassifications, options) → {String|number}

Get the value of the first object that is classified as the requestedClassification
parameter.

Parameters:
Name Type Description
submittedResource Object | Array

the JSON-LD Object

requestedClassifications String | Array

the requested classifications

options Object

additional options

language String

limits the results to just a specific language (or leave undefined for all results)

languageOptions Object

any additional options when working with language(s) @see LanguageHelpers.doesObjectLanguageMatch

operator String

a boolean operator (AND|OR) for how to treat the nested classifications

View Source LinkedArtHelpers.js, line 436

the matching value

String | number
Example
for the submittedResource:
[
  {content: 'Irises', classified_as: [{id: 'title'}]},
  {content: 'Blue Irises', classified_as: [{id: 'title'}]},
  {content: 'Van Gogh painting', classified_as: [{id: 'description'}]}
]
getValueByClassification(submittedResource, 'title') would return 'Irises'

# static getValueOrContent(object) → {String|number}

Given an object get the value of the 'value' or 'content' attribute (if
an object has both returns the 'value' attribute)

Parameters:
Name Type Description
object Object

the JSON-LD object

View Source LinkedArtHelpers.js, line 508

the value or content depending on which exists.

String | number
Example
getValueOrContent({'value': 123, 'content': '456'}) would return 123

//fixme: if this should only return a string or number should we add a type check?

# static getValuesByClassification(submittedResource, requestedClassifications, options) → {Array}

Get an array of all the values of objects that are classified as the
requestedClassification parameter.

Parameters:
Name Type Description
submittedResource Object | Array

the JSON-LD Object

requestedClassifications String | Array

the requested classifications

options Object

additional options

language String

limits the results to just a specific language (or leave undefined for all results)

languageOptions Object

any additional options when working with language(s) @see LanguageHelpers.doesObjectLanguageMatch

operator String

a boolean operator (AND|OR) for how to treat the nested classifications

View Source LinkedArtHelpers.js, line 474

the matching values (string|Array)

Array
Example
for the submittedResource:
[
  {content: 'Irises', classified_as: [{id: 'title'}]},
  {content: 'Blue Irises', classified_as: [{id: 'title'}]},
  {content: 'Van Gogh painting', classified_as: [{id: 'description'}]}
]
getValuesByClassification(submittedResource, 'title') would return ['Irises', 'Blue Irises']