metadata.ql
An entity to handle metadata on meta-allowable objects. Only one should be created per application context. Objects that allow metadata on them are: songs, albums, artists, collections.
Metadata attributes may be owned by a single object, or inherited from parent objects. The hierarchy of inheritance is: song -> album -> artist Such that songs can get metadata from albums and then artists, and albums can get metadata from artists.
Constructor | Description |
---|---|
Metadata(_connection) | Create a new metadata object with the given database connection. For depending libraries, use the |
Function | Description |
---|---|
static fun createMetadata(database) | |
static fun defaultMetadata() | Create a new metadata connection with the environment variables. Expected environment variables (with defaults) are: - QL_METADATA_DATABASE_HOST (localhost) - QL_METADATA_DATABASE_PORT (5432) - QL_MET... |
fun isConnected() | Check if the metadata database connection is connected. |
fun _getParent(metaObject) | Get the parent object of the given object, if it has one. |
fun _getHierarchyIds(metaObject, inherit) | Get the hierarchy of IDs for the given object, inheriting from parent objects. |
fun _constructPlaceholders(count) | Construct a string of ? placeholders for a prepared statement. |
fun getTags(metaObject) | Get the tags for the given object, inheriting from parent objects. If no tags are found, an empty list is returned. |
fun getTags(metaObject, inherit) | Get the tags for the given object. If no tags are found, an empty list is returned. |
fun getDescription(metaObject) | Get the description for the given object, inheriting from parent objects. If no description is found, an empty string is returned. |
fun _constructDescriptionPlaceholder(count) | |
fun getDescription(metaObject, inherit) | Get the description for the given object. If no description is found, an empty string is returned. |
fun getRating(metaObject) | Get the rating for the given object, inheriting from parent objects. If no rating is found, -1 is returned. |
fun getRating(metaObject, inherit) | Get the rating for the given object. If no rating is found, -1 is returned. |
fun getCustomField(metaObject, field) | Get the custom field for the given object, returned as an Optional. |
fun getCustomField(metaObject, field, inherit) | Get the custom field for the given object, returned as an Optional. |
fun getAllCustomFields(metaObject) | Get all custom fields for the given object, inheriting from parent objects. |
fun getAllCustomFields(metaObject, inherit) | Get all custom fields for the given object. |
fun setTags(metaObject, tags) | Set the tags for the given object. |
fun addTag(metaObject, tag) | Add a tag to the given object. |
fun removeTag(metaObject, tag) | Remove a tag from the given object. If the tag is found in parent objects, remove it from there too. |
fun removeTag(metaObject, tag, inherit) | Remove a tag from the given object, inheriting from parent objects. |
fun setDescription(metaObject, description) | Set the description for the given object. |
fun setRating(metaObject, rating) | Set the rating for the given object. |
fun setCustomField(metaObject, field, value) | Set the custom field for the given object. Custom field allowed types: string, int, double, boolean |
fun setAllCustomFields(metaObject, fields) | Set all custom fields for the given object. Custom field allowed types: string, int, double, boolean, list (of the previous types) |
Create a new metadata object with the given database connection. For depending libraries, use the createMetadata
function instead of the constructor.
_connection
|
An active connection to a database |
Create a new metadata connection with the environment variables. Expected environment variables (with defaults) are: - QL_METADATA_DATABASE_HOST
(localhost) - QL_METADATA_DATABASE_PORT
(5432) - QL_METADATA_DATABASE
(metadata) - QL_METADATA_USER
(admin) - QL_METADATA_PASS
(pass)
The created metadata object
Get the hierarchy of IDs for the given object, inheriting from parent objects.
metaObject
|
The object to get the hierarchy for |
inherit
( boolean )
|
Whether to inherit from parent objects. If false, only the given object's ID is returned in the array |
The hierarchy of IDs for the object
Get the description for the given object. If no description is found, an empty string is returned.
metaObject
|
The object to get the description for |
inherit
( boolean )
|
Whether to inherit from parent objects |
The description for the object. If no description is found, an empty string is returned
Get the custom field for the given object, returned as an Optional.
metaObject
|
The object to get the custom field for |
field
|
The field to get |
The custom field for the object, if present. Actual value is whatever type it was set to (e.g. string, int, etc.)
Get the custom field for the given object, returned as an Optional.
metaObject
|
The object to get the custom field for |
field
|
The field to get |
The custom field for the object, if present. Actual value is whatever type it was set to (e.g. string, int, etc.)
Get all custom fields for the given object, inheriting from parent objects.
metaObject
|
The object to get the custom fields for |
A map of all custom fields for the object, with the field name as the key and the value as the value
Set the custom field for the given object. Custom field allowed types: string, int, double, boolean
metaObject
|
The object to set the custom field for |
field
|
The field to set |
value
|
The value to set |
Set all custom fields for the given object. Custom field allowed types: string, int, double, boolean, list (of the previous types)
metaObject
|
The object to set the custom fields for |
fields
( Map )
|
A map of all custom fields for the object, with the field name as the key and the value as the value |