1
0
-1

Hello,

When manipulating a Collection in Bean Shell Tool, I wanted to use the Java 8 stream API (myCollection.stream().filter().andsoon)

In my code I have a collection of WorkflowActivities activities and I want to find the first for which ActivityDefId = "firstMb1" :


Collection activities = workflowManager.getActivityList(processId, null, 30, null, null);

//get user who completed previous activity BM1. Needed : processdefid processid and BM1 activityDefID
WorkflowActivity bmActivity1 = new WorkflowActivity();
WorkflowActivity bmActivity1 = activities.stream()
	.filter(a -> "firstMb1".equals(a.getActivityDefId()))
	.findAny()
	.orElse(null);


But this does'nt work :

ERROR 01 août 2019 06:24:43 org.joget.apps.app.lib.BeanShellTool - Error executing script
Parse error at line 36, column 20. Encountered: >

It actually is my lambda expression that seems to rise an Error.

Any ideas?

Thanks


Baptiste

    CommentAdd your comment...

    2 answers

    1.  
      2
      1
      0

      Hi,

      The parsing issue comes when you write a lambda expression in bean shell. However, i tested the same code by writing a plugin(store/load etc) in a maven plugin and then upload it on Joget and tried, it works. 

      Solution:
      Write your maven plugin with the same code instead of bean shell.Guideline for developing a plugin .

      Thanks

        CommentAdd your comment...
      1.  
        2
        1
        0

        Hi, I believe BeanShell only supports a subset and not the full Java syntax https://github.com/beanshell/beanshell/wiki/Basic-syntax. So stuff like the stream API and generics are not supported.

          CommentAdd your comment...