cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

raw item vs canonical item

Former Member
0 Likes
595

Some of the items which are in target-items.xml file not exists in cononical-items.xml file. I thought whatever is in the target-items.xml file should be in canonical-items.xml file.

Example - target-items.xml file has this attribute.

 <name>b2bUnitName</name>
 <transformationExpression>resolve('CanonicalParty').name</transformationExpression>
 <exportCode>Name</exportCode>

The name attribute not exists in canonical-items.xml file but only exists in raw-items.xml file?

Q= When do we need to define the attributes / items in the canonical items.xml file? Are all the attributes exists in target items need to be in the canonical items.xml file? Some times I am seeing some of the attributes but not all of them in the canonical-items.xml file.

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Likes

In general, canonical item definitions are defined in the *-canonical-datahub-extension.xml, raw types are defined in *-raw-datahub-extension.xml, and target types defined in *-target-datahub-extension.xml. It is best practice to put the raw -> canonical transformations in the *-raw-datahub-extension.xml file and the canonical -> target transformations in the *-target-datahub-extension.xml. But it is not always the case with legacy extensions.

In the example you gave above, the b2bUnitName attribute on the TargetItem (which is unknown to me since it's not in the code snippet) is mapped by looking up the name attribute on the CanonicalParty type. So name must be defined on the CanonicalParty type. Types can be extended, so if you don't see CanonicalParty in your *-canonical-datahub-extension.xml file, or if you don't see the attribute name on CanonicalParty, it means that it is defined on it's parent type. There will be a dependency on another extension where CanonicalParty is defined. Dependencies are usually defined at the top of the extension xml file in the following format:

 <dependencies>
     <dependency>
         <extension>my-extension</extension>
     </dependency>
 </dependencies>

So I can define CanonicalParty type in my-extension. Then I can extend it to have additional attributes in another extension without repeating the attributes that I defined in my-extension.

Former Member
0 Likes

Thanks for the nice explanation. What explained about the relation ship is not clear in the documentation. Now I am clear on it. This name not clear for me..

         <targetItems>
             <item>
                 <type>Company</type>
                 <exportCode>B2BUnit</exportCode>
                 <description>Company</description>
                 <canonicalItemSource>CanonicalParty</canonicalItemSource>
                            <updatable>true</updatable>
                 <attributes>
                     <attribute>
                         <name>uid</name>
                         <transformationExpression>externalPartyId</transformationExpression>
                         <exportCode>uid[unique=true]</exportCode>
                         <mandatoryInHeader>true</mandatoryInHeader>
                     </attribute>
                     <attribute>
                         <name>b2bUnitName</name>
                         <transformationExpression>name</transformationExpression>
                         <exportCode>Name</exportCode>
                     </attribute>
                 </attributes>
             </item>

If you see b2bUnitName --> where exactly used this b2bUnitName? uid --> Where exactly the uid is used? Basically I didn't find the purpose of name tag.

Former Member
0 Likes

The value of the property b2bUnitName on type Company is assigned from the value of the property name on CanonicalParty. Same goes for externalPartyId -> uid.

The properties on the Target Item are used during export. So in the case of exporting to a Hybris target system, those target items are used to generate ImpEx. But if you export to a different target system, you can create an adapter that will grab the property values from Target Item values for a different purpose.

Former Member
0 Likes

Appreciate your quick reply. So far what I understood is in case of Hybris the exportCode tag will go into impex header not the name tag. Let say my target system is Hybris, then what is the purpose of name tag?

Answers (2)

Answers (2)

Former Member
0 Likes

I didn't expect that answer from you. I posted after reading documentation only.

Former Member
0 Likes

I thought this concept is explained well in the documentation. But if you think there are gaps, please let us know how we can improve it.

Former Member
0 Likes

Hi , please go through the Data Hub tutorials. They will answer many of your questions: https://help.hybris.com/6.6.0/hcd/8ba79fcc86691014a83e8530484d3892.html