cancel
Showing results for 
Search instead for 
Did you mean: 

Spel expression for primary key of canonical in data hub

Former Member
0 Kudos

Hello,

Is it possible to use a spel expression for a canonical primary key. Example:

 <attribute>
                     <name>XXYY</name>
                     <model>
                         <type>String</type>
                         <primaryKey>true</primaryKey>
                     </model>
                     <transformations>
                         <transformation>
                             <rawSource>RawXXXItem</rawSource>
                             <expression spel="true">T(org.apache.commons.lang3.StringUtils).equals(getField('YYY'), 'TTTT') ?
                                 getField(XXX) : 'EMPTY'</expression>
                         </transformation>
                     </transformations>
                 </attribute>

Does not seem to be possible to combine both expression = spel and primaryKey. Correct?

Getting exception:

Exception org.springframework.expression.spel.SpelEvaluationException: EL1008E: Property or field 'XXX' cannot be found on object of type 'com.hybris.datahub.model.RawItem'

The actual rawItem:

         <type>RawXXXItem</type>
         <attributes>
             <attribute>
                 <name>YYY</name>
             </attribute>
             <attribute>
                 <name>XXX</name>
             </attribute>
             <attribute>
                 <name>ZZZZ</name>
             </attribute>
         </attributes>
     </item>

Best Regards

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Found my glasses! The answer to my question is YES. You can use a spel expression transformation as part of the primary key! You just have to use the correct syntax.

T(org.apache.commons.lang3.StringUtils).equals(getField('YYY'), 'TTTT') ? getField(XXX) : 'EMPTY'

should be:

T(org.apache.commons.lang3.StringUtils).equals(getField('YYY'), 'TTTT') ? getField('XXX') : 'EMPTY'

Best Regards

Answers (0)