Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible Fix for Template render error when using entity-find-count with having-econditions #579

Open
gurveenbagga opened this issue Apr 7, 2023 · 0 comments

Comments

@gurveenbagga
Copy link

gurveenbagga commented Apr 7, 2023

When using having-econditions with entity-find-count, encountered below error

06:48:40.952 ERROR   MoquiJob-1      o.moqui.i.c.r.FtlTemplateRenderer Error from FTL in render
freemarker.core.NonHashException: For "...[...]" left-hand operand: Expected a hash, but this has evaluated to a sequence (wrapper: org.moqui.util.MNode$FtlNodeListWrapper):
==> .node["having-econditions"]  [in template "classpath://template/XmlActions.groovy.ftl" at line 212, column 65]

----
FTL stack trace ("~" means nesting-related):
        - Failed at: #list .node["having-econditions"]["*"...  [in template "classpath://template/XmlActions.groovy.ftl" in macro "entity-find-count" at line 212, column 58]
        - Reached through: #recurse  [in template "classpath://template/XmlActions.groovy.ftl" in macro "actions" at line 22, column 1]
        - Reached through: #visit xmlActionsRoot  [in template "classpath://template/XmlActions.groovy.ftl" at line 19, column 1]
----
        at org.moqui.impl.actions.XmlAction.getGroovyString(XmlAction.java:119) ~[moqui_temp2194216266458823044WEB-INF_lib_moqui-framework-3.1.0-rc1.jar.:3.1.0-rc1]
        at org.moqui.impl.actions.XmlAction.writeGroovyWithLines(XmlAction.java:85) ~[moqui_temp2194216266458823044WEB-INF_lib_moqui-framework-3.1.0-rc1.jar.:3.1.0-rc1]
        at org.moqui.impl.actions.XmlAction.makeGroovyClass(XmlAction.java:104) ~[moqui_temp2194216266458823044WEB-INF_lib_moqui-framework-3.1.0-rc1.jar.:3.1.0-rc1]
        at org.moqui.impl.actions.XmlAction.getGroovyClass(XmlAction.java:94) ~[moqui_temp2194216266458823044WEB-INF_lib_moqui-framework-3.1.0-rc1.jar.:3.1.0-rc1]
        at org.moqui.impl.actions.XmlAction.run(XmlAction.java:61) ~[moqui_temp2194216266458823044WEB-INF_lib_moqui-framework-3.1.0-rc1.jar.:3.1.0-rc1]
        at org.moqui.impl.service.runner.InlineServiceRunner.runService(InlineServiceRunner.java:59) ~[moqui_temp2194216266458823044WEB-INF_lib_moqui-framework-3.1.0-rc1.jar.:3.1.0-rc1]
        at org.moqui.impl.service.ServiceCallSyncImpl.callSingle(ServiceCallSyncImpl.java:322) ~[moqui_temp2194216266458823044WEB-INF_lib_moqui-framework-3.1.0-rc1.jar.:3.1.0-rc1]
        at org.moqui.impl.service.ServiceCallSyncImpl.call(ServiceCallSyncImpl.java:125) ~[moqui_temp2194216266458823044WEB-INF_lib_moqui-framework-3.1.0-rc1.jar.:3.1.0-rc1]
        at org.moqui.impl.service.ServiceCallJobImpl$ServiceJobCallable.call(ServiceCallJobImpl.groovy:244) ~[moqui_temp2194216266458823044WEB-INF_lib_moqui-framework-3.1.0-rc1.jar.:3.1.0-rc1]
        at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[?:?]
        at java.lang.Thread.run(Thread.java:829) ~[?:?]

Possible Fix

While exploring the similar behavior and analysing the XmlActions.groovy.ftl for the use of having-econditions in entity-find, replacing the code of line [1]

<#t><#if .node["having-econditions"]?has_content><#list .node["having-econditions"]["*"] as havingCond>.havingCondition(<#visit havingCond/>)</#list></#if>

with

<#t><#if .node["having-econditions"]?has_content><#list .node["having-econditions"][0]?children as havingCond>.havingCondition(<#visit havingCond/>)</#list></#if>

worked and produced the desired result.

I would like to suggest this change in XmlActions.groovy.ftl.
If this looks okay, can I add this an improvement PR?

[1] https://github.com/moqui/moqui-framework/blob/master/framework/template/XmlActions.groovy.ftl#L214

@gurveenbagga gurveenbagga changed the title error Possible Fix for Template render error when using entity-find-count with having-econditions Apr 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant