1

I have a scenario where I need to call a static method in DRL file. example :

//2
rule "availableTentativeDateIfUsersAvailableGT1"
    salience 2
when
    event  : Event(eventName == "Event1")
then
    getDates(event.parameterization.usersAvailability);
end

Now i need to get the response from the method in DRL. Is it possible?

Konstantin V. Salikhov
  • 4,554
  • 2
  • 35
  • 48
Harish Garg
  • 139
  • 8
  • You can call static methods with no trouble. – Steve Jul 18 '14 at 12:23
  • but how can i get an object in return and how can i access it in DRL? – Harish Garg Jul 18 '14 at 12:34
  • 1
    For more constructive answers, add the Java code of that static method. BTW, the consequence code (between "then" and "end") is plain old Java, with extensions (insert, delete, modify). – laune Jul 18 '14 at 14:27
  • public static void getDates(def usersAvailability){ TentativeDate tentativeDate = new TentativeDate(); List dates = new ArrayList(); println "usersAvailability : " +usersAvailability for(Date date : dateWithAvailableUserCount.keySet()){ Integer noOfUsers = dateWithAvailableUserCount.get(date) if(noOfUsers>=usersAvailability){ dates.add(date); println "Tentative Date is : " + date + " and number of available users : " + noOfUsers; } } tentativeDate.setTentativeDates(dates); } This is a piece of code of my static method – Harish Garg Jul 21 '14 at 10:32
  • I have used insert(getDates(event.parameterization.usersAvailability)) in drl file. Now how can i access TentativeDate(which is return type of method) in java file? – Harish Garg Jul 21 '14 at 11:08
  • anyone please suggest some solution how can i access the objects from working memory using optaplanner? – Harish Garg Jul 21 '14 at 12:37
  • It's unclear to me what you wish to accomplish. If you want to explain to the user why a certain solution has a certain score (so which entities trigger which score constraints), [get the ConstraintMatches](http://docs.jboss.org/drools/release/latest/optaplanner-docs/html_single/index.html#reusingTheScoreCalculationOutsideTheSolver). – Geoffrey De Smet Jul 22 '14 at 06:43
  • Actually i have put an object in working memory using insert in DRL file now i need to get that object in JAVA file. Is it clear now? – Harish Garg Jul 22 '14 at 07:49
  • any update on this question? – Harish Garg Jul 24 '14 at 12:18
  • @GeoffreyDeSmet : Can you update about this question as not able to get the solution of this. – Harish Garg Jul 28 '14 at 09:57

0 Answers0