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

Datahub 6.6.0.0 : SPEL expression in not able to produce expected result, please help.

Former Member
0 Kudos
536

Hi Team,

We have a custom Invoice Implementation where I am trying to use the below expression :

root.getField('E1EDK14-QUALF') == '015' ? #root.getField('E1EDK14-ORGID') : null

and I see below error during the server start up ,

2018-04-30 16:44:38,059 [DEBUG] [c.h.d.e.l.i.CanonicalModelLoader] Loading canonical attribute Attribute{name='documentType', model=null, transformations=Transformations{transformation=[Transformation{rawSource='RawINVOIC', expression='Expression{value='#root.getField('E1EDK14-QUALF') == '015' ? #root.getField('E1EDK14-ORGID') : null', spel='true'}, override='false, disabled='false}]}} 2018-04-30 16:44:38,060 [DEBUG] [c.h.d.e.l.i.CanonicalModelLoader] Creating attribute transformationCanonicalTransformationData{rawItemType='RawINVOIC', expression='#root.getField('E1EDK14-QUALF') == '015' ? #root.getField('E1EDK14-ORGID') : null', override='false', disabled='false', spel='true'} 2018-04-30 16:44:38,100 [ERROR] [c.h.d.e.l.i.DefaultExtensionLoaderService] Could not load extension XXXXXXInvoiceHistory-raw com.hybris.datahub.validation.ValidationException: [ValidationFailure{FATAL, rawAttribute: "Canonical attribute transformation cannot be modifiedCanonicalInvoiceHistory, documentType, RawINVOIC"}] at com.hybris.datahub.validation.AbstractValidator.validate(AbstractValidator.java:32) ~[datahub-service-6.6.0.0-RC4.jar:6.6.0.0-RC4] at com.hybris.datahub.facade.metadata.DefaultTransformationItemClassFacade.createNewAttribute(DefaultTransformationItemClassFacade.java:42) ~[datahub-service-6.6.0.0-RC4.jar:6.6.0.0-RC4] at com.hybris.datahub.facade.metadata.DefaultTransformationItemClassFacade.createNewAttribute(DefaultTransformationItemClassFacade.java:32) ~[datahub-service-6.6.0.0-RC4.jar:6.6.0.0-RC4] at com.hybris.datahub.facade.metadata.AbstractItemClassFacade.createAttribute(AbstractItemClassFacade.java:36) ~[datahub-service-6.6.0.0-RC4.jar:6.6.0.0-RC4] at sun.reflect.GeneratedMethodAccessor222.invoke(Unknown Source) ~[na:na] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_151] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_151] at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333) ~[spring-aop-4.3.11.RELEASE.jar:4.3.11.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) ~[spring-aop-4.3.11.RELEASE.jar:4.3.11.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.3.11.RELEASE.jar:4.3.11.RELEASE] at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) ~[spring-tx-4.3.11.RELEASE.jar:4.3.11.RELEASE] at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282) ~[spring-tx-4.3.11.RELEASE.jar:4.3.11.RELEASE] at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) ~[spring-tx-4.3.11.RELEASE.jar:4.3.11.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.11.RELEASE.jar:4.3.11.RELEASE] at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) ~[spring-aop-4.3.11.RELEASE.jar:4.3.11.RELEASE] at com.sun.proxy.$Proxy180.createAttribute(Unknown Source) ~[na:na] at com.hybris.datahub.extension.load.impl.CanonicalModelLoader.loadAttributeTransformations(CanonicalModelLoader.java:104) ~[datahub-extension-loader-6.6.0.0-RC4.jar:6.6.0.0-RC4] at com.hybris.datahub.extension.load.impl.CanonicalModelLoader.createCanonicalAttribute(CanonicalModelLoader.java:90) ~[datahub-extension-loader-6.6.0.0-RC4.jar:6.6.0.0-RC4] at com.hybris.datahub.extension.load.impl.CanonicalModelLoader.lambda$loadCanonicalItemType$0(CanonicalModelLoader.java:59) ~[datahub-extension-loader-6.6.0.0-RC4.jar:6.6.0.0-RC4] at java.util.ArrayList.forEach(ArrayList.java:1255) ~[na:1.8.0_151] at com.hybris.datahub.extension.load.impl.CanonicalModelLoader.loadCanonicalItemType(CanonicalModelLoader.java:59) ~[datahub-extension-loader-6.6.0.0-RC4.jar:6.6.0.0-RC4] at java.util.ArrayList.forEach(ArrayList.java:1255) ~[na:1.8.0_151] at com.hybris.datahub.extension.load.impl.CanonicalModelLoader.loadCanonicalItems(CanonicalModelLoader.java:46) ~[datahub-extension-loader-6.6.0.0-RC4.jar:6.6.0.0-RC4] at com.hybris.datahub.extension.load.impl.DefaultExtensionImportService.loadExtension(DefaultExtensionImportService.java:44) ~[datahub-extension-loader-6.6.0.0-RC4.jar:6.6.0.0-RC4] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_151] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_151] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_151] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_151] at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333) ~[spring-aop-4.3.11.RELEASE.jar:4.3.11.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) ~[spring-aop-4.3.11.RELEASE.jar:4.3.11.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) ~[spring-aop-4.3.11.RELEASE.jar:4.3.11.RELEASE] at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) ~[spring-tx-4.3.11.RELEASE.jar:4.3.11.RELEASE] at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282) ~[spring-tx-4.3.11.RELEASE.jar:4.3.11.RELEASE] at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) ~[spring-tx-4.3.11.RELEASE.jar:4.3.11.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.3.11.RELEASE.jar:4.3.11.RELEASE] at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) ~[spring-aop-4.3.11.RELEASE.jar:4.3.11.RELEASE] at com.sun.proxy.$Proxy186.loadExtension(Unknown Source) ~[na:na] at com.hybris.datahub.extension.load.impl.DefaultExtensionLoaderService.loadExtension(DefaultExtensionLoaderService.java:86) ~[datahub-extension-loader-6.6.0.0-RC4.jar:6.6.0.0-RC4] at java.util.Iterator.forEachRemaining(Iterator.java:116) ~[na:1.8.0_151] at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801) ~[na:1.8.0_151] at java.util.stream.ReferencePipeline$Head.forEachOrdered(ReferencePipeline.java:590) ~[na:1.8.0_151] at com.hybris.datahub.extension.load.impl.DefaultExtensionLoaderService.loadExtensionsInOrder(DefaultExtensionLoaderService.java:78) ~[datahub-extension-loader-6.6.0.0-RC4.jar:6.6.0.0-RC4] at com.hybris.datahub.extension.load.impl.DefaultExtensionLoaderService.loadExtensions(DefaultExtensionLoaderService.java:71) ~[datahub-extension-loader-6.6.0.0-RC4.jar:6.6.0.0-RC4] at com.hybris.datahub.extension.load.impl.DefaultExtensionLoaderService.loadExtensionsFromClasspath(DefaultExtensionLoaderService.java:44) ~[datahub-extension-loader-6.6.0.0-RC4.jar:6.6.0.0-RC4] at com.hybris.datahub.spring.ContextRefreshedEventListener.onApplicationEvent(ContextRefreshedEventListener.java:43) ~[classes/:na] at com.hybris.datahub.spring.ContextRefreshedEventListener.onApplicationEvent(ContextRefreshedEventListener.java:25) ~[classes/:na] at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-4.3.11.RELEASE.jar:4.3.11.RELEASE] at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-4.3.11.RELEASE.jar:4.3.11.RELEASE] at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-4.3.11.RELEASE.jar:4.3.11.RELEASE] at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393) ~[spring-context-4.3.11.RELEASE.jar:4.3.11.RELEASE] at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347) ~[spring-context-4.3.11.RELEASE.jar:4.3.11.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:883) ~[spring-context-4.3.11.RELEASE.jar:4.3.11.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546) ~[spring-context-4.3.11.RELEASE.jar:4.3.11.RELEASE] at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443) ~[spring-web-4.3.11.RELEASE.jar:4.3.11.RELEASE] at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325) ~[spring-web-4.3.11.RELEASE.jar:4.3.11.RELEASE] at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107) ~[spring-web-4.3.11.RELEASE.jar:4.3.11.RELEASE] at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5068) ~[catalina.jar:7.0.68] at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5584) ~[catalina.jar:7.0.68] at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) ~[catalina.jar:7.0.68] at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899) ~[catalina.jar:7.0.68] at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:875) ~[catalina.jar:7.0.68] at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652) ~[catalina.jar:7.0.68] at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1091) ~[catalina.jar:7.0.68] at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1980) ~[catalina.jar:7.0.68] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[na:1.8.0_151] at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_151] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_151] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_151] at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_151]

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

you have to model your attribute documentType as override='true' in your extension otherwise you cannot override the existing one from InvoiceHistory

Former Member
0 Kudos

Thanks ,

could you please let me know if this change has to go in the raw xml or canonical xml ? could you please share any link which has example for this ?

or could you please put the full expression ?

Regards, Gaurav

mansurarisoy
Contributor
0 Kudos

For overriding target item attributes you can investigate the following link: https://help.hybris.com/6.6.0/hcd/d20e0c9523754493b38e19d3be28ec64.html

 <attribute override="true">
      <name>name</name>
       <localizable>false</localizable>
      <collection>false</collection>
      <transformationExpression>name</transformationExpression>
  </attribute>

For overriding canonical item attribute you can investigate the following link: https://help.hybris.com/6.6.0/hcd/57e84aadfd4d40cb9c4b5f288c342b8d.html

 <attribute>
 <name>region</name>
 <transformations>
    <transformation disabled="false" override="true">
       <rawSource>RawCyclingApparel</rawSource>
       <expression>region</expression>
    </transformation>
 </transformations>
 </attribute>
Former Member
0 Kudos

@Ahmet

Thank you! this suggestion has worked , but could you please let me know how does it work internally ? Does it create for loop internally? Is it better than creating a composition handler ? Can this approach give performance boost ?

Former Member
0 Kudos

Internally during extension load the old attribute definition is replaced with the new one. but only if overwite=true. then datahub acts as if there was only one definition.

mansurarisoy
Contributor
0 Kudos

Hi ,

What said is correct. And you need to be careful when overriding canonical item definitions, you have to set its properties correct when overriding. For example if you set localizable true of an attribute which is defined as localizable false previously, your overridden transformation won't work.

Former Member
0 Kudos

, Thank you. could you please let me know from performance point of view how the code works in the back-end?

mansurarisoy
Contributor
0 Kudos

Override commands take effect during startup. Data Hub creates a new record in canonicalattrdef table and changes the previous definition status to inactive (updates active column as false). Similar things occur for Target Items in targetattrdef table (e.g. in screenshots). And since it takes effect during startup I don't think there is any performance drawback about overriding an attribute.

Former Member
0 Kudos

, Reason why I asked is , currently I have written a composition handler. which iterates over all the canonical items for one raw type (i.e. RawASN) and once it matches to the value of the required raw attribute then it pick the value and puts into a canonical item.

mansurarisoy
Contributor
0 Kudos

I'm not sure that I understand your requirement. Do you need to filter Raw Items or do you need to use just specific values (a map of valid values or something) for Canonial Items? If you explain your requirement more clearly, I'll try to help you if I can.

Former Member
0 Kudos

Hi ,

Requirement : " 015 Z8C1

In the above segment we have to pick value of , if value of is '015' . To achieve that I have written a composition handler which iterates though all the canonicalItems , and when it finds the canonical Item as documentType then it fetches the value of , as it involves a loop that is why I would like to do this activity via other approach"

mansurarisoy
Contributor
0 Kudos

If you want to take the value of your CanonicalItem's attribute from E1EDK14-ORGID segment only if E1EDK14-QUALF is equal 015, otherwise null, your first approach with <transformation override=true> should work with the following SPEL expression:

 #root.getField('E1EDK14-QUALF') == '015' ? #root.getField('E1EDK14-ORGID') : null

However if you want to compose CanonicalItems only if E1EDK14-QUALF segment is equal to 015 then you need to write a CompositionHandler to achieve this.