Search code examples
springspring-bootoptaplanner

how can I use spring boot Service class in .drl files in Optaplanner Planning projects?


not in drools project, just in Optaplanner planning project. Optaplanner with drools engine!!! use spring boot service classs in drools project

here more info about this question code structure

here service's function in drl file

rule "RuleLimosis"
when
    ViewPatient($RevId:Id,$PatientID:PatientID, PatientID != null)
then
    boolean limosisFlag = viewPatientService.getChecklistLimosis($RevId);
    System.out.println("empty stomach status: " + limosisFlag);

end

runtime info use @ProblemFactProperty in planning solution class

1 System.out.println("in java file viewPatientService is: " + viewPatientService);

2 System.out.println("in drl one file viewPatientService is: " + viewPatientService);

code 1 have correct value code 2 null


Solution

  • You could wrap the service in a class and create a @ProblemFactProperty field of that wrapper class in the planning solution.

    But your constraints shouldn't be calling remote services as that will cripple your score calculation speed.