Chapter 15. Building and running the employee rostering starter application

You can build the employee rostering starter application from the source code and run it as a JAR file.

Alternatively, you can use your IDE, for example, Eclipse (including Red Hat CodeReady Studio), to build and run the application.

15.1. Preparing deployment files

You must download and prepare the deployment files before building and deploying the application.

Procedure

  1. Download the rhpam-7.10.0-reference-implementation.zip file from the Software Downloads page for Red Hat Process Automation Manager 7.10.
  2. Unzip the downloaded archive.
  3. Copy the contents of the jboss-rhba-7.10.0.GA-maven-repository/maven-repository subdirectory into the ~/.m2/repository directory.
  4. Expand the rhpam-7.10.0-optaweb-employee-rostering.zip file that is extracted from the reference implementation archive.

    The optaweb-employee-rostering-distribution-7.48.0.Final-redhat-00004 folder is created. This folder is the base folder in subsequent parts of this document.

    Note

    File and folder names might have higher version numbers than specifically noted in this document.

15.2. Running the Employee Rostering starter application JAR file

You can run the Employee Rostering starter application from a JAR file included in the reference implementation download.

Prerequisites

  • You have downloaded and extracted the rhpam-7.10.0-reference-implementation.zip file as described in Section 15.1, “Preparing deployment files”.
  • A Java Development Kit is installed.
  • Maven is installed.
  • The host has access to the Internet. The build process uses the Internet for downloading Maven packages from external repositories.

Procedure

  1. In a command terminal, change to the sources directory.
  2. Enter the following command:

    mvn clean install -DskipTests
  3. Wait for the build process to complete.
  4. Navigate to the optaweb-employee-rostering-distribution-7.48.0.Final-redhat-00004/sources/optaweb-employee-rostering-standalone/target directory.
  5. Enter the following command to run the Employee Rostering JAR file:

    java -jar optaweb-employee-rostering-standalone-*-exec.jar
    Note

    This command starts the employee rostering application with a non-production database. To start the employee rostering application with a production database, add the --spring.profiles.active=production argument to the preceding command.

  6. To access the application, enter http://localhost:8080/ in a web browser.

15.3. Building and running the Employee Rostering starter application using Maven

You can use the command line to build and run the employee rostering starter application.

If you use this procedure, the data is stored in memory and is lost when the server is stopped. To build and run the application with a database server for persistent storage, see Section 15.4, “Building and running the employee rostering starter application with persistent data storage from the command line”.

Prerequisites

  • You prepared the deployment files as described in Section 15.1, “Preparing deployment files”.
  • A Java Development Kit is installed.
  • Maven is installed.
  • The host has access to the Internet. The build process uses the Internet for downloading Maven packages from external repositories.

Procedure

  1. Navigate to the optaweb-employee-rostering-backend directory.
  2. Enter the following command:

    mvn spring-boot:run
  3. Navigate to the optaweb-employee-rostering-frontend directory.
  4. Enter the following command:

    npm start
    Note

    If you use npm to start the server, npm monitors code changes.

  5. To access the application, enter http://localhost:3000/ in a web browser.

15.4. Building and running the employee rostering starter application with persistent data storage from the command line

If you use the command line to build the employee rostering starter application and run it, you can provide a database server for persistent data storage.

Prerequisites

  • You prepared the deployment files as described in Section 15.1, “Preparing deployment files”.
  • A Java Development Kit is installed.
  • Maven is installed.
  • The host has access to the Internet. The build process uses the Internet for downloading Maven packages from external repositories.
  • You have a deployed MySQL or PostrgeSQL database server.

Procedure

  1. In a command terminal, navigate to the optaweb-employee-rostering-standalone/target directory.
  2. Enter the following command to run the Employee Rostering JAR file:

    java -jar optaweb-employee-rostering-standalone-*-exec.jar --spring.profiles.active=production
    spring.datasource.url=<DATABASE_URL> --spring.datasource.username=<DATABASE_USER> --spring.datasource.password=<DATABASE_PASSWORD>

    In this example, replace the following placeholders:

    • <DATABASE_URL>: URL to connect to the database, for example jdbc:postgresql://postgresql:5432/MY_DATABASE
    • <DATABASE_USER>: The user to connect to the database
    • <DATABASE_PASSWORD>: The password for <DATABASE_USER>

15.5. Building and running the employee rostering starter application using IntelliJ IDEA

You can use IntelliJ IDEA to build and run the employee rostering starter application.

Prerequisites

  • You have downloaded the Employee Rostering source code, available from the Employee Rostering GitHub page.
  • IntelliJ IDEA, Maven, and Node.js are installed.
  • The host has access to the Internet. The build process uses the Internet for downloading Maven packages from external repositories.

Procedure

  1. Start IntelliJ IDEA.
  2. From the IntelliJ IDEA main menu, select FileOpen.
  3. Select the root directory of the application source and click OK.
  4. From the main menu, select RunEdit Configurations.
  5. In the window that appears, expand Templates and select Maven. The Maven sidebar appears.
  6. In the Maven sidebar, select optaweb-employee-rostering-backend from the Working Directory menu.
  7. In Command Line, enter spring-boot:run.
  8. To start the back end, click OK .
  9. In a command terminal, navigate to the optaweb-employee-rostering-frontend directory.
  10. Enter the following command to start the front end:

    npm start
  11. To access the application, enter http://localhost:3000/ in a web browser.