Skip to main content
Skip table of contents

Interface Customizing

Information

  • Each object from the PLANTA link API should be imported from the ppms.interface namespace!

Create New Mapping Function

Information

  • You can create new mapping functions under /py/api/ppms/wrapper/customer/ppms/interface/blocks/.
    • To do so, simply create an enricher.py, converter.py, or validator.py file at this position and fill it with individual mapping functions
  • The ppms.interface package provides three basic classes for the implementation of your own mapping functions: BaseConverter, BaseEnricher, and BaseValidator.

Parameter

Information

  • The parameters of a mapping function are configured in the register_parameters class method.
  • Via the register_parameter and unregister_parameter class methods you can add new parameters or delete parameters of the parent class.
  • You can access the value of your own parameters within the instance via the self parameters dictionary.

Example

  • Here, a validator is defined which checks whether the transferred value matches the configured value.
  • For this purpose, a new parameter with the key "value" is registered. This parameter has no standard value but it is a mandatory field.
  • Within the check method, the configured parameters are accessed via self parameters. As a result, the value of the value parameter is opened.
  • Afterwards it is checked whether the transferred value matches the configured value.
PY
from ppms.interface import BaseValidator, InvalidRecordException

class Equals(BaseValidator):

    @classmethod
    def register_parameters(cls):
        super(Equals, cls).register_parameters()

        cls.register_parameter(name='value', default='', validator_cls=MandatoryValidator)

    def check(self, value):
        check_value = self.parameters['value']
        
        if value != check_value:
            raise InvalidRecordException('"%s" is not equal to "%s"' % (value, check_value))

Create a New Validator

Information

  • Create a new file under ppms.interface and define a new class which inherits from BaseValidator.
  • Here, the check(self, parameter) method must be implemented.
  • The method must throw the InvalidRecordException if the validation has failed.

Example: Validator that checks whether a particular task exists

PY
from ppms.interface import BaseValidator, InvalidRecordException

class TaskExists(BaseValidator):
  
    @classmethod
    def register_parameters(cls):
        super(TaskExists, cls).register_parameters()

        cls.register_parameter(name='project', default='', validator_cls=MandatoryValidator) 

    def check(self, task_id):
        pr_id = self.parameters['project']
        
        task_record = ppms.search_record(463, [pr_id, task_id], [1097, 1098], True)
        
        if task_record is None:
            raise InvalidRecordException('There is no task "%s" in project "%s"' % (task_id, pr_id))

Create a New Enricher

Information

  • Create a new file under ppms.interface and define a new class that inherits from BaseEnricher.
  • Here you have to implement the enrich(self, parameter) method.
  • The method must return the edited value.

Example: Enricher for replacing a text by another one

PY
from ppms.interface import BaseEnricher

class Replacer(BaseEnricher):
    """Gives access to the str.replace function"""
    
    @classmethod
    def register_parameters(cls):
        super(Replacer, cls).register_parameters()

        cls.register_parameter(name='old_value', default='', validator_cls=MandatoryValidator)
        cls.register_parameter(name='new_value', default='', validator_cls=MandatoryValidator)
 
    def enrich(self, arg):
        return arg.replace(self.parameters['old_value'], 
                           self.parameters['new_value'])

Create a New Converter

Information

  • Create a new file at ppms.interface and define a new class that inherits from BaseConverter.
  • Here, the convert(self, parameter) method must be implemented.
  • The method must return the converted value.

Example: Converter for converting text into capital letters

PY
from ppms.interface import BaseConverter

class ToUppercase(BaseConverter):

    def convert(self, value):
        return value.upper()

Add a New Mapping Function to the Listbox

Information

  • Under PLANTA Link → Interface Administration → Interface Administration you can add the new mapping functions so that they are displayed in the object listbox

Create a New Module Class

Information

  • The module classes implement an individual transfer logic and constitute docking points to other systems.
  • Each module class to be used for the interface must inherit from the BaseInterfaceModule class.
  • The module class parameters work in the same way as the interface component parameters.
  • The basic class defines 6 methods, 3 for import and 3 for export.

Export

SequenceSignatureUseReturn value
1before_send(self)Prepares the module for sending dataNone
2send(self)Send the records as dictionariesMust return all records individually via yield. The yield return value is either True, if the record was successfully received or False, if an error occurred
3after_send(self, was_successful)Here, opened resources can be closed again.
The was_successful parameter indicates whether the transfer was successful.
None

Import

SequenceSignatureUseReturn value
1before_receive(self)Prepares the module for receiving dataNone
2receive(self, record)Is opened once for each record and receives the record.Either returns True, when the record was processed successfully, or it throws a CantProcessRecordException
3after_receive(self, was_successful)Here, opened resources can be closed again.
The was_successful parameter indicates whether the transfer was successful.
None

Create a New Pool Table

Notes

  • Pool tables can be created in PLANTA project just like any other table.
  • In order for PLANTA link to be able to use a table correctly as a pool table, it must contain the following data items:
data itemDI Python IDSQL IDColumn typeDB lengthDF lengthMiscellaneous
UUIDuuidUUIDUUID1636PK
Interface configurationconfig_idCONFIG_IDUUID1636FC for DT 560
StatusstatusSTATUSNumber without DP up to 4 digits22
Transferred ontransferred_onTRANSFERRED_ONAlpha8080

Things to note for interface customizing

Things to note for import interfaces

Caution

  • For interfaces which import into a table which contains a primary key with auto number, e.g. (DT463), the primary key must always be at the first position in the target data area of the target module. This is relevant for later updates.
JavaScript errors detected

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

If this problem persists, please contact our support.