Harish Garg
Harish Garg

Reputation: 139

How to pass a parameter from request to DRL file in optaplanner?

I need to pass a parameter from request to the DRL file. I need to call a method of java class that takes a parameter but I am not able to access the parameter in DRL.

Can you provide a way to achieve this?

Upvotes: 0

Views: 455

Answers (1)

Geoffrey De Smet
Geoffrey De Smet

Reputation: 27322

From which request? a HTTP request? the loaded dataset?

Before you call Solver.solve(planningProblem), do something like planningProblem.getParametrization().setFoo("bar"). In the DRL, you can then do something like this:

when
    Parametrization($foo : foo) // Parametrization is a singleton
    ...
    MyEntity(methodOnMyEntity($foo) == true)
then
    ...

See the source code of the Examination example.

Upvotes: 1

Related Questions