Automation : RuleProvider : Use module outputs as config parameters on the next module [message #1720477] |
Mon, 18 January 2016 20:35 |
Karel Goderis Messages: 198 Registered: March 2014 |
Senior Member |
|
|
I trying to build a RuleProvider whereby I would use a Context to provide the trigger with some inputs.
This trigger does nothing at all, but I would like to use some of the context variables as parameters for the Configuration of the ActionModule of the Rule, and not as parameters for the inputs of the ActionModule. e.g. I would like to do something like:
Before triggering the trigger:
Map<String, Object> context = new HashMap<String, Object>();
context.put(SomeType.INPUT_EXPRESSION, someString);
In the RuleProvider bit where the Rule is built:
config = new HashMap<String, Object>();
config.put("script", triggerId + "." + SomeType.INPUT_EXPRESSION);
List<Action> actions = new ArrayList<Action>();
actions.add(new Action("MyScriptAction", "ScriptAction", config, null));
Is this kind of construct allowed?
If not, then because of the fact that ScriptAction takes the script it needs to execute as a Configuration parameter, and not as an Input, I would have to build a separate Rule for each different script I would like to flow through the Rule (e.g. I would need to develop a RuleTemplate and apply that over and over)
It would be very convenient to be able to "dynamically" configure a Module by using the Outputs of a previous Module
Karel
[Updated on: Mon, 18 January 2016 20:36] Report message to a moderator
|
|
|
Re: Automation : RuleProvider : Use module outputs as config parameters on the next module [message #1720597 is a reply to message #1720477] |
Tue, 19 January 2016 15:38 |
Karel Goderis Messages: 198 Registered: March 2014 |
Senior Member |
|
|
No one?
Studying the source code of the new Rule Engine it find the ambiguity between Inputs and Configurations more and more troublesome. It is very confusing on when a parameter should be a fixed value as part of the configuration of a Module, as to when it should/could be an Input. In some case, either one could work, and to achieve maximum re-usage of a Module, you could even put the same parameter as an Input and a Configuration element.
Because the only other way to render Rules variable is to us RuleTemplates, in case you get stuck with a Module you want to use. For example, the ScriptAction module takes the content of the Script to execute under the form of a Configuration. But I would prefer to have it as an Input, so that I can feed the same ScriptActionModule instance different scripts, for processing by the same underlying ScriptEgine. Another example: in the newly introduced Java API example PR, the StateConditionHandler works with both an element through the Input, and other one via the Configuration. How to decide what is appropriate?
I think this should be clarified, otherwise we will end up with a lot of boiler plate code over and over again to solve the same trivial "problem"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02493 seconds