spinetoolbox.spine_db_editor.mvcmodels.parameter_mixins¶
Miscelaneous mixins for parameter models
| authors: |
|
|---|---|
| date: | 4.10.2019 |
Module Contents¶
Classes¶
ConvertToDBMixin |
Base class for all mixins that convert model items (name-based) into database items (id-based). |
FillInAlternativeIdMixin |
Fills in alternative names. |
FillInParameterNameMixin |
Fills in parameter names. |
FillInValueListIdMixin |
Fills in value list ids. |
MakeParameterTagMixin |
Makes parameter_tag items. |
FillInEntityClassIdMixin |
Fills in entity_class ids. |
FillInEntityIdsMixin |
Fills in entity ids. |
FillInParameterDefinitionIdsMixin |
Fills in parameter_definition ids. |
InferEntityClassIdMixin |
Infers object_class ids. |
MakeRelationshipOnTheFlyMixin |
Makes relationships on the fly. |
Functions¶
_parse_csv_list(csv_list) |
-
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:
spinetoolbox.spine_db_editor.mvcmodels.parameter_mixins.ConvertToDBMixinFills in alternative names.
Initializes lookup dicts.
-
class
spinetoolbox.spine_db_editor.mvcmodels.parameter_mixins.FillInParameterNameMixin[source]¶ Bases:
spinetoolbox.spine_db_editor.mvcmodels.parameter_mixins.ConvertToDBMixinFills in parameter names.
-
class
spinetoolbox.spine_db_editor.mvcmodels.parameter_mixins.FillInValueListIdMixin(*args, **kwargs)[source]¶ Bases:
spinetoolbox.spine_db_editor.mvcmodels.parameter_mixins.ConvertToDBMixinFills 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:
spinetoolbox.spine_db_editor.mvcmodels.parameter_mixins.ConvertToDBMixinMakes 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:
spinetoolbox.spine_db_editor.mvcmodels.parameter_mixins.ConvertToDBMixinFills 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:
spinetoolbox.spine_db_editor.mvcmodels.parameter_mixins.ConvertToDBMixinFills 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:
spinetoolbox.spine_db_editor.mvcmodels.parameter_mixins.ConvertToDBMixinFills 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:
spinetoolbox.spine_db_editor.mvcmodels.parameter_mixins.ConvertToDBMixinInfers 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.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
-
static