Controlled Keywords#

class metacatalog.models.keyword.Keyword(**kwargs)#

The major purpose of a Keyword is to describe a Metadataset by a common word. Ideally, these keywords are hosted in a controlled dictionary. That means a third party distributes and describes the scope of these keywords and makes them publicly available. Added to an Entry, the keyword is primarily used to filter entities by keyword.

Keywords can be used to filter for similar Metadata in cross-database repositories.

id#

Unique id of the record. If not specified, the database will assign it.

Type:

int

uuid#

Version 4 UUID string to identify the Thesaurus across installations. Usually, this is created outside of metacatalog.

Type:

str

parent_id#

Foreign key to another Keyword (keywords.id). Used to build the hierachical order of keywords.

Type:

int

value#

The keyword itself. Should be all uppercase letters

Type:

str

full_path#

The full keyword including all ancestors keyword values. Usually, the term ‘Keyword’ refers to the full path of the keyword.

Note

The Keyword does also have a method Keyword.path to contruct the path by recursively querying the parents’ values. You can use this function to store the result in full_path for convenience.

Type:

str

thesaurusName#

New in version 0.1.10.

If the keyword is part of a controlled dictionary, this thesaurus should be described here. Usually, metacatalog will only implement onr or two, which are maintained by the admin.

Type:

metacatalog.models.Thesaurus

thesaurus_id#

New in version 0.1.10.

Foreign key to the associated thesaurus.

Type:

int

tagged_entries#

List of Associations between the current keyword and Entries tagged by this keyword. This list is filled automatically.

Type:

list

Note

If you use additional keywords, that are already part of a controlled dictionary, make sure not to upload them via the metacatalog API, as this will assign new UUIDs to the keywords. Rather use this model to upload them directly using sqlalchemy.

Keywords are build hierachical, separated by ' > '. This makes it possible to filter by keywords themselves or by groups of keywords. They have to follow the pattern:

category > topic > term ...

followed by any number of more granular groupings.

path() str#

Returns the full keyword path for the given level. The levels are separated by a ‘>’ sign. The levels are:

Topic > Term > Variable_Level_1 > Variable_Level_2 > Variable_Level_3 > Detailed_Variable

Returns:

path – The full keyword path

Return type:

str

to_dict(deep: bool = False) dict#

Return the model as a python dictionary.

New in version 0.1.10.

Parameters:

deep (bool) – If True, all related objects will be included as dictionary. Defaults to False

Returns:

obj – The Model as dict

Return type:

dict

class metacatalog.models.keyword.KeywordAssociation(**kwargs)#

Keyword association

Association between keyword and entry.

keyword_id#

Unique ID of the metacatalog.models.Keyword

Type:

int

entry_id#

Unique ID of the metacatalog.models.Entry

Type:

int

class metacatalog.models.keyword.Thesaurus(**kwargs)#

A thesaurus is a controlled dictionary, which is served at a permanent URL. As of now, metacatalog implements NASA Global Climate change Master Dictionary (GCMD) science keywords.

New in version 0.1.10.

id#

Unique id of the record. If not specified, the database will assign it.

Type:

int

uuid#

Version 4 UUID string to identify the Thesaurus across installations. Usually, this is created outside of metacatalog.

Type:

str

name#

Short name of the thesaurus entry. Should be 'custom' for non-official thesaurii. Example: 'GCMD' for the NASA/GCMD Science Keywords, which can be loaded by default.

Type:

str

title#

Full name of the keyword list. The title should contain the full qualified name. It is best practice to use a title the distiributor officially uses for the list. A short name can be given as name attribute.

Type:

str

organisation#

Name of the publishing Organisation for the thesaurus. It has to be the responsible party for the resource given at url.

Type:

str

description#

Full description of the scope and context of the thesaurus. From this description it should become obvious how keywords relate to the matadata that is tagged by the keywords

Type:

str

url#

URL of the full keyword list. May contain a placehoder for an UUID if the API at the resource is capable of loading keywords by UUID.

Type:

str

Notes

If you add other keywords, a thesaurus isnstance has to be specfied, which can be found at the url. If only one url is given, a full XML list of all keywords have to be published here. The url may contain a UUID placeholder for loading keywords by UUID. Do not reference a WIKI page or description via URL.

If the server instance operating metacatalog implements custom keyword lists, you can add a thesaurus instance here on installation. Do not expose this table to the user.

to_dict(deep: bool = False) dict#

Return the model as a python dictionary.

Parameters:

deep (bool) – If True, all related objects will be included as dictionary. Defaults to False

Returns:

obj – The Model as dict

Return type:

dict