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 useget_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 callingMappingBlock.create_child()
on the instance
Methods
Function | Parameters | Return Value | Description |
---|---|---|---|
MappingBlock.__eq__(self, other) | other: Another MappingBlock instance | True or False | Check if a mapping is equal to another |
MappingBlock.__hash__(self) | Integer | Returns a hash based on UUID | |
MappingBlock.__init_(self, uuid, parent= | uuid: UUID parent: A MappingBlock instanceconfig: A ppms.interface.Config instance check_for_parent: True or False | Instance | Initialize 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 set | A subclass of MappingBlock or None | Create 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) | UUID | Calculate 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
Function | Parameters | Return Value | Description |
---|---|---|---|
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 None | Create 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 values | Fetch the parameters and their default values | |
MappingBlock.register_parameter(cls, name, default, validator_cls= | 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 parameter | True or False | Remove 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
Property | Getter | Setter | Description |
---|---|---|---|
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
Function | Parameters | Return Value | Description |
---|---|---|---|
BaseWorkerMapping.get_numeric_parameter(self, parameter) | parameter: Bezeichnung | Wert as integer or None | Retrieve a parameter value as an integer |
BaseConverter
The BaseConverter
class is the base class for all converters.
Methods
Function | Parameters | Return Value | Description |
---|---|---|---|
BaseConverter.convert(self, parameter) | parameter: The value returned by the previous mapping | Should return the converted value | This 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
Function | Parameters | Return Value | Description |
---|---|---|---|
BaseEnricher.enrich(self, parameter) | parameter: The value returned by the previous mapping | Should return the enriched value | This 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
Function | Parameters | Return Value | Description |
---|---|---|---|
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
Function | Parameters | Return Value | Description |
---|---|---|---|
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 None | Get a mapping instance from the UUID. Will return a instance of the correct class. |