Add Entry#

Entry#

metacatalog.api.add_entry(session: Session, title: str, author: Union[int, str], location: Union[str, Tuple[int], Tuple[float]], variable: Union[int, str], abstract: str = None, external_id: str = None, license: Union[str, int] = None, embargo: bool = False, is_partial: bool = False, **kwargs) Entry#

Add new Entry

Adds a new metadata Entry to the database. This method will create the core entry. Usually, more steps are necessary, which will need the newly created database ID. Such steps are:

  • adding contributors (mandatory)

  • adding data (extremly useful)

  • adding keywords (recommended)

Parameters:
  • session (sqlalchemy.Session) – SQLAlchemy session connected to the database.

  • title (str) – Title of the Entry

  • author (int, str) –

    New in version 0.2.6.

    First author of the Entry. The Person record has to exist already in the database and can be found by exact match on id (int) or last_name (str). Organisations can also be added as an author, can be found by exact match on id (int) or organisation_name (str).

  • location (str, tuple) –

    Can be either a WKT of a EPSG:4326 location, or the coordinates as a tuple. It has to be (X,Y), to (longitude, latitude).

    Changed in version 0.6.1: A POINT location should be specified here if there is a physical measurement point that is different from the centroid of the spatial extent (e.g., discharge measurement with the extent of the catchment). Otherwise, Datasource.spatial_scale.extent should be used to specify the location of the measured data.

  • variable (int, str) – Full variable name (str) or ID (int) of the data described by the Entry.

  • abstract (str) – Description of the data. Be as detailed as possible

  • external_id (str) – If the data described by Entry has another unique identifier, usually supplied by the data provider, it can be stored for reference reasons.

  • comment (str) – General purpose comment that should not contain any vital information to understand the entry. If it’s vital, it should go into the abstract.

  • license (str, int) – Either the id or full name of the license to be linked to this Entry.

  • embargo (bool) – If True, this Entry will not be publicly available until the embargo ends The embargo period is usually 2 years but can be modified using the kwargs.

  • is_partial (bool) –

    New in version 0.7.6.

    Flag for marking a Entry as partial. Partial entries have to be embedded into a Composite EntryGroup(type='Composite'). This means, that an entry is not self-contained and needs another entry to be complete.

Returns:

entry – Entry instance of the added entry entity

Return type:

metacatalog.Entry

Add Entry details#

metacatalog.api.add_details_to_entries(session: Session, entries: List[Union[int, str, Entry]], details: List[dict] = None, **kwargs) None#

Associate detail(s) to entrie(s). Add key-value pair details to one, or many Entry(s). The Entry(s) have to already exist in the database.

Parameters:
  • session (sqlalchemy.Session) – SQLAlchemy session connected to the database.

  • entries (list) – List of identifier or single identifier to load entries. If int, the Entry.id is assumed. If str, title is assumed. Can also pass a metacatalog.Entry object.

  • details (list, None) –

    New in version 0.1.8.

    List of dict of structure:

    [{
        'key': '',
        'value': '',
        'description': ''
    }]
    

    where the description is optional and can be omitted. If no descriptions are passed at all, you can also use **kwargs to pass key=value pairs. You can mix details and kwargs

Note

Each keyword argument will be added as a py:class:Detail <metacatalog.models.Detail> and linked to each entry.

Add keywords to entries#

metacatalog.api.add_keywords_to_entries(session: Session, entries: List[Union[int, str, Entry]], keywords: List[Union[int, str, Keyword]], alias=None) None

Associate keyword(s) to entrie(s)

Adds associations between entries and keywords. The Entry and Keyword instances have to already exist in the database. Keywords are usually prepopulated. You might want to alias an keyword or associate a value to it. Use the alias and value lists for this.

Parameters:
  • session (sqlalchemy.Session) – SQLAlchemy session connected to the database.

  • entries (list) – List of identifier or single identifier to load entries. If int, the Entry.id is assumed. If str, title is assumed. Can also pass a metacatalog.Entry object.

  • keywords (list) – List of identifier or single identifier to load keywords. If int, Keyword.id is assumed, If str, Keyword.value is assumed. Can also pass a metacatalog.Keyword object.

  • alias (list) –

    List of, or single alias names. The shape has to match the keywords parameter. These alias will rename the keywords on association. In case one instance should not recive an alias, pass None instead.

    Deprecated since version 0.4.5: ‘alias’ will be removed with a future release

Return type:

void

See also

metacatalog.Entry, metacatalog.Keyword