spinetoolbox.import_editor.mvcmodels.mapping_specification_model

Contains the mapping specification model.

author:
  1. Vennström (VTT)
date:

1.6.2019

Module Contents

Classes

MappingSpecificationModel A model to hold a Mapping specification.

Functions

_name_index(name) Parses an index from a string which ends with that number.
spinetoolbox.import_editor.mvcmodels.mapping_specification_model._MAP_TYPE_DISPLAY_NAME[source]
spinetoolbox.import_editor.mvcmodels.mapping_specification_model._DISPLAY_TYPE_TO_TYPE[source]
spinetoolbox.import_editor.mvcmodels.mapping_specification_model._TYPE_TO_DISPLAY_TYPE[source]
class spinetoolbox.import_editor.mvcmodels.mapping_specification_model.MappingSpecificationModel(table_name, mapping_name, mapping, undo_stack)[source]

Bases: PySide2.QtCore.QAbstractTableModel

A model to hold a Mapping specification.

Parameters:
  • table_name (str) – source table name
  • mapping_name (str) – mapping name
  • mapping (spinedb_api.ItemMappingBase) – the item mapping to model
  • undo_stack (QUndoStack) – undo stack
mapping_read_start_row_changed[source]

Emitted after mapping’s read start row has been changed.

row_or_column_type_recommendation_changed[source]

Emitted when a change in mapping prompts for change in column or row type.

multi_column_type_recommendation_changed[source]

Emitted when all but given columns should be of given type.

about_to_undo[source]

Emitted before an undo/redo action.

mapping[source]
mapping_name[source]
source_table_name[source]
skip_columns[source]
map_type[source]
last_pivot_row[source]
dimension[source]
import_objects[source]
parameter_type[source]
is_pivoted[source]
read_start_row[source]
set_read_start_row(self, row)[source]
set_import_objects(self, flag)[source]
set_mapping(self, mapping)[source]
set_dimension(self, dim)[source]
change_item_mapping_type(self, new_type)[source]

Change item mapping’s type.

Parameters:new_type (str) – name of the type
change_parameter_type(self, new_type)[source]

Change parameter type

set_parameter_mapping(self, mapping)[source]

Changes the parameter mapping.

Parameters:mapping (ParameterDefinitionMapping) – new mapping
update_display_table(self)[source]
get_map_type_display(self, mapping, name)[source]
get_map_value_display(self, mapping, name)[source]
data(self, index, role=Qt.DisplayRole)[source]
static data_color(display_name)[source]
_mapping_issues(self, row)[source]

Returns a message string if given row contains issues, or an empty string if everything is OK.

rowCount(self, index=None)[source]
columnCount(self, index=None)[source]
headerData(self, section, orientation, role=Qt.DisplayRole)[source]
flags(self, index)[source]
setData(self, index, value, role=Qt.DisplayRole)[source]
change_component_mapping(self, component_name, type_name, reference)[source]

Pushes SetComponentMappingType to the undo stack.

Parameters:
  • component_name (str) – name of the component whose type to change
  • type_name (str) – name of the new type
  • reference (str or int) – component mapping reference
set_type(self, name, value)[source]

Changes the type of a component mapping.

Parameters:
  • name (str) – component name
  • value (str) – mapping type name
set_value(self, name, value)[source]

Sets the reference for given mapping.

Parameters:
  • name (str) – name of the mapping
  • value (str) – a new value
Returns:

True if the reference was modified successfully, False otherwise.

Return type:

bool

_get_component_mapping_from_name(self, name)[source]
_set_component_mapping_from_name(self, name, mapping)[source]
_row_for_component_name(self, name)[source]
_recommend_string_type(self, mapping)[source]
_recommend_float_type(self, mapping)[source]
_recommend_datetime_type(self, mapping)[source]
_recommend_mapping_reference_type_change(self, mapping, convert_spec)[source]
_recommend_parameter_value_mapping_reference_type_change(self, mapping)[source]
set_skip_columns(self, columns=None)[source]
set_time_series_repeat(self, repeat)[source]

Toggles the repeat flag in the parameter’s options.

set_map_dimensions(self, dimensions)[source]
set_map_compress_flag(self, compress)[source]

Sets the compress flag for Map type parameters.

Parameters:compress (bool) – flag value
mapping_has_parameters(self)[source]

Returns True if the item mapping has parameters.

model_parameters(self)[source]

Returns the mapping’s parameters.

to_dict(self)[source]

Serializes the mapping specification into a dict.

Returns:serialized specification
Return type:dict
static from_dict(specification_dict, table_name, undo_stack)[source]

Restores a serialized mapping specification.

Parameters:
  • specification_dict (dict) – serialized specification model
  • table_name (str) – source table name
  • undo_stack (QUndoStack) – undo stack
Returns:

mapping specification

Return type:

MappingSpecificationModel

spinetoolbox.import_editor.mvcmodels.mapping_specification_model._name_index(name)[source]

Parses an index from a string which ends with that number.

Parameters:name (str) – a string that ends with a number
Returns:the number at the end of the given string minus one
Return type:int