hybris datahub缓存CanonicalItem数据

时间:2018-03-22 09:23:01

标签: caching idoc hybris-data-hub

我为datahub实现了一个新的扩展来处理DEBMAS IDOC&#39。这是我实施的相关部分:

<!-- 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>

当我收到以下IDOC时,它会被正确处理,创建4个地址:

<!-- 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>

当在SAP中删除一个地址时,我将收到仅包含3个地址的相同IDOC。根据IDOC,现有的3个地址对象在hybris中正确创建,但关系(字段&#34;地址&#34;)仍然包含4个地址。因此,我的装饰者认为,在hybris中仍然有4个地址和删除的地址不会被删除。我相信这些信息来自缓存。

以下是相关的CanonicalItem。两者都是在删除过程中创建的。

------正确的CanonicalItem,未发表------

<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>

------错误的CanonicalItem但发布成功------

<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>

有谁知道如何解决这个问题? 提前致谢

安迪

0 个答案:

没有答案