on ‎2018 Jan 31 7:04 AM - last edited on ‎2024 Feb 04 4:11 AM by postmig_api_4
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 ?
Request clarification before answering.
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)?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
| User | Count |
|---|---|
| 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.