spinedb_api.db_mapping
This module defines the DatabaseMapping class, the main mean to communicate with a Spine DB.
If you’re planning to use this class, it is probably a good idea to first familiarize yourself a little bit with the
DB mapping schema.
Classes
Enables communication with a Spine DB. |
Module Contents
- class spinedb_api.db_mapping.DatabaseMapping(db_url, username=None, upgrade=False, backup_url='', create=False, apply_filters=True, memory=False, commit_lock=None, sqlite_timeout=1800)[source]
Bases:
spinedb_api.db_mapping_query_mixin.DatabaseMappingQueryMixin,spinedb_api.db_mapping_commit_mixin.DatabaseMappingCommitMixin,spinedb_api.db_mapping_base.DatabaseMappingBaseEnables communication with a Spine DB.
The DB is incrementally mapped into memory as data is requested/modified, following the DB mapping schema.
Data is typically retrieved using
item()orfind(). If the requested data is already in memory, it is returned from there; otherwise it is fetched from the DB, stored in memory, and then returned. In other words, the data is fetched from the DB exactly once.For convenience, we also provide specialized getter methods for each item type, e.g.,
entity()andfind_entities().Data is added via
add(); updated viaupdate(); removed viaremove(); and restored viarestore().add_or_update()adds an item or updates an existing one. All the above methods modify the in-memory mapping (not the DB itself). These methods also fetch data from the DB into the in-memory mapping to perform the necessary integrity checks (unique and foreign key constraints).For convenience, we also provide specialized ‘add’, ‘update’, ‘remove’, and ‘restore’ methods for each item type, e.g.,
add_entity(),update_entity(),remove_entity()andrestore_entity().Modifications to the in-memory mapping are committed (written) to the DB via
commit_session(), or rolled back (discarded) viarollback_session().The DB fetch status is reset via
refresh_session(). This allows new items in the DB (added by other clients in the meantime) to be retrieved as well.You can also control the fetching process via
fetch_more()and/orfetch_all(). For example, you can callfetch_more()in a dedicated thread while you do some work on the main thread. This will nicely place items in the in-memory mapping, so you can access them later, without the overhead of fetching them from the DB.The
query()method is also provided as an alternative way to retrieve data from the DB while bypassing the in-memory mapping entirely.You usually use this class as a context manager, e.g.:
with DatabaseMapping(db_url) as db_map: # Do stuff with db_map ...
or:
db_map = DatabaseMapping(db_url) ... with db_map: # Do stuff with db_map ...
- Parameters:
db_url (str or
URL) – A URL in RFC-1738 format pointing to the database to be mapped, or to a DB server.username (str, optional) – A user name. If not given, it gets replaced by the string anon.
upgrade (bool, optional) – Whether the DB at the given url should be upgraded to the most recent version.
backup_url (str, optional) – A URL to backup the DB before upgrading.
create (bool, optional) – Whether to create a new Spine DB at the given url if it’s not already one.
apply_filters (bool, optional) – Whether to apply filters in the url’s query segment.
commit_lock (threading.Lock, optional) – If given, committing to the DB is done with the lock.
memory (bool, optional) – Whether to use a SQLite memory DB as replacement for the original one.
sqlite_timeout (int, optional) – The number of seconds to wait before raising SQLite connection errors.
- static item_types() list[spinedb_api.helpers.ItemType][source]
Returns a list of public item types from the DB mapping schema (equivalent to the table names).
- static all_item_types() list[spinedb_api.helpers.ItemType][source]
Returns a list of all item types from the DB mapping schema (equivalent to the table names).
- static item_factory(item_type: spinedb_api.helpers.ItemType) Type[spinedb_api.db_mapping_base.MappedItemBase][source]
Returns a subclass of
MappedItemBaseto make items of given type.
- add(mapped_table: spinedb_api.db_mapping_base.MappedTable, **kwargs) spinedb_api.db_mapping_base.PublicItem[source]
Adds an item to the in-memory mapping.
Example:
with DatabaseMapping(db_url) as db_map: class_table = db_map.mapped_table("entity_class") db_map.add(class_table, name="musician") entity_table = db_map.mapped_table("entity") db_map.add(entity_table, entity_class_name="musician", name="Prince")
- item(mapped_table: spinedb_api.db_mapping_base.MappedTable, **kwargs) spinedb_api.db_mapping_base.PublicItem[source]
Returns an item matching the keyword arguments.
Example:
with DatabaseMapping(db_url) as db_map: entity_table = db_map.mapped_table("entity") prince = db_map.get_item(entity_table, entity_class_name="musician", name="Prince")
- find(mapped_table: spinedb_api.db_mapping_base.MappedTable, **kwargs) list[spinedb_api.db_mapping_base.PublicItem][source]
Finds items that match the keyword arguments.
Example:
with DatabaseMapping(db_url) as db_map: entity_table = db_map.mapped_table("entity") entities = db_map.find(entity_table, entity_class_name="musician") for entity in entities: print(f"{entity['name']}: {entity['description']}")
- static update(mapped_table: spinedb_api.db_mapping_base.MappedTable, **kwargs) spinedb_api.db_mapping_base.PublicItem | None[source]
Updates an existing item.
Returns the updated item or None if nothing was updated.
Example:
with DatabaseMapping(db_url) as db_map: entity_table = db_map.mapped_table("entity") prince = db_map.item(entity_table, entity_class_name="musician", name="Prince") db_map.update( entity_table, id=prince["id"], name="the Artist", description="Formerly known as Prince." )
- add_or_update(mapped_table: spinedb_api.db_mapping_base.MappedTable, **kwargs) spinedb_api.db_mapping_base.PublicItem | None[source]
Adds an item if it does not exist, otherwise updates it.
Returns the added/updated item or None if nothing was changed.
- static remove(mapped_table: spinedb_api.db_mapping_base.MappedTable, **kwargs) None[source]
Removes an item matching the keyword arguments.
Example:
with DatabaseMapping(db_url) as db_map: entity_table = db_map.mapped_table("entity") prince = db_map.item(entity_table, entity_class_name="musician", name="Prince") db_map.remove_item(entity_table, id=prince["id"])
- static restore(mapped_table: spinedb_api.db_mapping_base.MappedTable, **kwargs) spinedb_api.db_mapping_base.PublicItem[source]
Restores a previously removed item.
Example:
with DatabaseMapping(db_url) as db_map: entity_table = db_map.mapped_table("entity") db_map.restore(entity_table, entity_class_name="musician", name="Prince")
- get_item(item_type: spinedb_api.helpers.ItemType | spinedb_api.helpers.LegacyItemType, fetch: bool = True, skip_removed: bool = True, **kwargs) spinedb_api.db_mapping_base.PublicItem | dict[source]
Finds and returns an item matching the arguments, or an empty dict if none found.
This is legacy method. Use
item()instead. This method supports legacy item types, e.g. object and relationship_class.- Parameters:
item_type – One of
alternative,scenario,scenario_alternative,entity_class,display_mode,entity_class_display_mode,superclass_subclass,entity,entity_group,entity_alternative,parameter_value_list,list_value,parameter_type,parameter_group,parameter_definition,parameter_value,metadata,entity_metadata,parameter_value_metadata,entity_location.fetch – Whether to fetch the DB in case the item is not found in memory.
skip_removed – Whether to ignore removed items.
**kwargs – Fields and values for one the unique keys as specified for the item type in DB mapping schema.
- Returns:
PublicItemor empty dict
- get_items(item_type: spinedb_api.helpers.ItemType | spinedb_api.helpers.LegacyItemType, fetch: bool = True, skip_removed: bool = True, **kwargs) list[spinedb_api.db_mapping_base.PublicItem][source]
Finds and returns all the items of one type.
This is legacy method. Use
find()instead. This method supports legacy item types, e.g. object and relationship_class.- Parameters:
item_type – One of
alternative,scenario,scenario_alternative,entity_class,display_mode,entity_class_display_mode,superclass_subclass,entity,entity_group,entity_alternative,parameter_value_list,list_value,parameter_type,parameter_group,parameter_definition,parameter_value,metadata,entity_metadata,parameter_value_metadata,entity_location.fetch – Whether to fetch the DB before returning the items.
skip_removed – Whether to ignore removed items.
**kwargs – Fields and values for one the unique keys as specified for the item type in DB mapping schema.
- Returns:
The items.
- add_item(item_type: spinedb_api.helpers.ItemType | spinedb_api.helpers.LegacyItemType, check: bool = True, **kwargs) tuple[spinedb_api.db_mapping_base.PublicItem | None, str | None][source]
Adds an item to the in-memory mapping.
This is legacy method. Use
add()instead. This method supports legacy item types, e.g. object and relationship_class.- Parameters:
item_type – One of
alternative,scenario,scenario_alternative,entity_class,display_mode,entity_class_display_mode,superclass_subclass,entity,entity_group,entity_alternative,parameter_value_list,list_value,parameter_type,parameter_group,parameter_definition,parameter_value,metadata,entity_metadata,parameter_value_metadata,entity_location.check – Whether to check for data integrity.
**kwargs – Fields and values as specified for the item type in DB mapping schema.
- Returns:
The added item and any errors.
- add_items(item_type: spinedb_api.helpers.ItemType | spinedb_api.helpers.LegacyItemType, *items: dict, check: bool = True, strict: bool = False) tuple[list[spinedb_api.db_mapping_base.PublicItem | None], list[str | None]][source]
Adds many items to the in-memory mapping.
This is legacy method. Use the
add_entities(),add_entity_classes()etc. methods instead. This method supports legacy item types, e.g. object and relationship_class.- Parameters:
item_type – One of
alternative,scenario,scenario_alternative,entity_class,display_mode,entity_class_display_mode,superclass_subclass,entity,entity_group,entity_alternative,parameter_value_list,list_value,parameter_type,parameter_group,parameter_definition,parameter_value,metadata,entity_metadata,parameter_value_metadata,entity_location.*items – One or more
dictobjects mapping fields to values of the item type, as specified in DB mapping schema.check – Whether to check for data integrity.
strict – Whether the method should raise
SpineIntegrityErrorif the insertion of one of the items violates an integrity constraint.
- Returns:
items successfully added and found violations.
- update_item(item_type: spinedb_api.helpers.ItemType | spinedb_api.helpers.LegacyItemType, check: bool = True, **kwargs) tuple[spinedb_api.db_mapping_base.PublicItem | None, str | None][source]
Updates an item in the in-memory mapping.
This is legacy method. Use
update()instead. This method supports legacy item types, e.g. object and relationship_class.- Parameters:
item_type – One of
alternative,scenario,scenario_alternative,entity_class,display_mode,entity_class_display_mode,superclass_subclass,entity,entity_group,entity_alternative,parameter_value_list,list_value,parameter_type,parameter_group,parameter_definition,parameter_value,metadata,entity_metadata,parameter_value_metadata,entity_location.check – Whether to check for data integrity and legacy item types.
**kwargs – Fields to update and their new values as specified for the item type in DB mapping schema.
- Returns:
The updated item and any errors.
- update_items(item_type: spinedb_api.helpers.ItemType | spinedb_api.helpers.LegacyItemType, *items: dict, check: bool = True, strict: bool = False) tuple[list[spinedb_api.db_mapping_base.PublicItem | None], list[str | None]][source]
Updates many items in the in-memory mapping.
This is legacy method. Use the
update_entities(),update_entity_classes()etc. methods instead. This method supports legacy item types, e.g. object and relationship_class.- Parameters:
item_type – One of
alternative,scenario,scenario_alternative,entity_class,display_mode,entity_class_display_mode,superclass_subclass,entity,entity_group,entity_alternative,parameter_value_list,list_value,parameter_type,parameter_group,parameter_definition,parameter_value,metadata,entity_metadata,parameter_value_metadata,entity_location.*items – One or more
dictobjects mapping fields to values of the item type, as specified in DB mapping schema and including the id.check – Whether to check for data integrity.
strict – Whether the method should raise
SpineIntegrityErrorif the update of one of the items violates an integrity constraint.
- Returns:
items successfully updated and found violations.
- add_update_item(item_type: spinedb_api.helpers.ItemType | spinedb_api.helpers.LegacyItemType, check: bool = True, **kwargs) tuple[spinedb_api.db_mapping_base.PublicItem | None, spinedb_api.db_mapping_base.PublicItem | None, str | None][source]
Adds an item to the in-memory mapping if it doesn’t exist; otherwise updates the current one.
This is legacy method. Use
add_or_update()instead. This method supports legacy item types, e.g. object and relationship_class.- Parameters:
item_type – One of
alternative,scenario,scenario_alternative,entity_class,display_mode,entity_class_display_mode,superclass_subclass,entity,entity_group,entity_alternative,parameter_value_list,list_value,parameter_type,parameter_group,parameter_definition,parameter_value,metadata,entity_metadata,parameter_value_metadata,entity_location.check – Whether to check for data integrity.
**kwargs – Fields and values as specified for the item type in DB mapping schema.
- Returns:
The added item if any, the updated item if any, and any errors.
- add_update_items(item_type: spinedb_api.helpers.ItemType | spinedb_api.helpers.LegacyItemType, *items: spinedb_api.db_mapping_base.PublicItem | spinedb_api.db_mapping_base.MappedItemBase | dict, check: bool = True, strict: bool = False) tuple[list[spinedb_api.db_mapping_base.PublicItem | None], list[spinedb_api.db_mapping_base.PublicItem | None], list[str | None]][source]
Adds or updates many items into the in-memory mapping.
This is legacy method. Use
add_or_update_entities(),add_or_update_entity_classes()etc. methods instead. This method supports legacy item types, e.g. object and relationship_class.- Parameters:
item_type – One of
alternative,scenario,scenario_alternative,entity_class,display_mode,entity_class_display_mode,superclass_subclass,entity,entity_group,entity_alternative,parameter_value_list,list_value,parameter_type,parameter_group,parameter_definition,parameter_value,metadata,entity_metadata,parameter_value_metadata,entity_location.*items – One or more
dictobjects mapping fields to values of the item type, as specified in DB mapping schema.check – Whether to check for data integrity.
strict – Whether the method should raise
SpineIntegrityErrorif the insertion of one of the items violates an integrity constraint.
- Returns:
items successfully added, items successfully updated, and found violations.
- remove_item(item_type: spinedb_api.helpers.ItemType | spinedb_api.helpers.LegacyItemType, id_: spinedb_api.temp_id.TempId | int, check: bool = True) tuple[spinedb_api.db_mapping_base.PublicItem | None, str | None][source]
Removes an item from the in-memory mapping.
This is legacy method. Use
remove()instead. This method supports legacy item types, e.g. object and relationship_class.- Parameters:
item_type – One of
alternative,scenario,scenario_alternative,entity_class,display_mode,entity_class_display_mode,superclass_subclass,entity,entity_group,entity_alternative,parameter_value_list,list_value,parameter_type,parameter_group,parameter_definition,parameter_value,metadata,entity_metadata,parameter_value_metadata,entity_location.id – The id of the item to remove.
check – Whether to check for data integrity.
- Returns:
The removed item and any errors.
- Return type:
tuple(
PublicItemor None, str)
- remove_items(item_type: spinedb_api.helpers.ItemType | spinedb_api.helpers.LegacyItemType, *ids: spinedb_api.temp_id.TempId | int, check: bool = True, strict: bool = False) tuple[list[spinedb_api.db_mapping_base.PublicItem], list[str]][source]
Removes many items from the in-memory mapping.
This is legacy method. Use
remove_entities(),remove_entity_classes()etc. methods instead. This method supports legacy item types, e.g. object and relationship_class.- Parameters:
item_type – One of
alternative,scenario,scenario_alternative,entity_class,display_mode,entity_class_display_mode,superclass_subclass,entity,entity_group,entity_alternative,parameter_value_list,list_value,parameter_type,parameter_group,parameter_definition,parameter_value,metadata,entity_metadata,parameter_value_metadata,entity_location.*ids – Ids of items to be removed.
check – Whether to check for data integrity.
strict – Whether the method should raise
SpineIntegrityErrorif the update of one of the items violates an integrity constraint.
- Returns:
items successfully removed and found violations.
- restore_item(item_type: spinedb_api.helpers.ItemType | spinedb_api.helpers.LegacyItemType, id_: spinedb_api.temp_id.TempId | int) tuple[spinedb_api.db_mapping_base.PublicItem | None, str | None][source]
Restores a previously removed item into the in-memory mapping.
This is legacy method. Use
restore()instead. This method supports legacy item types, e.g. object and relationship_class.- Parameters:
item_type – One of
alternative,scenario,scenario_alternative,entity_class,display_mode,entity_class_display_mode,superclass_subclass,entity,entity_group,entity_alternative,parameter_value_list,list_value,parameter_type,parameter_group,parameter_definition,parameter_value,metadata,entity_metadata,parameter_value_metadata,entity_location.id – The id of the item to restore.
- Returns:
The restored item if any and possible error.
- restore_items(item_type: spinedb_api.helpers.ItemType | spinedb_api.helpers.LegacyItemType, *ids: spinedb_api.temp_id.TempId | int) tuple[list[spinedb_api.db_mapping_base.PublicItem | None], list[str | None]][source]
Restores many previously removed items into the in-memory mapping.
This is legacy method. Use
restore_entities(),restore_entity_classes()etc. methods instead. This method supports legacy item types, e.g. object and relationship_class.- Parameters:
item_type – One of
alternative,scenario,scenario_alternative,entity_class,display_mode,entity_class_display_mode,superclass_subclass,entity,entity_group,entity_alternative,parameter_value_list,list_value,parameter_type,parameter_group,parameter_definition,parameter_value,metadata,entity_metadata,parameter_value_metadata,entity_location.*ids – Ids of items to be removed.
- Returns:
items successfully restored and found violations.
- purge_items(item_type: spinedb_api.helpers.ItemType | spinedb_api.helpers.LegacyItemType) bool[source]
Removes all items of one type.
This is legacy method. Use
remove_entity(),remove_entity_class()etc. withid=Asteriskinstead. This method supports legacy item types, e.g. object and relationship_class.- Parameters:
item_type – One of
alternative,scenario,scenario_alternative,entity_class,display_mode,entity_class_display_mode,superclass_subclass,entity,entity_group,entity_alternative,parameter_value_list,list_value,parameter_type,parameter_group,parameter_definition,parameter_value,metadata,entity_metadata,parameter_value_metadata,entity_location.- Returns:
True if any data was removed, False otherwise.
- fetch_more(item_type: spinedb_api.helpers.ItemType | spinedb_api.helpers.LegacyItemType, offset: int = 0, limit: int | None = None, **kwargs) list[spinedb_api.db_mapping_base.PublicItem][source]
Fetches items from the DB into the in-memory mapping, incrementally.
- Parameters:
item_type – One of
alternative,scenario,scenario_alternative,entity_class,display_mode,entity_class_display_mode,superclass_subclass,entity,entity_group,entity_alternative,parameter_value_list,list_value,parameter_type,parameter_group,parameter_definition,parameter_value,metadata,entity_metadata,parameter_value_metadata,entity_location.offset – The initial row.
limit – The maximum number of rows to fetch.
**kwargs – Fields and values for one the unique keys as specified for the item type in DB mapping schema.
- Returns:
The items fetched.
- fetch_all(*item_types: spinedb_api.helpers.ItemType | spinedb_api.helpers.LegacyItemType) list[spinedb_api.db_mapping_base.PublicItem][source]
Fetches items from the DB into the in-memory mapping. Unlike
fetch_more(), this method fetches entire tables.- Parameters:
*item_types – One or more of
alternative,scenario,scenario_alternative,entity_class,display_mode,entity_class_display_mode,superclass_subclass,entity,entity_group,entity_alternative,parameter_value_list,list_value,parameter_type,parameter_group,parameter_definition,parameter_value,metadata,entity_metadata,parameter_value_metadata,entity_location. If none given, then the entire DB is fetched.
- query(*entities, **kwargs) sqlalchemy.orm.Query[source]
Returns a
Queryobject to execute against the mapped DB.To perform custom
SELECTstatements, call this method with one or more of the documented subquery properties ofDatabaseMappingQueryMixinreturningSubqueryobjetcs. For example, to select the entity class withidequal to 1:from spinedb_api import DatabaseMapping url = 'sqlite:///spine.db' ... with DatabaseMapping(url) as db_map: entity_record = db_map.query(db_map.entity_class_sq).filter_by(id=1).one_or_none() if entity_record is not None: ...
To perform more complex queries, use SQLAlchemy’s
Queryinterface. For example, to select all entity class names and the names of their entities concatenated in a comma-separated string:from sqlalchemy import func with DatabaseMapping(ur) as db_map: classes = db_map.query( db_map.entity_class_sq.c.name, func.group_concat(db_map.entity_sq.c.name).label("entities") ).filter( db_map.entity_sq.c.class_id == db_map.entity_class_sq.c.id ).group_by( db_map.entity_class_sq.c.name ).all() for entity_class in classes: print(f"{entity_class.name}: {entity_class.entities}")
- Returns:
The resulting query.
- Return type:
- commit_session(comment: str, apply_compatibility_transforms: bool = True) spinedb_api.compatibility.CompatibilityTransformations[source]
Commits the changes from the in-memory mapping to the database.
- Parameters:
comment – commit message
apply_compatibility_transforms – if True, apply compatibility transforms
- Returns:
compatibility transformations
- has_external_commits() bool[source]
Tests whether the database has had commits from other sources than this mapping.
- Returns:
True if database has external commits, False otherwise
- get_filter_configs() list[dict][source]
Returns the config dicts of filters applied to this database mapping.
- alternative(**kwargs)[source]
Returns an alternative item matching the keyword arguments.
- Parameters:
name (str) – The alternative name.
- Returns:
PublicItem
- scenario(**kwargs)[source]
Returns a scenario item matching the keyword arguments.
- Parameters:
name (str) – The scenario name.
- Returns:
PublicItem
- scenario_alternative(**kwargs)[source]
Returns a scenario_alternative item matching the keyword arguments.
- entity_class(**kwargs)[source]
Returns an entity_class item matching the keyword arguments.
- Parameters:
name (str) – The class name.
- Returns:
PublicItem
- display_mode(**kwargs)[source]
Returns a display_mode item matching the keyword arguments.
- Parameters:
name (str) – The display mode name.
- Returns:
PublicItem
- entity_class_display_mode(**kwargs)[source]
Returns an entity_class_display_mode item matching the keyword arguments.
- superclass_subclass(**kwargs)[source]
Returns a superclass_subclass item matching the keyword arguments.
- Parameters:
subclass_name (str) – The subclass name.
- Returns:
PublicItem
- entity_alternative(**kwargs)[source]
Returns an entity_alternative item matching the keyword arguments.
- parameter_value_list(**kwargs)[source]
Returns a parameter_value_list item matching the keyword arguments.
- Parameters:
name (str) – The parameter value list name.
- Returns:
PublicItem
- parameter_group(**kwargs)[source]
Returns a parameter_group item matching the keyword arguments.
- Parameters:
name (str) – The parameter group name.
- Returns:
PublicItem
- parameter_definition(**kwargs)[source]
Returns a parameter_definition item matching the keyword arguments.
- parameter_value(**kwargs)[source]
Returns a parameter_value item matching the keyword arguments.
- Parameters:
entity_class_name (str) – The entity class name.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
alternative_name (str, optional) – The alternative name - defaults to ‘Base’.
parameter_definition_name (str) – The parameter name.
- Returns:
PublicItem
- entity_metadata(**kwargs)[source]
Returns an entity_metadata item matching the keyword arguments.
- Parameters:
metadata_name (str) – The metadata entry name.
entity_class_name (str) – The entity class name.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
metadata_value (str) – The metadata entry value.
- Returns:
PublicItem
- parameter_value_metadata(**kwargs)[source]
Returns a parameter_value_metadata item matching the keyword arguments.
- Parameters:
alternative_name (str) – The alternative name.
metadata_name (str) – The metadata entry name.
entity_class_name (str) – The entity class name.
metadata_value (str) – The metadata entry value.
parameter_definition_name (str) – The parameter name.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
- Returns:
PublicItem
- find_alternatives(**kwargs)[source]
Finds and returns all alternative items matching the keyword arguments.
- Parameters:
name (str) – The alternative name.
- Returns:
The items.
- Return type:
list of
PublicItem
- find_scenarios(**kwargs)[source]
Finds and returns all scenario items matching the keyword arguments.
- Parameters:
name (str) – The scenario name.
- Returns:
The items.
- Return type:
list of
PublicItem
- find_scenario_alternatives(**kwargs)[source]
Finds and returns all scenario_alternative items matching the keyword arguments.
- find_entity_classes(**kwargs)[source]
Finds and returns all entity_class items matching the keyword arguments.
- Parameters:
name (str) – The class name.
- Returns:
The items.
- Return type:
list of
PublicItem
- find_display_modes(**kwargs)[source]
Finds and returns all display_mode items matching the keyword arguments.
- Parameters:
name (str) – The display mode name.
- Returns:
The items.
- Return type:
list of
PublicItem
- find_entity_class_display_modes(**kwargs)[source]
Finds and returns all entity_class_display_mode items matching the keyword arguments.
- find_superclass_subclasses(**kwargs)[source]
Finds and returns all superclass_subclass items matching the keyword arguments.
- Parameters:
subclass_name (str) – The subclass name.
- Returns:
The items.
- Return type:
list of
PublicItem
- find_entities(**kwargs)[source]
Finds and returns all entity items matching the keyword arguments.
- Parameters:
- Returns:
The items.
- Return type:
list of
PublicItem
- find_entity_groups(**kwargs)[source]
Finds and returns all entity_group items matching the keyword arguments.
- find_entity_alternatives(**kwargs)[source]
Finds and returns all entity_alternative items matching the keyword arguments.
- Parameters:
- Returns:
The items.
- Return type:
list of
PublicItem
- find_parameter_value_lists(**kwargs)[source]
Finds and returns all parameter_value_list items matching the keyword arguments.
- Parameters:
name (str) – The parameter value list name.
- Returns:
The items.
- Return type:
list of
PublicItem
- find_list_values(**kwargs)[source]
Finds and returns all list_value items matching the keyword arguments.
- find_parameter_types(**kwargs)[source]
Finds and returns all parameter_type items matching the keyword arguments.
- find_parameter_groups(**kwargs)[source]
Finds and returns all parameter_group items matching the keyword arguments.
- Parameters:
name (str) – The parameter group name.
- Returns:
The items.
- Return type:
list of
PublicItem
- find_parameter_definitions(**kwargs)[source]
Finds and returns all parameter_definition items matching the keyword arguments.
- find_parameter_values(**kwargs)[source]
Finds and returns all parameter_value items matching the keyword arguments.
- Parameters:
entity_class_name (str) – The entity class name.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
alternative_name (str, optional) – The alternative name - defaults to ‘Base’.
parameter_definition_name (str) – The parameter name.
- Returns:
The items.
- Return type:
list of
PublicItem
- find_metadata_items(**kwargs)[source]
Finds and returns all metadata items matching the keyword arguments.
- find_entity_metadata_items(**kwargs)[source]
Finds and returns all entity_metadata items matching the keyword arguments.
- Parameters:
metadata_name (str) – The metadata entry name.
entity_class_name (str) – The entity class name.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
metadata_value (str) – The metadata entry value.
- Returns:
The items.
- Return type:
list of
PublicItem
- find_parameter_value_metadata_items(**kwargs)[source]
Finds and returns all parameter_value_metadata items matching the keyword arguments.
- Parameters:
alternative_name (str) – The alternative name.
metadata_name (str) – The metadata entry name.
entity_class_name (str) – The entity class name.
metadata_value (str) – The metadata entry value.
parameter_definition_name (str) – The parameter name.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
- Returns:
The items.
- Return type:
list of
PublicItem
- find_entity_locations(**kwargs)[source]
Finds and returns all entity_location items matching the keyword arguments.
- add_scenario_alternative(**kwargs)[source]
Adds a scenario_alternative item to the in-memory mapping.
- add_entity_class(**kwargs)[source]
Adds an entity_class item to the in-memory mapping.
- Parameters:
name (str) – The class name.
dimension_name_list (tuple, optional) – The dimension names for a multi-dimensional class.
entity_class_byname (tuple) – A tuple with the class name as single element if the class is 0-dimensional, or the 0-dimensional class names if it is multi-dimensional.
description (str, optional) – The class description.
display_icon (int, optional) – An integer representing an icon within your application.
display_order (int, optional) – Not in use at the moment.
hidden (int, optional) – Not in use at the moment.
active_by_default (bool, optional) – Default activity for the entity alternatives of the class.
- Returns:
The added item.
- Return type:
PublicItem
- add_entity_class_display_mode(**kwargs)[source]
Adds an entity_class_display_mode item to the in-memory mapping.
- Parameters:
entity_class_name (str) – The entity class name.
display_mode_name (int) – The display mode name.
display_order (int) – The display order.
display_status (str) – The display status; one of ‘visible’, ‘hidden’ or ‘greyed_out’.
display_font_color (str, optional) – The color of the font.
display_background_color (str, optional) – The color of the background.
- Returns:
The added item.
- Return type:
PublicItem
- add_superclass_subclass(**kwargs)[source]
Adds a superclass_subclass item to the in-memory mapping.
- add_entity(**kwargs)[source]
Adds an entity item to the in-memory mapping.
- Parameters:
entity_class_name (str) – The entity class name.
name (str) – The entity name.
element_name_list (tuple) – The element names if the entity is multi-dimensional.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
description (str, optional) – The entity description.
lat (float, optional) – The latitude of entity.
lon (float, optional) – The longitude of entity.
alt (float, optional) – The altitude of entity.
shape_name (str, optional) – The name of the entity’s shape.
shape_blob (str, optional) – The shape as GEOJSON string.
- Returns:
The added item.
- Return type:
PublicItem
- add_entity_alternative(**kwargs)[source]
Adds an entity_alternative item to the in-memory mapping.
- Parameters:
entity_class_name (str) – The entity class name.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
alternative_name (str) – The alternative name.
active (bool, optional) – Whether the entity is active in the alternative - defaults to True.
- Returns:
The added item.
- Return type:
PublicItem
- add_parameter_value_list(**kwargs)[source]
Adds a parameter_value_list item to the in-memory mapping.
- Parameters:
name (str) – The parameter value list name.
- Returns:
The added item.
- Return type:
PublicItem
- add_list_value(**kwargs)[source]
Adds a list_value item to the in-memory mapping.
- Parameters:
parameter_value_list_name (str) – The parameter value list name.
value (bytes) – The value’s database representation.
type (str, optional) – The value’s type.
parsed_value (ParameterValue, optional) – The value.
index (int, optional) – The value index.
- Returns:
The added item.
- Return type:
PublicItem
- add_parameter_definition(**kwargs)[source]
Adds a parameter_definition item to the in-memory mapping.
- Parameters:
entity_class_name (str) – The entity class name.
name (str) – The parameter name.
parameter_group_name (str, optional) – The name of the group of the parameter.
parameter_type_list (tuple, optional) – List of valid value types.
default_value (bytes, optional) – The default value’s database representation.
default_type (str, optional) – The default value’s type.
parsed_value (ParameterValue, optional) – The default value.
parameter_value_list_name (str, optional) – The parameter value list name if any.
description (str, optional) – The parameter description.
- Returns:
The added item.
- Return type:
PublicItem
- add_parameter_value(**kwargs)[source]
Adds a parameter_value item to the in-memory mapping.
- Parameters:
entity_class_name (str) – The entity class name.
parameter_definition_name (str) – The parameter name.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
value (bytes) – The value’s database representation.
type (str, optional) – The value’s type. Optional only when value is null.
parsed_value (ParameterValue, optional) – The value.
alternative_name (str, optional) – The alternative name - defaults to ‘Base’.
- Returns:
The added item.
- Return type:
PublicItem
- add_entity_metadata(**kwargs)[source]
Adds an entity_metadata item to the in-memory mapping.
- Parameters:
entity_class_name (str) – The entity class name.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
metadata_name (str) – The metadata entry name.
metadata_value (str) – The metadata entry value.
- Returns:
The added item.
- Return type:
PublicItem
- add_parameter_value_metadata(**kwargs)[source]
Adds a parameter_value_metadata item to the in-memory mapping.
- Parameters:
entity_class_name (str) – The entity class name.
parameter_definition_name (str) – The parameter name.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
alternative_name (str) – The alternative name.
metadata_name (str) – The metadata entry name.
metadata_value (str) – The metadata entry value.
- Returns:
The added item.
- Return type:
PublicItem
- add_entity_location(**kwargs)[source]
Adds an entity_location item to the in-memory mapping.
- Parameters:
entity_class_name (str) – The entity class name.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
lat (float, optional) – Latitude.
lon (float, optional) – Longitude.
alt (float, optional) – Altitude.
shape_name (str, optional) – Name identifying the shape.
shape_blob (str, optional) – Shape as GEOJSON feature.
- Returns:
The added item.
- Return type:
PublicItem
- add_scenario_alternatives(items)[source]
Adds multiple scenario_alternative items to the in-memory mapping.
- add_entity_class_display_modes(items)[source]
Adds multiple entity_class_display_mode items to the in-memory mapping.
- add_superclass_subclasses(items)[source]
Adds multiple superclass_subclass items to the in-memory mapping.
- add_entity_alternatives(items)[source]
Adds multiple entity_alternative items to the in-memory mapping.
- add_parameter_value_lists(items)[source]
Adds multiple parameter_value_list items to the in-memory mapping.
- add_parameter_definitions(items)[source]
Adds multiple parameter_definition items to the in-memory mapping.
- add_entity_metadata_items(items)[source]
Adds multiple entity_metadata items to the in-memory mapping.
- add_parameter_value_metadata_items(items)[source]
Adds multiple parameter_value_metadata items to the in-memory mapping.
- update_scenario_alternative(**kwargs)[source]
Updates a scenario_alternative item in the in-memory mapping.
- update_entity_class(**kwargs)[source]
Updates an entity_class item in the in-memory mapping.
- Parameters:
id (int) – The id of the item to update.
name (str) – The class name.
dimension_name_list (tuple, optional) – The dimension names for a multi-dimensional class.
entity_class_byname (tuple) – A tuple with the class name as single element if the class is 0-dimensional, or the 0-dimensional class names if it is multi-dimensional.
description (str, optional) – The class description.
display_icon (int, optional) – An integer representing an icon within your application.
display_order (int, optional) – Not in use at the moment.
hidden (int, optional) – Not in use at the moment.
active_by_default (bool, optional) – Default activity for the entity alternatives of the class.
- Returns:
The updated item or None if nothing was updated.
- Return type:
PublicItemor None
- update_entity_class_display_mode(**kwargs)[source]
Updates an entity_class_display_mode item in the in-memory mapping.
- Parameters:
id (int) – The id of the item to update.
entity_class_name (str) – The entity class name.
display_mode_name (int) – The display mode name.
display_order (int) – The display order.
display_status (str) – The display status; one of ‘visible’, ‘hidden’ or ‘greyed_out’.
display_font_color (str, optional) – The color of the font.
display_background_color (str, optional) – The color of the background.
- Returns:
The updated item or None if nothing was updated.
- Return type:
PublicItemor None
- update_superclass_subclass(**kwargs)[source]
Updates a superclass_subclass item in the in-memory mapping.
- update_entity(**kwargs)[source]
Updates an entity item in the in-memory mapping.
- Parameters:
id (int) – The id of the item to update.
entity_class_name (str) – The entity class name.
name (str) – The entity name.
element_name_list (tuple) – The element names if the entity is multi-dimensional.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
description (str, optional) – The entity description.
lat (float, optional) – The latitude of entity.
lon (float, optional) – The longitude of entity.
alt (float, optional) – The altitude of entity.
shape_name (str, optional) – The name of the entity’s shape.
shape_blob (str, optional) – The shape as GEOJSON string.
- Returns:
The updated item or None if nothing was updated.
- Return type:
PublicItemor None
- update_entity_alternative(**kwargs)[source]
Updates an entity_alternative item in the in-memory mapping.
- Parameters:
id (int) – The id of the item to update.
entity_class_name (str) – The entity class name.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
alternative_name (str) – The alternative name.
active (bool, optional) – Whether the entity is active in the alternative - defaults to True.
- Returns:
The updated item or None if nothing was updated.
- Return type:
PublicItemor None
- update_parameter_value_list(**kwargs)[source]
Updates a parameter_value_list item in the in-memory mapping.
- update_list_value(**kwargs)[source]
Updates a list_value item in the in-memory mapping.
- Parameters:
- Returns:
The updated item or None if nothing was updated.
- Return type:
PublicItemor None
- update_parameter_type(**kwargs)[source]
Updates a parameter_type item in the in-memory mapping.
- Parameters:
- Returns:
The updated item or None if nothing was updated.
- Return type:
PublicItemor None
- update_parameter_definition(**kwargs)[source]
Updates a parameter_definition item in the in-memory mapping.
- Parameters:
id (int) – The id of the item to update.
entity_class_name (str) – The entity class name.
name (str) – The parameter name.
parameter_group_name (str, optional) – The name of the group of the parameter.
parameter_type_list (tuple, optional) – List of valid value types.
default_value (bytes, optional) – The default value’s database representation.
default_type (str, optional) – The default value’s type.
parsed_value (ParameterValue, optional) – The default value.
parameter_value_list_name (str, optional) – The parameter value list name if any.
description (str, optional) – The parameter description.
- Returns:
The updated item or None if nothing was updated.
- Return type:
PublicItemor None
- update_parameter_value(**kwargs)[source]
Updates a parameter_value item in the in-memory mapping.
- Parameters:
id (int) – The id of the item to update.
entity_class_name (str) – The entity class name.
parameter_definition_name (str) – The parameter name.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
value (bytes) – The value’s database representation.
type (str, optional) – The value’s type. Optional only when value is null.
parsed_value (ParameterValue, optional) – The value.
alternative_name (str, optional) – The alternative name - defaults to ‘Base’.
- Returns:
The updated item or None if nothing was updated.
- Return type:
PublicItemor None
- update_entity_metadata(**kwargs)[source]
Updates an entity_metadata item in the in-memory mapping.
- Parameters:
id (int) – The id of the item to update.
entity_class_name (str) – The entity class name.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
metadata_name (str) – The metadata entry name.
metadata_value (str) – The metadata entry value.
- Returns:
The updated item or None if nothing was updated.
- Return type:
PublicItemor None
- update_parameter_value_metadata(**kwargs)[source]
Updates a parameter_value_metadata item in the in-memory mapping.
- Parameters:
id (int) – The id of the item to update.
entity_class_name (str) – The entity class name.
parameter_definition_name (str) – The parameter name.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
alternative_name (str) – The alternative name.
metadata_name (str) – The metadata entry name.
metadata_value (str) – The metadata entry value.
- Returns:
The updated item or None if nothing was updated.
- Return type:
PublicItemor None
- update_entity_location(**kwargs)[source]
Updates an entity_location item in the in-memory mapping.
- Parameters:
id (int) – The id of the item to update.
entity_class_name (str) – The entity class name.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
lat (float, optional) – Latitude.
lon (float, optional) – Longitude.
alt (float, optional) – Altitude.
shape_name (str, optional) – Name identifying the shape.
shape_blob (str, optional) – Shape as GEOJSON feature.
- Returns:
The updated item or None if nothing was updated.
- Return type:
PublicItemor None
- update_scenario_alternatives(items)[source]
Updates multiple scenario_alternative items in the in-memory mapping.
- update_entity_class_display_modes(items)[source]
Updates multiple entity_class_display_mode items in the in-memory mapping.
- update_superclass_subclasses(items)[source]
Updates multiple superclass_subclass items in the in-memory mapping.
- update_entity_alternatives(items)[source]
Updates multiple entity_alternative items in the in-memory mapping.
- update_parameter_value_lists(items)[source]
Updates multiple parameter_value_list items in the in-memory mapping.
- update_parameter_types(items)[source]
Updates multiple parameter_type items in the in-memory mapping.
- update_parameter_groups(items)[source]
Updates multiple parameter_group items in the in-memory mapping.
- update_parameter_definitions(items)[source]
Updates multiple parameter_definition items in the in-memory mapping.
- update_parameter_values(items)[source]
Updates multiple parameter_value items in the in-memory mapping.
- update_entity_metadata_items(items)[source]
Updates multiple entity_metadata items in the in-memory mapping.
- update_parameter_value_metadata_items(items)[source]
Updates multiple parameter_value_metadata items in the in-memory mapping.
- update_entity_locations(items)[source]
Updates multiple entity_location items in the in-memory mapping.
- add_or_update_alternative(**kwargs)[source]
Adds an alternative item to the in-memory mapping if it doesn’t exist; otherwise updates the current one.
- add_or_update_scenario(**kwargs)[source]
Adds a scenario item to the in-memory mapping if it doesn’t exist; otherwise updates the current one.
- add_or_update_scenario_alternative(**kwargs)[source]
Adds a scenario_alternative item to the in-memory mapping if it doesn’t exist; otherwise updates the current one.
- add_or_update_entity_class(**kwargs)[source]
Adds an entity_class item to the in-memory mapping if it doesn’t exist; otherwise updates the current one.
- Parameters:
name (str) – The class name.
dimension_name_list (tuple, optional) – The dimension names for a multi-dimensional class.
entity_class_byname (tuple) – A tuple with the class name as single element if the class is 0-dimensional, or the 0-dimensional class names if it is multi-dimensional.
description (str, optional) – The class description.
display_icon (int, optional) – An integer representing an icon within your application.
display_order (int, optional) – Not in use at the moment.
hidden (int, optional) – Not in use at the moment.
active_by_default (bool, optional) – Default activity for the entity alternatives of the class.
- Returns:
The added or updated item or None if nothing was added or updated.
- Return type:
PublicItemor None
- add_or_update_display_mode(**kwargs)[source]
Adds a display_mode item to the in-memory mapping if it doesn’t exist; otherwise updates the current one.
- add_or_update_entity_class_display_mode(**kwargs)[source]
Adds an entity_class_display_mode item to the in-memory mapping if it doesn’t exist; otherwise updates the current one.
- Parameters:
entity_class_name (str) – The entity class name.
display_mode_name (int) – The display mode name.
display_order (int) – The display order.
display_status (str) – The display status; one of ‘visible’, ‘hidden’ or ‘greyed_out’.
display_font_color (str, optional) – The color of the font.
display_background_color (str, optional) – The color of the background.
- Returns:
The added or updated item or None if nothing was added or updated.
- Return type:
PublicItemor None
- add_or_update_superclass_subclass(**kwargs)[source]
Adds a superclass_subclass item to the in-memory mapping if it doesn’t exist; otherwise updates the current one.
- add_or_update_entity(**kwargs)[source]
Adds an entity item to the in-memory mapping if it doesn’t exist; otherwise updates the current one.
- Parameters:
entity_class_name (str) – The entity class name.
name (str) – The entity name.
element_name_list (tuple) – The element names if the entity is multi-dimensional.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
description (str, optional) – The entity description.
lat (float, optional) – The latitude of entity.
lon (float, optional) – The longitude of entity.
alt (float, optional) – The altitude of entity.
shape_name (str, optional) – The name of the entity’s shape.
shape_blob (str, optional) – The shape as GEOJSON string.
- Returns:
The added or updated item or None if nothing was added or updated.
- Return type:
PublicItemor None
- add_or_update_entity_group(**kwargs)[source]
Adds an entity_group item to the in-memory mapping if it doesn’t exist; otherwise updates the current one.
- add_or_update_entity_alternative(**kwargs)[source]
Adds an entity_alternative item to the in-memory mapping if it doesn’t exist; otherwise updates the current one.
- Parameters:
entity_class_name (str) – The entity class name.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
alternative_name (str) – The alternative name.
active (bool, optional) – Whether the entity is active in the alternative - defaults to True.
- Returns:
The added or updated item or None if nothing was added or updated.
- Return type:
PublicItemor None
- add_or_update_parameter_value_list(**kwargs)[source]
Adds a parameter_value_list item to the in-memory mapping if it doesn’t exist; otherwise updates the current one.
- Parameters:
name (str) – The parameter value list name.
- Returns:
The added or updated item or None if nothing was added or updated.
- Return type:
PublicItemor None
- add_or_update_list_value(**kwargs)[source]
Adds a list_value item to the in-memory mapping if it doesn’t exist; otherwise updates the current one.
- Parameters:
parameter_value_list_name (str) – The parameter value list name.
value (bytes) – The value’s database representation.
type (str, optional) – The value’s type.
parsed_value (ParameterValue, optional) – The value.
index (int, optional) – The value index.
- Returns:
The added or updated item or None if nothing was added or updated.
- Return type:
PublicItemor None
- add_or_update_parameter_type(**kwargs)[source]
Adds a parameter_type item to the in-memory mapping if it doesn’t exist; otherwise updates the current one.
- add_or_update_parameter_group(**kwargs)[source]
Adds a parameter_group item to the in-memory mapping if it doesn’t exist; otherwise updates the current one.
- add_or_update_parameter_definition(**kwargs)[source]
Adds a parameter_definition item to the in-memory mapping if it doesn’t exist; otherwise updates the current one.
- Parameters:
entity_class_name (str) – The entity class name.
name (str) – The parameter name.
parameter_group_name (str, optional) – The name of the group of the parameter.
parameter_type_list (tuple, optional) – List of valid value types.
default_value (bytes, optional) – The default value’s database representation.
default_type (str, optional) – The default value’s type.
parsed_value (ParameterValue, optional) – The default value.
parameter_value_list_name (str, optional) – The parameter value list name if any.
description (str, optional) – The parameter description.
- Returns:
The added or updated item or None if nothing was added or updated.
- Return type:
PublicItemor None
- add_or_update_parameter_value(**kwargs)[source]
Adds a parameter_value item to the in-memory mapping if it doesn’t exist; otherwise updates the current one.
- Parameters:
entity_class_name (str) – The entity class name.
parameter_definition_name (str) – The parameter name.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
value (bytes) – The value’s database representation.
type (str, optional) – The value’s type. Optional only when value is null.
parsed_value (ParameterValue, optional) – The value.
alternative_name (str, optional) – The alternative name - defaults to ‘Base’.
- Returns:
The added or updated item or None if nothing was added or updated.
- Return type:
PublicItemor None
- add_or_update_metadata(**kwargs)[source]
Adds a metadata item to the in-memory mapping if it doesn’t exist; otherwise updates the current one.
- add_or_update_entity_metadata(**kwargs)[source]
Adds an entity_metadata item to the in-memory mapping if it doesn’t exist; otherwise updates the current one.
- Parameters:
entity_class_name (str) – The entity class name.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
metadata_name (str) – The metadata entry name.
metadata_value (str) – The metadata entry value.
- Returns:
The added or updated item or None if nothing was added or updated.
- Return type:
PublicItemor None
- add_or_update_parameter_value_metadata(**kwargs)[source]
Adds a parameter_value_metadata item to the in-memory mapping if it doesn’t exist; otherwise updates the current one.
- Parameters:
entity_class_name (str) – The entity class name.
parameter_definition_name (str) – The parameter name.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
alternative_name (str) – The alternative name.
metadata_name (str) – The metadata entry name.
metadata_value (str) – The metadata entry value.
- Returns:
The added or updated item or None if nothing was added or updated.
- Return type:
PublicItemor None
- add_or_update_entity_location(**kwargs)[source]
Adds an entity_location item to the in-memory mapping if it doesn’t exist; otherwise updates the current one.
- Parameters:
entity_class_name (str) – The entity class name.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
lat (float, optional) – Latitude.
lon (float, optional) – Longitude.
alt (float, optional) – Altitude.
shape_name (str, optional) – Name identifying the shape.
shape_blob (str, optional) – Shape as GEOJSON feature.
- Returns:
The added or updated item or None if nothing was added or updated.
- Return type:
PublicItemor None
- add_or_update_alternatives(items)[source]
Adds multiple alternative items to the in-memory mapping if they don’t exist; otherwise updates the items.
- add_or_update_scenarios(items)[source]
Adds multiple scenario items to the in-memory mapping if they don’t exist; otherwise updates the items.
- add_or_update_scenario_alternatives(items)[source]
Adds multiple scenario_alternative items to the in-memory mapping if they don’t exist; otherwise updates the items.
- add_or_update_entity_classes(items)[source]
Adds multiple entity_class items to the in-memory mapping if they don’t exist; otherwise updates the items.
- add_or_update_display_modes(items)[source]
Adds multiple display_mode items to the in-memory mapping if they don’t exist; otherwise updates the items.
- add_or_update_entity_class_display_modes(items)[source]
Adds multiple entity_class_display_mode items to the in-memory mapping if they don’t exist; otherwise updates the items.
- add_or_update_superclass_subclasses(items)[source]
Adds multiple superclass_subclass items to the in-memory mapping if they don’t exist; otherwise updates the items.
- add_or_update_entities(items)[source]
Adds multiple entity items to the in-memory mapping if they don’t exist; otherwise updates the items.
- add_or_update_entity_groups(items)[source]
Adds multiple entity_group items to the in-memory mapping if they don’t exist; otherwise updates the items.
- add_or_update_entity_alternatives(items)[source]
Adds multiple entity_alternative items to the in-memory mapping if they don’t exist; otherwise updates the items.
- add_or_update_parameter_value_lists(items)[source]
Adds multiple parameter_value_list items to the in-memory mapping if they don’t exist; otherwise updates the items.
- add_or_update_list_values(items)[source]
Adds multiple list_value items to the in-memory mapping if they don’t exist; otherwise updates the items.
- add_or_update_parameter_types(items)[source]
Adds multiple parameter_type items to the in-memory mapping if they don’t exist; otherwise updates the items.
- add_or_update_parameter_groups(items)[source]
Adds multiple parameter_group items to the in-memory mapping if they don’t exist; otherwise updates the items.
- add_or_update_parameter_definitions(items)[source]
Adds multiple parameter_definition items to the in-memory mapping if they don’t exist; otherwise updates the items.
- add_or_update_parameter_values(items)[source]
Adds multiple parameter_value items to the in-memory mapping if they don’t exist; otherwise updates the items.
- add_or_update_metadata_items(items)[source]
Adds multiple metadata items to the in-memory mapping if they don’t exist; otherwise updates the items.
- add_or_update_entity_metadata_items(items)[source]
Adds multiple entity_metadata items to the in-memory mapping if they don’t exist; otherwise updates the items.
- add_or_update_parameter_value_metadata_items(items)[source]
Adds multiple parameter_value_metadata items to the in-memory mapping if they don’t exist; otherwise updates the items.
- add_or_update_entity_locations(items)[source]
Adds multiple entity_location items to the in-memory mapping if they don’t exist; otherwise updates the items.
- remove_scenario_alternative(**kwargs)[source]
Removes a scenario_alternative item from the in-memory mapping.
- remove_entity_class(**kwargs)[source]
Removes an entity_class item from the in-memory mapping.
- Parameters:
name (str) – The class name.
dimension_name_list (tuple, optional) – The dimension names for a multi-dimensional class.
entity_class_byname (tuple) – A tuple with the class name as single element if the class is 0-dimensional, or the 0-dimensional class names if it is multi-dimensional.
description (str, optional) – The class description.
display_icon (int, optional) – An integer representing an icon within your application.
display_order (int, optional) – Not in use at the moment.
hidden (int, optional) – Not in use at the moment.
active_by_default (bool, optional) – Default activity for the entity alternatives of the class.
- remove_entity_class_display_mode(**kwargs)[source]
Removes an entity_class_display_mode item from the in-memory mapping.
- Parameters:
entity_class_name (str) – The entity class name.
display_mode_name (int) – The display mode name.
display_order (int) – The display order.
display_status (str) – The display status; one of ‘visible’, ‘hidden’ or ‘greyed_out’.
display_font_color (str, optional) – The color of the font.
display_background_color (str, optional) – The color of the background.
- remove_superclass_subclass(**kwargs)[source]
Removes a superclass_subclass item from the in-memory mapping.
- remove_entity(**kwargs)[source]
Removes an entity item from the in-memory mapping.
- Parameters:
entity_class_name (str) – The entity class name.
name (str) – The entity name.
element_name_list (tuple) – The element names if the entity is multi-dimensional.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
description (str, optional) – The entity description.
lat (float, optional) – The latitude of entity.
lon (float, optional) – The longitude of entity.
alt (float, optional) – The altitude of entity.
shape_name (str, optional) – The name of the entity’s shape.
shape_blob (str, optional) – The shape as GEOJSON string.
- remove_entity_alternative(**kwargs)[source]
Removes an entity_alternative item from the in-memory mapping.
- Parameters:
entity_class_name (str) – The entity class name.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
alternative_name (str) – The alternative name.
active (bool, optional) – Whether the entity is active in the alternative - defaults to True.
- remove_parameter_value_list(**kwargs)[source]
Removes a parameter_value_list item from the in-memory mapping.
- Parameters:
name (str) – The parameter value list name.
- remove_list_value(**kwargs)[source]
Removes a list_value item from the in-memory mapping.
- Parameters:
parameter_value_list_name (str) – The parameter value list name.
value (bytes) – The value’s database representation.
type (str, optional) – The value’s type.
parsed_value (ParameterValue, optional) – The value.
index (int, optional) – The value index.
- remove_parameter_group(**kwargs)[source]
Removes a parameter_group item from the in-memory mapping.
- remove_parameter_definition(**kwargs)[source]
Removes a parameter_definition item from the in-memory mapping.
- Parameters:
entity_class_name (str) – The entity class name.
name (str) – The parameter name.
parameter_group_name (str, optional) – The name of the group of the parameter.
parameter_type_list (tuple, optional) – List of valid value types.
default_value (bytes, optional) – The default value’s database representation.
default_type (str, optional) – The default value’s type.
parsed_value (ParameterValue, optional) – The default value.
parameter_value_list_name (str, optional) – The parameter value list name if any.
description (str, optional) – The parameter description.
- remove_parameter_value(**kwargs)[source]
Removes a parameter_value item from the in-memory mapping.
- Parameters:
entity_class_name (str) – The entity class name.
parameter_definition_name (str) – The parameter name.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
value (bytes) – The value’s database representation.
type (str, optional) – The value’s type. Optional only when value is null.
parsed_value (ParameterValue, optional) – The value.
alternative_name (str, optional) – The alternative name - defaults to ‘Base’.
- remove_entity_metadata(**kwargs)[source]
Removes an entity_metadata item from the in-memory mapping.
- Parameters:
entity_class_name (str) – The entity class name.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
metadata_name (str) – The metadata entry name.
metadata_value (str) – The metadata entry value.
- remove_parameter_value_metadata(**kwargs)[source]
Removes a parameter_value_metadata item from the in-memory mapping.
- Parameters:
entity_class_name (str) – The entity class name.
parameter_definition_name (str) – The parameter name.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
alternative_name (str) – The alternative name.
metadata_name (str) – The metadata entry name.
metadata_value (str) – The metadata entry value.
- remove_entity_location(**kwargs)[source]
Removes an entity_location item from the in-memory mapping.
- Parameters:
entity_class_name (str) – The entity class name.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
lat (float, optional) – Latitude.
lon (float, optional) – Longitude.
alt (float, optional) – Altitude.
shape_name (str, optional) – Name identifying the shape.
shape_blob (str, optional) – Shape as GEOJSON feature.
- remove_scenario_alternatives(items)[source]
Removes multiple scenario_alternative items from the in-memory mapping.
- remove_entity_classes(items)[source]
Removes multiple entity_class items from the in-memory mapping.
- remove_display_modes(items)[source]
Removes multiple display_mode items from the in-memory mapping.
- remove_entity_class_display_modes(items)[source]
Removes multiple entity_class_display_mode items from the in-memory mapping.
- remove_superclass_subclasses(items)[source]
Removes multiple superclass_subclass items from the in-memory mapping.
- remove_entity_groups(items)[source]
Removes multiple entity_group items from the in-memory mapping.
- remove_entity_alternatives(items)[source]
Removes multiple entity_alternative items from the in-memory mapping.
- remove_parameter_value_lists(items)[source]
Removes multiple parameter_value_list items from the in-memory mapping.
- remove_parameter_types(items)[source]
Removes multiple parameter_type items from the in-memory mapping.
- remove_parameter_groups(items)[source]
Removes multiple parameter_group items from the in-memory mapping.
- remove_parameter_definitions(items)[source]
Removes multiple parameter_definition items from the in-memory mapping.
- remove_parameter_values(items)[source]
Removes multiple parameter_value items from the in-memory mapping.
- remove_entity_metadata_items(items)[source]
Removes multiple entity_metadata items from the in-memory mapping.
- remove_parameter_value_metadata_items(items)[source]
Removes multiple parameter_value_metadata items from the in-memory mapping.
- remove_entity_locations(items)[source]
Removes multiple entity_location items from the in-memory mapping.
- restore_alternative(**kwargs)[source]
Restores a previously removed alternative item into the in-memory mapping.
- restore_scenario(**kwargs)[source]
Restores a previously removed scenario item into the in-memory mapping.
- restore_scenario_alternative(**kwargs)[source]
Restores a previously removed scenario_alternative item into the in-memory mapping.
- restore_entity_class(**kwargs)[source]
Restores a previously removed entity_class item into the in-memory mapping.
- Parameters:
name (str) – The class name.
dimension_name_list (tuple, optional) – The dimension names for a multi-dimensional class.
entity_class_byname (tuple) – A tuple with the class name as single element if the class is 0-dimensional, or the 0-dimensional class names if it is multi-dimensional.
description (str, optional) – The class description.
display_icon (int, optional) – An integer representing an icon within your application.
display_order (int, optional) – Not in use at the moment.
hidden (int, optional) – Not in use at the moment.
active_by_default (bool, optional) – Default activity for the entity alternatives of the class.
- Returns:
The restored item.
- Return type:
PublicItem
- restore_display_mode(**kwargs)[source]
Restores a previously removed display_mode item into the in-memory mapping.
- restore_entity_class_display_mode(**kwargs)[source]
Restores a previously removed entity_class_display_mode item into the in-memory mapping.
- Parameters:
entity_class_name (str) – The entity class name.
display_mode_name (int) – The display mode name.
display_order (int) – The display order.
display_status (str) – The display status; one of ‘visible’, ‘hidden’ or ‘greyed_out’.
display_font_color (str, optional) – The color of the font.
display_background_color (str, optional) – The color of the background.
- Returns:
The restored item.
- Return type:
PublicItem
- restore_superclass_subclass(**kwargs)[source]
Restores a previously removed superclass_subclass item into the in-memory mapping.
- restore_entity(**kwargs)[source]
Restores a previously removed entity item into the in-memory mapping.
- Parameters:
entity_class_name (str) – The entity class name.
name (str) – The entity name.
element_name_list (tuple) – The element names if the entity is multi-dimensional.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
description (str, optional) – The entity description.
lat (float, optional) – The latitude of entity.
lon (float, optional) – The longitude of entity.
alt (float, optional) – The altitude of entity.
shape_name (str, optional) – The name of the entity’s shape.
shape_blob (str, optional) – The shape as GEOJSON string.
- Returns:
The restored item.
- Return type:
PublicItem
- restore_entity_group(**kwargs)[source]
Restores a previously removed entity_group item into the in-memory mapping.
- restore_entity_alternative(**kwargs)[source]
Restores a previously removed entity_alternative item into the in-memory mapping.
- Parameters:
entity_class_name (str) – The entity class name.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
alternative_name (str) – The alternative name.
active (bool, optional) – Whether the entity is active in the alternative - defaults to True.
- Returns:
The restored item.
- Return type:
PublicItem
- restore_parameter_value_list(**kwargs)[source]
Restores a previously removed parameter_value_list item into the in-memory mapping.
- Parameters:
name (str) – The parameter value list name.
- Returns:
The restored item.
- Return type:
PublicItem
- restore_list_value(**kwargs)[source]
Restores a previously removed list_value item into the in-memory mapping.
- Parameters:
parameter_value_list_name (str) – The parameter value list name.
value (bytes) – The value’s database representation.
type (str, optional) – The value’s type.
parsed_value (ParameterValue, optional) – The value.
index (int, optional) – The value index.
- Returns:
The restored item.
- Return type:
PublicItem
- restore_parameter_type(**kwargs)[source]
Restores a previously removed parameter_type item into the in-memory mapping.
- restore_parameter_group(**kwargs)[source]
Restores a previously removed parameter_group item into the in-memory mapping.
- restore_parameter_definition(**kwargs)[source]
Restores a previously removed parameter_definition item into the in-memory mapping.
- Parameters:
entity_class_name (str) – The entity class name.
name (str) – The parameter name.
parameter_group_name (str, optional) – The name of the group of the parameter.
parameter_type_list (tuple, optional) – List of valid value types.
default_value (bytes, optional) – The default value’s database representation.
default_type (str, optional) – The default value’s type.
parsed_value (ParameterValue, optional) – The default value.
parameter_value_list_name (str, optional) – The parameter value list name if any.
description (str, optional) – The parameter description.
- Returns:
The restored item.
- Return type:
PublicItem
- restore_parameter_value(**kwargs)[source]
Restores a previously removed parameter_value item into the in-memory mapping.
- Parameters:
entity_class_name (str) – The entity class name.
parameter_definition_name (str) – The parameter name.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
value (bytes) – The value’s database representation.
type (str, optional) – The value’s type. Optional only when value is null.
parsed_value (ParameterValue, optional) – The value.
alternative_name (str, optional) – The alternative name - defaults to ‘Base’.
- Returns:
The restored item.
- Return type:
PublicItem
- restore_metadata(**kwargs)[source]
Restores a previously removed metadata item into the in-memory mapping.
- restore_entity_metadata(**kwargs)[source]
Restores a previously removed entity_metadata item into the in-memory mapping.
- Parameters:
entity_class_name (str) – The entity class name.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
metadata_name (str) – The metadata entry name.
metadata_value (str) – The metadata entry value.
- Returns:
The restored item.
- Return type:
PublicItem
- restore_parameter_value_metadata(**kwargs)[source]
Restores a previously removed parameter_value_metadata item into the in-memory mapping.
- Parameters:
entity_class_name (str) – The entity class name.
parameter_definition_name (str) – The parameter name.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
alternative_name (str) – The alternative name.
metadata_name (str) – The metadata entry name.
metadata_value (str) – The metadata entry value.
- Returns:
The restored item.
- Return type:
PublicItem
- restore_entity_location(**kwargs)[source]
Restores a previously removed entity_location item into the in-memory mapping.
- Parameters:
entity_class_name (str) – The entity class name.
entity_byname (tuple) – A tuple with the entity name as single element if the entity is 0-dimensional, or the 0-dimensional element names if it is multi-dimensional.
lat (float, optional) – Latitude.
lon (float, optional) – Longitude.
alt (float, optional) – Altitude.
shape_name (str, optional) – Name identifying the shape.
shape_blob (str, optional) – Shape as GEOJSON feature.
- Returns:
The restored item.
- Return type:
PublicItem
- restore_alternatives(items)[source]
Restores multiple alternative items back into the in-memory mapping.
- restore_scenario_alternatives(items)[source]
Restores multiple scenario_alternative items back into the in-memory mapping.
- restore_entity_classes(items)[source]
Restores multiple entity_class items back into the in-memory mapping.
- restore_display_modes(items)[source]
Restores multiple display_mode items back into the in-memory mapping.
- restore_entity_class_display_modes(items)[source]
Restores multiple entity_class_display_mode items back into the in-memory mapping.
- restore_superclass_subclasses(items)[source]
Restores multiple superclass_subclass items back into the in-memory mapping.
- restore_entity_groups(items)[source]
Restores multiple entity_group items back into the in-memory mapping.
- restore_entity_alternatives(items)[source]
Restores multiple entity_alternative items back into the in-memory mapping.
- restore_parameter_value_lists(items)[source]
Restores multiple parameter_value_list items back into the in-memory mapping.
- restore_list_values(items)[source]
Restores multiple list_value items back into the in-memory mapping.
- restore_parameter_types(items)[source]
Restores multiple parameter_type items back into the in-memory mapping.
- restore_parameter_groups(items)[source]
Restores multiple parameter_group items back into the in-memory mapping.
- restore_parameter_definitions(items)[source]
Restores multiple parameter_definition items back into the in-memory mapping.
- restore_parameter_values(items)[source]
Restores multiple parameter_value items back into the in-memory mapping.
- restore_metadata_items(items)[source]
Restores multiple metadata items back into the in-memory mapping.
- restore_entity_metadata_items(items)[source]
Restores multiple entity_metadata items back into the in-memory mapping.