Chapter 3. Overview of the source code of the employee rostering starter application
The employee rostering starter application consists of the following principal components:
- The server that implements the rostering logic using Red Hat Business Optimizer and provides a REST API.
-
The client that implements a user interface using the
gwt
library and calls the server using the REST API.
While some code is shared between the client and the server, you can build and use these components independently. In particular, you can implement a different user interface and use the REST API to call the server.
In addition to the two main components, the employee rostering template contains a generator of random source data (useful for demonstration and testing purposes) and a benchmarking application.
Modules and key classes
The Java source code of the employee rostering template contains several Maven modules. Each of these modules includes a separate aven project file (pom.xml
), but they are intended for building in a common project.
The modules contain a number of files, including Java classes. This document lists all the modules, as well as the classes and other files that contain the key information for the employee rostering calculations.
-
employee-rostering-benchmark
module: Contains an additional application that generates random data and benchmarks the solution. -
employee-rostering-distribution
module: Contains readme files. -
employee-rostering-docs
module: Contains documentation files. -
employee-rostering-gwtui
module: Contains the client application with the user interface, developed using thegwt
toolkit. employee-rostering-server
module: Contains the server application that uses Red Hat Business Optimizer to perform the rostering calculation.-
src/main/resources/org/optaweb/employeerostering/server/solver/employeeRosteringScoreRules.drl
file: Contains the rules for the Red Hat Business Optimizer calculation. These rules are written in the Drools rules language. You can modify the rules to change the logic for employee rostering. -
src/main/java/org.optaweb.employeerostering.server.roster/rosterGenerator.java
class: generates random input data for demonstration and testing purposes. If you change the requires input data, change the generator accordingly.
-
employee-rostering-shared
module: Contains the data structures shared between the server and client applications. In particular, undersrc/main/java/org/optaweb/employeerostering/shared/*
, this module includes the Java classes that define the input data for the rostering calculations, including the following classes:-
employee/EmployeeAvailability.java
defines availability information for an employee. For every time slot, an employee can be unavailable, available, or it can be a preferred timeslot for the employee. -
employee/Employee.java
defines an employee. An employee has a name and a list of skills. Skills are represented byEmployeeSkillProficiency
objects. -
roster/Roster.java
defines the calculated rostering information. -
shift/Shift.java
defines a shift to which an employee can be assigned. A shift is defined by a time slot and a spot. For example, in a diner there could be a shift in theKitchen
spot for theFebruary 20 8AM-4PM
time slot. Multiple shifts can be defined for a given spot and time slot; in this case, multiple employees are required for this spot and time slot. -
skill/Skill.java
defines a skill that an employee can have. -
spot/Spot.java
defines a spot where employees can be placed. For example, in a dinerKitchen
can be a spot. tenant/Tenant.java
defines a tenant. Each tenant represents an independent set of data; any change in the data for one tenant does not affect any other tenants.The
employee-rostering-shared
module also includes other shared artifacts:-
*View.java
classes define value sets that are calculated from other information; the client application can read these values through the REST API, but not write them. -
*RestService.java
interfaces define the REST API. Both the server and the client application separately define implementations of these interfaces.
-
-
employee-rostering-shared-gwt
module: Contains some of the classes required for the GWT client application. -
employee-rostering-webapp
module: Contains the HTML and other files necessary for building the entire application (client and server).