Custom databases

From CDL
(Redirected from Custom database)
Jump to: navigation, search
Managed element
Last edit 30 May 2017 19:20:47
Support contact 
A member of the CDL Team who is responsible for a specific element of the CDL infrastructure.
Kai Hüner

In a custom database, you can store some data in the CDL cloud to analyze or transform this data in several CDL apps. Some apps need to 'understand' your data in order to work properly. For example, the Cleansing App needs to now the address data attributes to cleanse and enrich this data. Hence, to create a custom database, you have to define a data model mapping which specifies how the attributes of the underlying data model of your data are mapped to the CDL data model. Technically, a custom database is just an ordered (by data input) set of key-value records where your data is stored by the values and is accessible by the mapped CDL attribute names or (if not mapped) the source attribute name.


Data model mapping

A data model mapping specifies which custom attributes (i.e. your data model) are mapped to which CDL attributes. The following example shows a basic mapping which maps some default SAP attributes to the semantically related CDL attributes. Data of all "unmapped" attributes is also stored in a custom database and is accessible simply by its source attribute names.

<DataModelMapping xmlns="http://www.corporate-data-league.ch/meta/DataModelMapping">
    
    <!-- apply all default SAP tax identifier mappings -->
    <DefaultMapping>IDENTIFIER</DefaultMapping>
    
    <!-- mapping for unique record identifier -->
    <Mapping cdlAttribute="EXTERNAL_ID">
        <CustomAttribute>LIFNR</CustomAttribute>
    </Mapping>
            
    <!-- business partner attributes -->
    <Mapping cdlAttribute="LOCAL_NAME">
        <CustomAttribute>NAME1</CustomAttribute>
        <CustomAttribute>NAME2</CustomAttribute>
        <CustomAttribute>NAME3</CustomAttribute>
        <CustomAttribute>NAME4</CustomAttribute>
        <Concatenator>_</Concatenator>
    </Mapping>
        
    <!-- to be filled by CDL tools -->
    <Mapping cdlAttribute="BUSINESS_PARTNER_CATEGORY" />
    <Mapping cdlAttribute="LEGAL_FORM" />
    
    <!-- address attributes -->
    <Mapping cdlAttribute="COUNTRY_SHORTNAME">
        <CustomAttribute>Country code</CustomAttribute>
    </Mapping>
    <Mapping cdlAttribute="POST_CODE_VALUE">
        <CustomAttribute>PSTLZ</CustomAttribute>
    </Mapping>   
    <Mapping cdlAttribute="POST_OFFICE_BOX_POST_CODE">
        <CustomAttribute>PSTL2</CustomAttribute>
    </Mapping>
    <Mapping cdlAttribute="POST_OFFICE_BOX_VALUE">
        <CustomAttribute>PFACH</CustomAttribute>
    </Mapping>
    <Mapping cdlAttribute="LOCALITY_VALUE">
        <CustomAttribute>ORT01</CustomAttribute>
    </Mapping>
    <Mapping cdlAttribute="THOROUGHFARE_VALUE">
        <CustomAttribute>STRAS1</CustomAttribute>
        <CustomAttribute>STRAS2</CustomAttribute>
        <CustomAttribute>STRAS3</CustomAttribute>
        <CustomAttribute>STRAS4</CustomAttribute>
        <Concatenator>_</Concatenator>
    </Mapping>
    <Mapping cdlAttribute="THOROUGHFARE_NUMBER">
        <CustomAttribute>HOUSE_NUM2</CustomAttribute>
    </Mapping>

</DataModelMapping>

A data model mapping must be valid regarding the following XML schema:

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.corporate-data-league.ch/meta/DataModelMapping"
    elementFormDefault="qualified"
    xmlns:cdl="http://www.corporate-data-league.ch/meta/DataModelMapping">
    
    <complexType name="Mapping">
        <sequence>
            <element name="CountryScope" minOccurs="0" maxOccurs="unbounded">
                <simpleType>
                    <restriction base="string">
                        <length value="2"></length>
                    </restriction>
                </simpleType>
            </element>
            <element name="CustomAttribute" type="string" minOccurs="0"
                maxOccurs="unbounded">
            </element>
            <element name="Concatenator" minOccurs="0" maxOccurs="1">
                <simpleType>
                    <restriction base="string">
                        <enumeration value="_"></enumeration>
                        <enumeration value="XOR"></enumeration>
                    </restriction>
                </simpleType>
            </element>
        </sequence>
        <attribute name="cdlAttribute" type="string" use="required"></attribute>
    </complexType>

    <complexType name="Splitter">
        <sequence>
            <element name="SourceAttribute" type="string" minOccurs="1"
                maxOccurs="unbounded">
            </element>
            <element name="TargetAttribute" type="string" minOccurs="1"
                maxOccurs="unbounded">
            </element>
            <element name="Concatenator" minOccurs="0" maxOccurs="1">
                <simpleType>
                    <restriction base="string">
                        <enumeration value="_"></enumeration>
                        <enumeration value="XOR"></enumeration>
                    </restriction>
                </simpleType>
            </element>
            <element name="Parameter" type="string" minOccurs="0"
                maxOccurs="unbounded"></element>
        </sequence>
        <attribute name="direction" use="required">
            <simpleType>
                <restriction base="string">
                    <enumeration value="in"></enumeration>
                    <enumeration value="out"></enumeration>
                </restriction>
            </simpleType>
        </attribute>
        <attribute name="type" type="string" use="required"></attribute>
    </complexType>

    <simpleType name="DefaultMappingType">
        <restriction base="string">
            <enumeration value="ALL"></enumeration>
            <enumeration value="IDENTIFIER"></enumeration>
            <enumeration value="BUSINESS_PARTNER"></enumeration>
            <enumeration value="ADDRESS"></enumeration>
            <enumeration value="BUSINESS_PARTNER_ADDRESS"></enumeration>
        </restriction>
    </simpleType>
    
    <element name="DataModelMapping">
        <complexType>
            <sequence>
                <element name="DefaultMapping" type="cdl:DefaultMappingType" nillable="false" minOccurs="0" maxOccurs="1"></element>
                <element name="Mapping" type="cdl:Mapping" minOccurs="0" maxOccurs="unbounded"></element>
                <element name="Splitter" type="cdl:Splitter" minOccurs="0" maxOccurs="unbounded"></element>
            </sequence>
        </complexType>
    </element>
    
</schema>

Attribute mappings

The simplest mapping is just one source attribute mapped to one CDL attribute.

<Mapping cdlAttribute="LOCAL_NAME">
    <CustomAttribute>Name</CustomAttribute>
</Mapping>

If you have multiple attributes with information for the same CDL attribute, you can concatenate data by adding a Concatenator. You can use any characters (e.g. ';', ', ') to concatenate your data. However, due to XML limitations, you have to use special characters for 'whitespace-only' concatenators like ' ' (use _ here).

<Mapping cdlAttribute="LOCAL_NAME">
    <CustomAttribute>Name 1</CustomAttribute>
    <CustomAttribute>Name 2</CustomAttribute>
    <Concatenator>_</Concatenator>
</Mapping>

There might be cases where you want to use data from either one attribute or another. The XOR concatenator uses the first non-empty value from the custom attributes.

<Mapping cdlAttribute="LOCAL_NAME">
    <CustomAttribute>Name A</CustomAttribute>
    <CustomAttribute>Name B</CustomAttribute>
    <Concatenator>XOR</Concatenator>
</Mapping>

Attribute splitters

A splitter is the opposite of a mapper. You can use splitters to map data from one attribute to several CDL attributes, e.g. to explicitly map a legal form from a name attribute.

<Splitter type="cdq.cdl.matching.LegalFormSplitter" direction="in">
    <SourceAttribute>Name 1</SourceAttribute>
    <SourceAttribute>Name 2</SourceAttribute>
    <Concatenator>_</Concatenator>
    <TargetAttribute>LOCAL_NAME</TargetAttribute>
    <TargetAttribute>LEGAL_FORM</TargetAttribute>
</Mapping>

You can also use splitters to split data after analysis or transformation, e.g. to fit them into a target data model. Just use out direction for these cases. The following examples maps data from the local name attribute to two name attributes which have a limited length of 35 characters.

<Splitter type="cdq.cdl.io.splitter.LengthSplitter" direction="out">
    <Parameter>35</Parameter>
    <SourceAttribute>LOCAL_NAME</SourceAttribute>
    <TargetAttribute>Name 1</TargetAttribute>
    <TargetAttribute>Name 2</TargetAttribute>
</Mapping>