spinetoolbox.spine_db_editor.mvcmodels.parameter_mixins
¶
Miscelaneous mixins for parameter models
- authors
Marin (KTH)
- date
4.10.2019
Module Contents¶
Classes¶
Base class for all mixins that convert model items (name-based) into database items (id-based). |
|
Fills in alternative names. |
|
Fills in parameter names. |
|
Fills in value list ids. |
|
Makes parameter_tag items. |
|
Fills in entity_class ids. |
|
Fills in entity ids. |
|
Fills in parameter_definition ids. |
|
Infers entity class ids. |
|
Imposes entity class ids. |
|
Validates that the chosen value is in the value list if one set. |
|
Validates that the chosen value is in the value list if one set. |
|
Validates that the chosen value is in the value list if one set. |
|
Makes relationships on the fly. |
Functions¶
|
- class spinetoolbox.spine_db_editor.mvcmodels.parameter_mixins.ConvertToDBMixin[source]¶
Base class for all mixins that convert model items (name-based) into database items (id-based).
- class spinetoolbox.spine_db_editor.mvcmodels.parameter_mixins.FillInAlternativeIdMixin(*args, **kwargs)[source]¶
Bases:
ConvertToDBMixin
Fills in alternative names.
Initializes lookup dicts.
- class spinetoolbox.spine_db_editor.mvcmodels.parameter_mixins.FillInParameterNameMixin[source]¶
Bases:
ConvertToDBMixin
Fills in parameter names.
- class spinetoolbox.spine_db_editor.mvcmodels.parameter_mixins.FillInValueListIdMixin(*args, **kwargs)[source]¶
Bases:
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.spine_db_editor.mvcmodels.parameter_mixins.MakeParameterTagMixin(*args, **kwargs)[source]¶
Bases:
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.spine_db_editor.mvcmodels.parameter_mixins.FillInEntityClassIdMixin(*args, **kwargs)[source]¶
Bases:
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.spine_db_editor.mvcmodels.parameter_mixins.FillInEntityIdsMixin(*args, **kwargs)[source]¶
Bases:
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.spine_db_editor.mvcmodels.parameter_mixins.FillInParameterDefinitionIdsMixin(*args, **kwargs)[source]¶
Bases:
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.spine_db_editor.mvcmodels.parameter_mixins.InferEntityClassIdMixin[source]¶
Bases:
ConvertToDBMixin
Infers entity 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.spine_db_editor.mvcmodels.parameter_mixins.ImposeEntityClassIdMixin[source]¶
Bases:
ConvertToDBMixin
Imposes entity 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
- _impose_entity_class_id(self, item, db_map)[source]¶
Imposes the entity_class id from the model, to pick the correct entity id and parameter_definition id.
- Parameters
item (dict) – the db item
db_map (DiffDatabaseMapping) – the database where the given item belongs
- Returns
error log
- Return type
list
- class spinetoolbox.spine_db_editor.mvcmodels.parameter_mixins.ValidateValueInListMixin[source]¶
Bases:
ConvertToDBMixin
Validates that the chosen value is in the value list if one set.
- class spinetoolbox.spine_db_editor.mvcmodels.parameter_mixins.ValidateValueInListForInsertMixin[source]¶
Bases:
ValidateValueInListMixin
Validates that the chosen value is in the value list if one set.
- class spinetoolbox.spine_db_editor.mvcmodels.parameter_mixins.ValidateValueInListForUpdateMixin[source]¶
Bases:
ValidateValueInListMixin
Validates that the chosen value is in the value list if one set.
- class spinetoolbox.spine_db_editor.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