Chapter 4. Modifying the employee rostering starter application
To modify the employee rostering starter application to suit your needs, you must change the rules that govern the optimization process. You must also ensure that the data structures include the required data and provide the required calculations for the rules. If the required data is not present in the user interface, you must also modify the user interface.
The following procedure outlines the general approach to modifying the employee rostering starter application.
- You have a build environment that successfully builds the application.
- You can read and modify Java code.
Plan the required changes. Answer the following questions:
- What are the additional scenarios that must be avoided? These scenarios are hard constraints.
- What are the additional scenarios that the optimizer must try to avoid when possible? These scenarios are soft constraints.
- What data is required to calculate if each scenario is happening in a potential solution?
- Which of the data can be derived from the information that the user enters in the existing version?
- Which of the data can be hardcoded?
- Which of the data must be entered by the user and is not entered in the current version?
- If any required data can be calculated from the current data or can be hardcoded, add the calculations or hardcoding to existing view or utility classes. If the data must be calculated on the server side, add REST API endpoints to read it.
If any required data must be entered by the user, add the data to the classes representing the data entities (for example, the
Employeeclass), add REST API endpoints to read and write the data, and modify the user interface to enter the data.
When all the data is available, modify the rules. For most modifications, you must add a new rule. The rules are located in the
src/main/resources/org/optaweb/employeerostering/service/solver/employeeRosteringScoreRules.drlfile of the
Use the Drools language for the rules. For reference information about the Drools rule language, see Designing a decision service using DRL rules. Classes defined in the
optaweb-employee-rostering-backendmodules are available to the decision engine.
- After modifying the application, build and run it.