Skip to main content
Skip table of contents

interface - Mappings

This topic discusses the mapping classes of the PLANTA link API.

Classes

MappingBlock

The MappingBlock is the base class that wraps a record from table 562

  • It allows you to query almost all attributes a mapping element has
  • Each type of mapping has a specific subclass to implement its functionality
  • Instead of instancing MappingBlock classes yourself you'll want to use get_mapping_instance_from_uuid() to get a instance of the correct class
  • You can create new mapping elements by calling MappingBlock.create() and a new child to a mapping element by calling MappingBlock.create_child() on the instance

Methods

FunctionParametersReturn ValueDescription
MappingBlock.__eq__(self, other)other: Another MappingBlock instanceTrue or FalseCheck if a mapping is equal to another
MappingBlock.__hash__(self)
IntegerReturns a hash based on UUID
MappingBlock.__init_(self, uuid, parent=None, config=None, check_for_parent=True)uuid: UUID

parent: A MappingBlock instance
config: A ppms.interface.Config instance
check_for_parent: True or False
InstanceInitialize a new MappingBlock element. When parent is None, check_for_parent controls wether the parent should be determined or skipped.

You should not call this directly but instead use get_mapping_instance_from_uuid() so your instance has the correct class.
MappingBlock.cache_clear(self)

Clears the cached values in a mapping. This only affects the object attribute.
MappingBlock.create_child(self, creation_parameters)creation_parameters: A dictionary of attributes from table 562 to setA subclass of MappingBlock or NoneCreate a new mapping element that is a direct child to the calling instance
MappingBlock.delete(self)

Delete this mapping
MappingBlock.generate_and_clean_up_parameters(self)

Populates the parameter table with the parameters defined by the mapping class. Superfluous parameters are removed.
MappingBlock.get_validation_hash(self)
UUIDCalculate a hash over all parts of this mapping that can be modified by the user and sanity checked by PLANTA link.
MappingBlock.modify_parameter(self, key, value)key: Bezeichnung
value: Parameter value

Modify a parameter of this mapping. Raises a ValueError when the parameter is missing or could not be modified.

Classmethods

FunctionParametersReturn ValueDescription
MappingBlock.create(cls, config_id, type, config=None, creation_parameters)config_id: UUID
type: ppms.interface.MappingType

config: A instance of ppms.interface.Config
creation_parameters: A dictionary of attributes from table 562 to set
A subclass of MappingBlock or NoneCreate a new mapping element belonging to a config. The config parameter is just a performance optimization.
MappingBlock.get_default_parameters(cls)
A dictionary of the parameters and their default valuesFetch the parameters and their default values
MappingBlock.register_parameter(cls, name, default, validator_cls=None, validator_kwargs=None)name: Name of the parameter
default: The default value

validator_cls: A subclass of ppms.interface.ParameterValidator
validator_kwargs: Keyword arguments to pass on to the validator

Register a new parameter for this class
MappingBlock.register_parameters(cls)

A method that is called by the framework to register all parameters. By default it does nothing and must be overwritten in a subclass to call MappingBlock.register_parameter() for every parameter
MappingBlock.unregister_parameter(cls, name)name: Name of the parameterTrue or FalseRemove a registered parameter that is not needed. Returns True when the parameter was removed and False if no parameter with that name exists. Use this to remove parameters registered by a base class that you don't need.

Properties

PropertyGetterSetterDescription
MappingBlock.children A list of all mapping instances that are direct children of this mapping
MappingBlock.config The ppms.interface.Config instance this mapping belongs to
MappingBlock.config_id UUID of the configuration this mapping belongs to
MappingBlock.object Objekt
MappingBlock.parameters Returns a dictionary of Bezeichnung: Wert for the parameters of this mapping
MappingBlock.position Position
MappingBlock.root_parent_position Position of the top level parent
MappingBlock.source Returns the top level parent instance
MappingBlock.type Mapping-Element-Typ

BaseWorkerMapping

The BaseWorkerMapping class is a flexible placeholder class that is used behind the scenes for all mappings that are not source/pool/target.

  • When executing a interface all worker mappings are initialized as BaseWorkerMapping and during the initialization the class searches for the concrete implementation and replaces itself with that

Methods

FunctionParametersReturn ValueDescription
BaseWorkerMapping.get_numeric_parameter(self, parameter)parameter: BezeichnungWert as integer or NoneRetrieve a parameter value as an integer

BaseConverter

The BaseConverter class is the base class for all converters.

Methods

FunctionParametersReturn ValueDescription
BaseConverter.convert(self, parameter)parameter: The value returned by the previous mappingShould return the converted valueThis method must be overwritten in a subclass to implement a converter for PLANTA link

BaseEnricher

The BaseEnricher class is the base class for all converters.

Methods

FunctionParametersReturn ValueDescription
BaseEnricher.enrich(self, parameter)parameter: The value returned by the previous mappingShould return the enriched valueThis method must be overwritten in a subclass to implement a enricher for PLANTA link

BaseValidator

The BaseValidator class is the base class for all validators.

Methods

FunctionParametersReturn ValueDescription
BaseValidator.check(self, parameter)parameter: The value returned by the previous mapping
This method must be overwritten in a subclass to implement a validator for PLANTA link. When the validation fails, a ppms.interface.InvalidRecordException must be raised

Functions

FunctionParametersReturn ValueDescription
get_mapping_instance_from_uuid(uuid, *args, **kwargs)uuid: UUID
args: Any arguments you want passed on to the constructor
kwargs: Any keyword arguments you want passed on to the constructor
A mapping instance or NoneGet a mapping instance from the UUID. Will return a instance of the correct class.
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.