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.

Prerequisites

  • You have a build environment that successfully builds the application.
  • You can read and modify Java code.

Procedure

  1. 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?
  2. 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.
  3. If any required data must be entered by the user, add the data to the classes representing the data entities (for example, the Employee class), add REST API endpoints to read and write the data, and modify the user interface to enter the data.
  4. 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.drl file of the optaweb-employee-rostering-backend module.

    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-backend modules are available to the decision engine.

  5. After modifying the application, build and run it.