Die Dokumentation ab Version 39.5.17 von PLANTA project finden Sie in der neuen PLANTA Online-Hilfe.

interface - Mappings

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

Classes

mapping_class_diagram.png

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

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=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
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=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 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 Checked Checked A list of all mapping instances that are direct children of this mapping
MappingBlock.config Checked Unchecked The ppms.interface.Config instance this mapping belongs to
MappingBlock.config_id Checked Unchecked UUID of the configuration this mapping belongs to
MappingBlock.object Checked Checked Objekt
MappingBlock.parameters Checked Unchecked Returns a dictionary of Bezeichnung: Wert for the parameters of this mapping
MappingBlock.position Checked Checked Position
MappingBlock.root_parent_position Checked Unchecked Position of the top level parent
MappingBlock.source Checked Unchecked Returns the top level parent instance
MappingBlock.type Checked Checked 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.
Topic attachments
I Attachment History Size Date Comment
Pngpng mapping_class_diagram.png r5 r4 r3 r2 r1 8.1 K 2017-10-10 - 11:55  

         PLANTA project









 
  • Suche in Topic-Namen

  • Suche in Topic-Inhalten
This site is powered by the TWiki collaboration platform Powered by Perl