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

Canonical Attribute transformation spel Expression Override

Former Member
1,143

The OOTB mapping for CanonicalPartySales in sapcustomer raw xml is as follows.

 <type>CanonicalPartySales</type>
                 <attributes>
                     <attribute>
                         <name>partyId</name>
                         <transformations>
                             <transformation>
                                 <rawSource>RawDEBMAS</rawSource>
                                 <expression spel="true">#root.getField('E1KNA1M-KUNNR') + '_KNA1'</expression>
                             </transformation>
                         </transformations>
                     </attribute>
                     <attribute>

Now i need to over ride the special expression in my custom extension as below.

 <type>CanonicalPartySales</type>
             <attributes>
                 <attribute>
                     <name>partyId</name>
                     <transformations>
                         <transformation override="true">
                             <rawSource>RawDEBMAS</rawSource>
                             <expression spel="true">{'FF','ZZ','YY','XX'}.contains(#root.getField('E1KNA1M-E1KN***-E1KNXXX-PAR**')) ? #root.getField('E1KNA1M-KUN**') + '_KNA1' : null</expression>
                         </transformation>
                     </transformations>
                 </attribute>

But when i do a datahub retsart with datahub.autoInitMode=create-drop am not getting error during server start, but with datahub.autoInitMode=create or datahub.autoInitMode=ignore am getting the below error.

com.hybris.datahub.validation.ValidationException: [ValidationFailure{FATAL, rawAttribute: "Canonical attribute transformation cannot be modifiedCanonicalPartySales, partyId, RawDEBMAS"}] at com.hybris.datahub.validation.AbstractValidator.validate(AbstractValidator.java:32) ~[datahub-service-6.3.0.7-RC1.jar:6.3.0.7-RC1] at com.hybris.datahub.facade.metadata.DefaultTransformationItemClassFacade.createNewAttribute(DefaultTransformationItemClassFacade.java:42) ~[datahub-service-6.3.0.7-RC1.jar:6.3.0.7-RC1]

On checking the code in CanonicalTransformationDataValidator , the following validation is done.

 private void validateThatTransformationCanBeCreated(ValidationContext ctx, CanonicalTransformationData data,
             CanonicalAttributeDefinition existing) {
         if (!data.isDisabled() && !data.isOverride()) {
             this.validateTransformationDoesNotAlreadyExistForAttribute(data, ctx, existing);
         }
 
     }
 
     private void validateTransformationDoesNotAlreadyExistForAttribute(CanonicalTransformationData dataObject,
             ValidationContext context, CanonicalAttributeDefinition existing) {
         if (existing != null) {
             if (this.isTransformationBeingUpdated(existing, dataObject)) {
                 context.addFailure(new ValidationFailure("rawAttribute",
                         "Canonical attribute transformation cannot be modified" + dataObject.getItemType() + ", "
                                 + dataObject.getName() + ", " + dataObject.getRawItemType(),
                         ValidationFailureType.FATAL));
             } else {
                 context.addFailure(new ValidationFailure("rawAttribute",
                         "Canonical attribute transformation already exists: " + dataObject.getItemType() + ", "
                                 + dataObject.getName() + ", " + dataObject.getRawItemType(),
                         ValidationFailureType.EXISTING_ITEM));
             }
         }
 private boolean isTransformationBeingUpdated(CanonicalAttributeDefinition currDef,
             CanonicalTransformationData newDef) {
         String newTransformationExpression = SpelUtils.resolveTransformationExpression(newDef.getExpression(),
                 newDef.isSpel());
         String oldTransformationExpression = currDef.getReferenceAttribute();
         return !Objects.equal(oldTransformationExpression, newTransformationExpression);
     }



So every time if attribute in not disabled i.e (isDisabled is false) and override is false it will enter the loop check for existing SPEL transformation with the new transformation. If both are matching then Canonical attribute transformation already exists: message is thrown else Canonical attribute transformation cannot be modified" is thrown.

Can some one confirm that spEL transformation cant be overidden ? if it can be over ridden , then how ?

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Likes

Hi , has there been any updates to this? We're experiencing the same issue with Datahub 6.3.0.0.

Is there a bug-report or workaround? Which version fixes this issue (assuming that its allready fixed)?

Former Member
0 Likes

Hi , due to the fact that this is not a functionality bug, it has been marked as won't fix. You can simply ignore the exception in the log and know that the value of the transformation expression was overridden correctly.

Former Member
0 Likes

Hi we checked in the database schema , the corresponding old spel attribute Transformation is inactive and our new spel attribute Transformation is active. And cross verified the functionality too , the new expression is getting picked. Not sure if the message is a confusing message , as still an in active spel expression is taken and compared with the new one.


Former Member
0 Likes

Hi , this sounds like a bug. I went ahead and logged it with the team. Can you please provide some more information on the following?

  • Data Hub version you are using

  • Does the extension fail to load after you see the exception, or is the exception logged but the extension still loads properly?

Former Member
0 Likes
  • Dataahub Version: 6.3.0.7

    The extensions are loaded but the exceptions are logged.

Thanks M S Thoppan

Former Member
0 Likes

Just to confirm, is it correct that the new spel transformation expression overrides the old one in the database? If so, at least it is not a functionality bug, just a confusing message to the user, which we will still want to address.

Former Member
0 Likes

any update ? we checked in the database schema , the corresponding old spel attribute Transformation is inactive and our new spel attribute Transformation is active. And cross verified the functionality too , the new expression is getting picked. Not sure if the message is a confusing message , as still an in active spel expression is taken and compared with the new one.