
######
Simple
######


****
NAME
****


Kernel::GenericInterface::Mapping::Simple - GenericInterface simple data mapping backend


****************
PUBLIC INTERFACE
****************


new()
=====


usually, you want to create an instance of this
by using Kernel::GenericInterface::Mapping->new();


Map()
=====


provides 1:1 and regex mapping for keys and values
also the use of a default for keys and values that were not mapped is possible

we need the config to be in the following format


.. code-block:: perl

     $Self->{MappingConfig}->{Config} = {
         KeyMapExact => {           # optional. key/value pairs for direct replacement
             'old_value'         => 'new_value',
             'another_old_value' => 'another_new_value',
             'maps_to_same_value => 'another_new_value',
         },
         KeyMapRegEx => {           # optional. replace keys with value if current key matches regex
             'Stat(e|us)'  => 'state',
             '[pP]riority' => 'prio',
         },
         KeyMapDefault => {         # required. replace keys if the have not been replaced before
             MapType => 'Keep',     # possible values are
                                    # 'Keep' (leave unchanged)
                                    # 'Ignore' (drop key/value pair)
                                    # 'MapTo' (use provided value as default)
             MapTo => 'new_value',  # only used if 'MapType' is 'MapTo'. then required
         },
         ValueMap => {              # optional.
             'new_key_name' => {    # optional. Replacement for a specific key
                 ValueMapExact => { # optional. key/value pairs for direct replacement
                     'old_value'         => 'new_value',
                     'another_old_value' => 'another_new_value',
                     'maps_to_same_value => 'another_new_value',
                 },
                 ValueMapRegEx => { # optional. replace keys with value if current key matches regex
                     'Stat(e|us)'  => 'state',
                     '[pP]riority' => 'prio',
                 },
             },
         },
         ValueMapDefault => {       # required. replace keys if the have not been replaced before
             MapType => 'Keep',     # possible values are
                                    # 'Keep' (leave unchanged)
                                    # 'Ignore' (drop key/value pair)
                                    # 'MapTo' (use provided value as default)
             MapTo => 'new_value',  # only used if 'MapType' is 'MapTo'. then required
         },
     };
 
     my $ReturnData = $MappingObject->Map(
         Data => {
             'original_key' => 'original_value',
             'another_key'  => 'next_value',
         },
     );
 
     my $ReturnData = {
         'changed_key'          => 'changed_value',
         'original_key'         => 'another_changed_value',
         'another_original_key' => 'default_value',
         'default_key'          => 'changed_value',
     };



_ConfigCheck()
==============


does checks to make sure the config is sane


.. code-block:: perl

     my $Return = $MappingObject->_ConfigCheck(
         Config => { # config as defined for Map
             ...
         },
     );


in case of an error


.. code-block:: perl

     $Return => {
         Success      => 0,
         ErrorMessage => 'An error occurred',
     };


in case of a success


.. code-block:: perl

     $Return = {
         Success => 1,
     };





