/optaweb-employee-rostering

Web application for solving Employee Rostering using OptaPlanner

Primary LanguageTypeScript

Employee Rostering Optimization as a Service

Quality Gate Status Reliability Rating Security Rating Maintainability Rating Lines of Code Coverage

An end-to-end OptaPlanner web application ready to deploy on OpenShift 4.

Building

Build the project with maven in the project’s root directory:

mvn clean install -DskipTests -DskipITs

Running

After building the project, run the application with:

java -jar optaweb-employee-rostering-standalone/target/optaweb-employee-rostering-standalone-*-exec.jar

Then open http://localhost:8080/ to see the web application.

Alternatively, run npm start in optaweb-employee-rostering-frontend to start the frontend in one terminal, and run mvn spring-boot:run in optaweb-employee-rostering-backend to start the backend in another terminal.

Use a different port

To run on an another port use --server.port=…​:

java -jar optaweb-employee-rostering-standalone/target/optaweb-employee-rostering-standalone-*-exec.jar --server.port=18080

Benchmark Application

After building the project above, run the benchmark application with:

java -jar optaweb-employee-rostering-benchmark/target/optaweb-employee-rostering-benchmark-*.jar

Note: make sure to run the project application and benchmark application on different ports if they are run simultaneously.

After benchmarking is complete, a benchmark report will be generated in the local/benchmarkReport directory. Open the index.html file in your browser to view the benchmark results.

Configure the benchmarker

To configure the benchmarker, modify the employeeRosteringBenchmarkConfig.xml file found in the optaweb-employee-rostering-benchmark/src/main/resources directory. Make sure to rebuild the project after modifying the config file for the benchmarker changes to be applied.

Refer to the OptaPlanner Docs for more information on benchmark tweaking.

Running using Docker Compose locally

In order to start running the database(Postgres) and the application, run the below command in your terminal:

docker-compose up

This will bring the database up and also the application. But the application will quit because the necessary database configuration is not setup yet. So you need to configure the database. To do that:

First you need to install the Postgres client. Here is a tutorial to do that for various platforms. Don’t quit the previous terminal tab/window and install the Postgres client in a separate tab/window.

Once you install psql, you can start configuring the database. In a separate terminal tab/window (keep Postgres running from the previous step), follow the below steps.

  1. Connect to the database, by typing the below in command line in a new terminal tab/window:

psql -h localhost -U postgres
  1. You will see the commandline prompt. First create the user that will access the database from the app. Type below in the psql command prompt:

CREATE USER optaweb WITH PASSWORD 'lay123lom6a' CREATEDB;
  1. Now you need to create the database where the data will be stored. Type below in the psql command prompt:

CREATE DATABASE roster OWNER optaweb;

Now you can quit the psql client. Postgres is configured with a user and a fresh new database.

You can now stop the docker-compose either by typing CTRL-C in the terminal tab/window the docker-compose was running or do the below in the same folder your docker-compose.yml file is:

docker-compose down

Now everything is down. Bring them back up by typing:

docker-compose up

Both the app and the database should be running at this stage. Open a browser window and navigate to http://localhost:8080 to see the app running.

Running on a local OpenShift cluster

Use Red Hat CodeReady Containers to easily set up a single-node OpenShift 4 cluster on your local computer.

Prerequisites

You have successfully built the project with Maven.

Procedure
  1. To install CRC, follow the Getting Started Guide.

  2. When the cluster has started,

    1. add oc command-line interface to your $PATH:

      eval $(crc oc-env)
    2. log in as "developer".

  3. Create a new project

    oc new-project project_name
  4. Run the script:

    ./runOnOpenShift.sh

Updating the deployed application with local changes

Backend

Change the source code and build the backend module with Maven. Then start OpenShift build:

cd optaweb-employee-rostering-backend
oc start-build backend --from-dir=. --follow

Frontend

Change the source code and build the frontend module with npm. Then start OpenShift build:

cd optaweb-employee-rostering-frontend
oc start-build frontend --from-dir=docker --follow

Development

Code formatter

Both IntelliJ and Eclipse formatters are available here: https://github.com/kiegroup/droolsjbpm-build-bootstrap/tree/master/ide-configuration

Backend

Configure your IDE to run the main class, which is in org.optaweb.employeerostering.OptaWebEmployeeRosteringApplication in optaweb-employee-rostering-backend repository.

Frontend

Run npm install and then npm start in the optaweb-employee-rostering-frontend directory.