The documentation from version 39.5.17 of PLANTA project can be found in the new PLANTA Online Help.

Interface Customizing New from S 39.5.4

Create New Mapping Function

Information
  • Mapping functions are stored under ppms.interface and must be importable.
  • The ppms.interface package provides three basic class: BaseConverter, BaseEnricher as well as BaseValidator.

Parameter

Information
  • Each class possesses the PARAMETERS class attribute. Here, a dictionary the key value pair of which shows the parameters with the help of which this interface component can be configured is expected.
  • Here, the key is the text displayed to the user and the value is the default setting.
  • The value of own parameters can be accessed within the instance via the parameters attribute.

Example

  • Here, a validator is defined, that checks whether the transferred value equates to the configured value. For this purpose, a key value pair is defined in the PARAMETERS class attribute, the key of which is the text "value" and has no default value.
  • The configured parameters are accessed via the self parameters within the check method. As a result, the value of the value parameter is opened.
  • Afterwards it is checked whether the transferred value equates to the configured value.

from ppms.interface import BaseValidator, InvalidRecordException

class Equals(BaseValidator):
    PARAMETERS = {'value': ''}
    
    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 New Validator

Information
  • Create a new file at ppms.interface and define a new class that 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

from ppms.interface import BaseValidator, InvalidRecordException

class TaskExists(BaseValidator):
    PARAMETERS = {'project': ''}
    
    def check(self, value):
        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 New Enricher

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

Example: Enricher for replacing a text by another one.

from ppms.interface import BaseEnricher

class Replacer(BaseEnricher):
    """Gives access to the str.replace function"""
    PARAMETERS = {'old_value': '',
                  'new_value': ''}
    
    def enrich(self, arg):
        return arg.replace(self.parameters['old_value'], 
                           self.parameters['new_value'])

Create 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 a text to upper-case letters

from ppms.interface import BaseConverter

class ToUppercase(BaseConverter):
    def convert(self, value):
        return value.upper()

Create New Module Class

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

From S 39.5.5

Export

Order Signatur Use ReturnValue
1 before_send(self) Prepares the module for sending data None
2 send(self) Sends the records as dictionaries Must return all records separately via yield. The return value yield is either True, if the record was successfully received or False, if an error occurred
3 after_send(self, was_successful) Here, opened resources can be closed again.
NEW The was_successful parameter indicates whether the transfer was successful..
None

Import

Order Signatur Use ReturnValue
1 before_receive(self) Prepares the module for sending data None
2 receive(self, record) Is opened once for each record and receives the record Either returns True if the record was processed successfully or throws a CantProcessRecordException
3 after_receive(self, was_successful) Here, opened resources can be closed again.
NEW The was_successful parameter indicates whether the transfer was successful.
None

Up to S 39.5.4

Export

Order Signatur Use ReturnValue
1 before_send(self) Prepares the module for sending data None
2 send(self) Sends the records as dictionaries Must return all records separately via yield. The return value yield is either True, if the record was successfully received or False, if an error occurred
3 after_send(self) Here, opened resources can be closed again None

Import

Order Signatur Use ReturnValue
1 before_receive(self) Prepares the module for sending data None
2 receive(self, record) Is opened once for each record and receives the record Either returns True if the record was processed successfully or throws a CantProcessRecordException
3 after_receive(self) Here, opened resources can be closed again None

Create New Pool Table

Notes

From S 39.5.8

  • Pool tables can be created in PLANTA project just like any other table.
  • NEW In all pool tables, a UUID column must be contained as a primary key so that this table can be used in the interface.
  • Additionally, the following fields are required:

Up to S 39.5.8

  • Pool tables can be created in PLANTA just like any other table.
  • Additionally, the following fields are required:
  • Data item Sort DI Python ID Sort SQL ID Sort Column type Sort DB length Sort DF length Sort Miscellaneous
    Interface configuration config_id CONFIG_ID UUID 16 36 filter criteria to DT560
    Status status STATUS Number without decimal place, up to 4 places 2 2  
    Transferred on transferred_on TRANSFERRED_ON Alpha 80 80




    See also: Here you can find an overview of all PLANTA link contents

             PLANTA project









     
    • Suche in Topic-Namen

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