OptaPlanner OpenShift template for Employee Rostering Optimization as a Service
Clone or download

README.adoc

Employee Rostering Optimization as a Service

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

Running on OpenShift Dedicated (paid edition)

Prerequisites

To copy-paste your command, go to the OpenShift Online web console and look for Help > Command line tools.

Setup

  1. Login to OpenShift Dedicated from command line:

    oc login https://api.YOUR_SERVER.openshift.com --token=<tokenId>

    If you don’t know your <tokenId>, log in at the OpenShift web console and look for Help > Command Line Tools.

  2. Create, build and deploy the project.

    ./provision.sh setup --project-suffix mydemo

    The --project-suffix is optional.

  3. It should now be building the pod and running it on OpenShift. Go to the OpenShift Online web console to get the *.openshiftapps.com URL to visit.

Updates

To build and deploy new changes, use:

./provision.sh deploy

Deletion

To delete the OpenShift application and project, run:

./provision.sh delete

Running on OpenShift Online (free edition)

This is not possible to due to resource limitations.

Running on a local OpenShift Origin

  1. If you just installed oc client tools, follow the OpenShift Local Cluster Management docs to get oc cluster (up|down) working.

  2. oc cluster up

  3. oc login, enter developer for both username and password when prompted

  4. oc new-project optaweb-employee-rostering

  5. oc new-app --image-stream="openshift/wildfly:10.1" https://github.com/kiegroup/optaweb-employee-rostering.git#master

To trigger a new build with the latest updates from the master branch, run

oc start-build optaweb-employee-rostering

To delete the OpenShift application and project, run

oc delete project optaweb-employee-rostering

Development

Code formatter

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

Building from source

mvn clean install

Under the covers, OpenShift builds activate the openshift profile. To reproduce locally, add it explicitly (the provision.sh script already does this):

mvn clean package -P openshift

IntelliJ IDEA Ultimate 2018.1

To run SuperDevMode and debug both backend and client code from IDEA you need to create two separate run configurations.

CodeServer run configuration

  1. Create Maven configuration and set following parameters:

    • Working directory: /absolute/path/optaweb-employee-rostering

    • Command line: gwt:codeserver

  2. Make sure launcherDir is configured to point to optaweb-employee-rostering-webapp/target/optaweb-employee-rostering-webapp-${version}/.

    The launcherDir property can be set in pom.xml or via system property.

AppServer run configuration

  1. Add local JBoss Server configuration.

  2. Configure the Application server field to point to a local WildFly 11 installation.

  3. Click Fix button at the bottom of the dialogue and select optaweb-employee-rostering-webbab:war exploded.

  4. Remove any steps that were automatically added to the Before launch phase.

  5. Configure JavaScript debugger:

    • Check After launch and select Chrome browser.

    • Check with JavaScript debugger.

    • Set start page to http://localhost:8080/gwtui/gwtui.html.

    • Set both On Update action and On frame deactivation to Update classes and resources.

Run SuperDevMode in IDEA

  1. Do a clean build:

    mvn clean install -DskipTests
  2. Run the CodeServer configuration in normal mode.

  3. Run the AppServer configuration in debug mode.

You get live update for backend code. You can see client code changes after refreshing the browser or Rerunning the JavaScript debugger. And you can debug both client and backend code in IDEA.

If something goes wrong, do a clean build and click Maven Projects > Reimport All Maven Projects.

IntelliJ IDEA 2017.2 (and below) + CLI

The steps below make sure that the GWT Codeserver will recompile the application after files under src/main/resources are saved.

  1. Import the maven project by choosing the root pom.xml file and selecting Open as project

  2. Install the Save Actions plugin

  3. Restart IntelliJ (required after installing the plugin)

  4. Under Other settings, go to the Save Actions submenu and check either the first or the second options in the General section

  5. Check the Compile file option in the Build actions section

After configuring the Save Actions plugin, you should be able to start Wildfly and deploy the application from the CLI. Note that if you need to restart the GWT Code Server, it’s not mandatory to restart Wildfly.

mvn -N wildfly:start wildfly:deploy
mvn gwt:codeserver

To stop the Wildfly server, use mvn -N wildfly:shutdown.

Eclipse

  1. TODO: Document