spinetoolbox.mvcmodels.parameter_mixins
¶
Miscelaneous mixins for parameter models
authors: |
|
---|---|
date: | 4.10.2019 |
Module Contents¶
-
class
spinetoolbox.mvcmodels.parameter_mixins.
ConvertToDBMixin
[source]¶ Base class for all mixins that convert model items (name-based) into database items (id-based).
-
class
spinetoolbox.mvcmodels.parameter_mixins.
FillInParameterNameMixin
[source]¶ Bases:
spinetoolbox.mvcmodels.parameter_mixins.ConvertToDBMixin
Fills in parameter names.
-
class
spinetoolbox.mvcmodels.parameter_mixins.
FillInValueListIdMixin
(*args, **kwargs)[source]¶ Bases:
spinetoolbox.mvcmodels.parameter_mixins.ConvertToDBMixin
Fills in value list ids.
Initializes lookup dicts.
-
build_lookup_dictionary
(self, db_map_data)[source]¶ Builds a name lookup dictionary for the given data.
Parameters: db_map_data (dict) – lists of model items keyed by DiffDatabaseMapping
-
-
class
spinetoolbox.mvcmodels.parameter_mixins.
MakeParameterTagMixin
(*args, **kwargs)[source]¶ Bases:
spinetoolbox.mvcmodels.parameter_mixins.ConvertToDBMixin
Makes parameter tag items.
Initializes lookup dicts.
-
build_lookup_dictionary
(self, db_map_data)[source]¶ Builds a name lookup dictionary for the given data.
Parameters: db_map_data (dict) – lists of model items keyed by DiffDatabaseMapping
-
_make_parameter_definition_tag
(self, item, db_map)[source]¶ Returns a db parameter definition tag item (id-based) from the given model parameter definition item (name-based).
Parameters: - item (dict) – the model parameter definition item
- db_map (DiffDatabaseMapping) – the database where the resulting item belongs
Returns: the db parameter definition tag item list: error log
Return type: dict
-
-
class
spinetoolbox.mvcmodels.parameter_mixins.
FillInEntityClassIdMixin
(*args, **kwargs)[source]¶ Bases:
spinetoolbox.mvcmodels.parameter_mixins.ConvertToDBMixin
Fills in entity class ids.
Initializes lookup dicts.
-
build_lookup_dictionary
(self, db_map_data)[source]¶ Builds a name lookup dictionary for the given data.
Parameters: db_map_data (dict) – lists of model items keyed by DiffDatabaseMapping
-
-
class
spinetoolbox.mvcmodels.parameter_mixins.
FillInEntityIdsMixin
(*args, **kwargs)[source]¶ Bases:
spinetoolbox.mvcmodels.parameter_mixins.ConvertToDBMixin
Fills in entity ids.
Initializes lookup dicts.
-
build_lookup_dictionary
(self, db_map_data)[source]¶ Builds a name lookup dictionary for the given data.
Parameters: db_map_data (dict) – lists of model items keyed by DiffDatabaseMapping
-
_fill_in_entity_ids
(self, item, db_map)[source]¶ Fills in all possible entity ids keyed by entity class id in the given db item (as there can be more than one entity for the same name).
Parameters: - item (dict) – the db item
- db_map (DiffDatabaseMapping) – the database where the given item belongs
Returns: error log
Return type: list
-
-
class
spinetoolbox.mvcmodels.parameter_mixins.
FillInParameterDefinitionIdsMixin
(*args, **kwargs)[source]¶ Bases:
spinetoolbox.mvcmodels.parameter_mixins.ConvertToDBMixin
Fills in parameter definition ids.
Initializes lookup dicts.
-
build_lookup_dictionary
(self, db_map_data)[source]¶ Builds a name lookup dictionary for the given data.
Parameters: db_map_data (dict) – lists of model items keyed by DiffDatabaseMapping
-
_fill_in_parameter_ids
(self, item, db_map)[source]¶ Fills in all possible parameter definition ids keyed by entity class id in the given db item (as there can be more than one parameter definition for the same name).
Parameters: - item (dict) – the db item
- db_map (DiffDatabaseMapping) – the database where the given item belongs
Returns: error log
Return type: list
-
-
class
spinetoolbox.mvcmodels.parameter_mixins.
InferEntityClassIdMixin
[source]¶ Bases:
spinetoolbox.mvcmodels.parameter_mixins.ConvertToDBMixin
Infers object class ids.
-
_convert_to_db
(self, item, db_map)[source]¶ Returns a db item (id-based) from the given model item (name-based).
Parameters: - item (dict) – the model item
- db_map (DiffDatabaseMapping) – the database where the resulting item belongs
Returns: the db item list: error log
Return type: dict
-
_infer_and_fill_in_entity_class_id
(self, item, db_map)[source]¶ Fills the entity class id in the given db item, by intersecting entity ids and parameter ids. Then picks the correct entity id and parameter definition id. Also sets the inferred entity class name in the model.
Parameters: - item (dict) – the db item
- db_map (DiffDatabaseMapping) – the database where the given item belongs
Returns: error log
Return type: list
-
-
class
spinetoolbox.mvcmodels.parameter_mixins.
MakeRelationshipOnTheFlyMixin
(*args, **kwargs)[source]¶ Makes relationships on the fly.
Initializes lookup dicts.
-
static
_make_unique_relationship_id
(item)[source]¶ Returns a unique name-based identifier for db relationships.
-
build_lookup_dictionaries
(self, db_map_data)[source]¶ Builds a name lookup dictionary for the given data.
Parameters: db_map_data (dict) – lists of model items keyed by DiffDatabaseMapping.
-
_make_relationship_on_the_fly
(self, item, db_map)[source]¶ Returns a database relationship item (id-based) from the given model parameter value item (name-based).
Parameters: - item (dict) – the model parameter value item
- db_map (DiffDatabaseMapping) – the database where the resulting item belongs
Returns: the db relationship item list: error log
Return type: dict
-
static