简体   繁体   中英

hybris datahub caches CanonicalItem datas

I implemented a new extension for datahub to process DEBMAS IDOC's. This are the relevant part of my implementation:

<!-- raw.xml -->
<type>CanonicalParty</type>
    <attributes>
        ....
        <attribute>
            <name>addresses</name>
            <transformations>
                <transformation>
                    <rawSource>RawDEBMASU</rawSource>
                    <expression spel="true">T(org.apache.commons.lang3.StringUtils).stripStart(getField("E1KNA1M-KUNNR"),"0")
                        + '|' + T(org.apache.commons.lang3.StringUtils).stripStart(getField("E1KNA1M-E1KNVVM-E1KNVPM-KUNN2"),"0")
                        + '|' + 'KNA1' + '|' + getField("E1KNA1M-E1KNVVM-E1KNVPM-PARVW")</expression>
                </transformation>
            </transformations>
        </attribute>
        ...
    </attributes>
</item>

<!-- canonical.xml -->
<canonicalItems>
    <item>
        <type>CanonicalParty</type>
        <attributes>
            ...
            <attribute>
                <name>addresses</name>
                <model>
                    <localizable>false</localizable>
                    <collection>true</collection>
                    <type>String</type>
                    <primaryKey>false</primaryKey>
                </model>
            </attribute>
            ...
        </attributes>
    </item>
</canonicalItems>

<!-- target.xml -->
<targetItems>
    <item>
        <type>Company</type>
        <exportCode>B2BUnit</exportCode>
        <description>Company</description>
        <updatable>true</updatable>
        <canonicalItemSource>CanonicalParty</canonicalItemSource>
        <status></status>
        <attributes>
            ...
            <attribute>
                <name>addresses</name>
                <localizable>false</localizable>
                <collection>true</collection>
                <transformationExpression>addresses</transformationExpression>
                <exportCode>addresses(publicKey)[cellDecorator=ch.vzug.internet.imports.datahub.decorator.VzugAddressRemoveDecorator][mode=replace]</exportCode>
                <mandatoryInHeader>false</mandatoryInHeader>
            </attribute>
            ...
        </attributes>
    </item>
</targetItems>

When I receive the following IDOC it is processed correctly, creating 4 addresses:

<!-- Example IDOC -->
<ZDEBMASENH1>
    <IDOC BEGIN="1">
    ...
    <E1KNVPM SEGMENT="1">
        <MSGFN>005</MSGFN>
        <PARVW>AG</PARVW>
        <KUNN2>0010022191</KUNN2>
        <PARZA>000</PARZA>
        <Z1E1KNVPM SEGMENT="1">
            ...
        </Z1E1KNVPM>
    </E1KNVPM>
    <E1KNVPM SEGMENT="1">
        <MSGFN>005</MSGFN>
        <PARVW>RE</PARVW>
        <KUNN2>0010022191</KUNN2>
        <PARZA>000</PARZA>
        <Z1E1KNVPM SEGMENT="1">
            ...
        </Z1E1KNVPM>
    </E1KNVPM>
    <E1KNVPM SEGMENT="1">
        <MSGFN>005</MSGFN>
        <PARVW>WE</PARVW>
        <KUNN2>0015000461</KUNN2>
        <DEFPA>X</DEFPA>
        <PARZA>000</PARZA>
        <Z1E1KNVPM SEGMENT="1">
            ...
        </Z1E1KNVPM>
    </E1KNVPM>
    <E1KNVPM SEGMENT="1">
        <MSGFN>005</MSGFN>
        <PARVW>WE</PARVW>
        <KUNN2>0015000500</KUNN2>
        <DEFPA>X</DEFPA>
        <PARZA>000</PARZA>
        <Z1E1KNVPM SEGMENT="1">
            ...
        </Z1E1KNVPM>
    </E1KNVPM>
    ...
    </IDOC>
</ZDEBMASENH1>

When one address is deleted in SAP, I will receive the same IDOC containing only 3 addresses. The existing 3 address object are created correctly in hybris according to the IDOC, but the relation (field "addresses") still contains 4 addresses. Therefore, my decorator believes, there are still 4 addresses and the deleted one will not be deleted in hybris. I believe this information comes from a cache.

Here are the related CanonicalItem. Both are created during deletion process.

------ Correct CanonicalItem, not published ------

<itemData>
<type>CanonicalParty</type>
<dataPool>SAPCUSTOMER_INBOUND_POOL</dataPool>
<id>19</id>
<attribute>
<name>compositionAction</name>
<values>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">2</value>
</values>
</attribute>
<attribute>
<name>integrationKey</name>
<values>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">10022191</value>
</values>
</attribute>
<attribute>
<name>rawItems</name>
<values>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:long">7</value>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:long">9</value>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:long">11</value>
</values>
</attribute>
<attribute>
<name>publicationStatuses</name>
</attribute>
<attribute>
<name>status</name>
<values>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">ARCHIVED</value>
</values>
</attribute>
<attribute>
<name>lastName</name>
<values>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">TestName</value>
</values>
</attribute>
<attribute>
<name>parent</name>
</attribute>
<attribute>
<name>addresses</name>
<values>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">10022191|15000461|KNA1|WE</value>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">10022191|10022191|KNA1|RE</value>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">10022191|10022191|KNA1|AG</value>
</values>
</attribute>
<attribute>
<name>communicationLanguage</name>
<values>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">DE</value>
</values>
</attribute>
<attribute>
<name>role</name>
</attribute>
<attribute>
<name>gender</name>
<values>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">2</value>
</values>
</attribute>
<attribute>
<name>accountGroup</name>
<values>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">YA00</value>
</values>
</attribute>
<attribute>
<name>dateOfBirth</name>
<values>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">00000000</value>
</values>
</attribute>
<attribute>
<name>title</name>
<values>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">0003</value>
</values>
</attribute>
<attribute>
<name>type</name>
</attribute>
<attribute>
<name>customerCountry</name>
<values>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">CH</value>
</values>
</attribute>
<attribute>
<name>firstName</name>
<values>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">Peter</value>
</values>
</attribute>
<attribute>
<name>externalPartyId</name>
</attribute>
<attribute>
<name>function</name>
</attribute>
<attribute>
<name>name</name>
<values>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">TestCompany Name</value>
</values>
</attribute>
<attribute>
<name>partyId</name>
<values>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">10022191</value>
</values>
</attribute>
<attribute>
<name>department</name>
</attribute>
<link rel="RawItemSource" href="http://localhost:8080/datahub-webapp/v1/raw-items/7"/>
<link rel="RawItemSource" href="http://localhost:8080/datahub-webapp/v1/raw-items/9"/>
<link rel="RawItemSource" href="http://localhost:8080/datahub-webapp/v1/raw-items/11"/>
</itemData>

------ Wrong CanonicalItem but published successfully ------

<itemData>
<type>CanonicalParty</type>
<dataPool>SAPCUSTOMER_INBOUND_POOL</dataPool>
<id>18</id>
<attribute>
<name>compositionAction</name>
<values>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">2</value>
</values>
</attribute>
<attribute>
<name>integrationKey</name>
<values>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">10022191</value>
</values>
</attribute>
<attribute>
<name>rawItems</name>
</attribute>
<attribute>
<name>publicationStatuses</name>
<values>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="canonicalItemPublicationStatusData">
<targetSystemPublicationId>5</targetSystemPublicationId>
<targetSystemName>HybrisCore</targetSystemName>
<type>CanonicalParty</type>
<canonicalItemId>18</canonicalItemId>
<integrationKey>10022191</integrationKey>
<status>SUCCESS</status>
</value>
</values>
</attribute>
<attribute>
<name>status</name>
<values>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">SUCCESS</value>
</values>
</attribute>
<attribute>
<name>lastName</name>
<values>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">TestName</value>
</values>
</attribute>
<attribute>
<name>parent</name>
</attribute>
<attribute>
<name>addresses</name>
<values>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">10022191|15000461|KNA1|WE</value>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">10022191|10022191|KNA1|RE</value>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">10022191|10022191|KNA1|AG</value>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">10022191|15000502|KNA1|WE</value>
</values>
</attribute>
<attribute>
<name>communicationLanguage</name>
<values>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">DE</value>
</values>
</attribute>
<attribute>
<name>role</name>
</attribute>
<attribute>
<name>gender</name>
<values>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">2</value>
</values>
</attribute>
<attribute>
<name>accountGroup</name>
<values>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">YA00</value>
</values>
</attribute>
<attribute>
<name>dateOfBirth</name>
<values>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">00000000</value>
</values>
</attribute>
<attribute>
<name>title</name>
<values>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">0003</value>
</values>
</attribute>
<attribute>
<name>type</name>
</attribute>
<attribute>
<name>customerCountry</name>
<values>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">CH</value>
</values>
</attribute>
<attribute>
<name>firstName</name>
<values>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">Peter</value>
</values>
</attribute>
<attribute>
<name>externalPartyId</name>
</attribute>
<attribute>
<name>function</name>
</attribute>
<attribute>
<name>name</name>
<values>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">TestCompany Name</value>
</values>
</attribute>
<attribute>
<name>partyId</name>
<values>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">10022191</value>
</values>
</attribute>
<attribute>
<name>department</name>
</attribute>
</itemData>

Does anyone has an idea how to solve that issue? Thanks in advance

Andy

The Canonical item is regulated by the Collections framework in java. Within the collections the items are noted and therefore your 4 items are expected what you have drawn as cache. Initialize the collection in the appropriate Java code once to see what happens.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM