on 09-05-2018 12:32 PM - last edited on 02-04-2024 6:48 AM by postmig_api_4
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.