Get the front end web shop application

The online web shop frontend application is a source project you can download and build from scratch. Get the project in one of the two following ways:
  • $ git clone https://gitlab.com/bpmworkshop/rhdm-retail-webshop-frontend-repo.git
  • Download and unzip

Building front end web shop application

Next step is to build the front end for your web shop. If you used the git clone option to get the code project:
  • $ cd rhdm-retail-webshop-frontend-repo


If you used the DOWNLOAD AND UNZIP option to get the project code:
  • $ cd rhdm-retail-webshop-frontend-repo-master


Finally, build using: $ mvn clean install

A common build error

If you try and build this project before you build and deploy the rules project for the web shop in the Decision Central tooling, you might see the following error results. The initial build creates a kjar file in your local maven repository, by not building in Decision Central it's missing:
Could not resolve dependencies for project com.redhat:webstore-demo:war:3.0.0-FINAL: Failed to collect dependencies at com.redhat.demo.retail:retail-webshop:jar:LATEST: Failed to read artifact descriptor for com.redhat.demo.retail:retail-webshop:jar:LATEST: Failed to resolve version for com.redhat.demo.retail:retail-webshop:jar:LATEST: Could not find metadata com.redhat.demo.retail :retail-webshop/maven-metadata.xml in local (/home/erics/.m2/repository)

Failed to resolve version for com.redhat.demo.retail:retail-webshop:jar:LATEST: Could not find metadata com.redhat.demo.retail:retail-webshop/maven-metadata.xml in local (/home/erics/.m2/repository)
SOLUTION: Be sure to DEPLOY (not just BUILD) your rules project from Decision Central to add the resulting kjar to your local maven repository.

Build directory deployable artifact

After the build finishes, you'll find a new target directory with the deployable artifact labeled webstore-demo.war:

Copy front end application to server

To deploy the built web shop application, copy it to the application server deployments directory as follows:

$ cp target/webstore-demo.war [path-to-project-root]/target/jboss-eap-7.3/standalone/deployments/

Start the server and verify

If you watch the server log during server start up from the console, you'll notice the application kicks off with 'Starting deployment...':

17:15:38,486 INFO [org.jboss.as.repository] (DeploymentScanner-threads - 2) WFLYDR0001: Content added at location rhdm-install-demo/target/jboss-eap-7.3/standalone/data/content/be/29fc6a90596/content
17:15:38,488 INFO [org.jboss.as.server.deployment] (MSC service thread 1-6) WFLYSRV0027: Starting deployment of "webstore-demo.war" (runtime-name: "webstore-demo.war")

Front end application deployed

The server log should show the deployment of your web shop application end with something like this:

17:15:42,220 INFO [com.vaadin.cdi.internal.ContextDeployer] (ServerService Thread Pool -- 98) Mapping VaadinServlet to /*
17:15:42,220 INFO [com.vaadin.cdi.internal.ContextDeployer] (ServerService Thread Pool -- 98) Done deploying Vaadin UIs
17:15:42,221 INFO [org.wildfly.extension.undertow] WFLYUT0021: Registered web context: '/webstore-demo' for server 'default-server'
17:15:42,231 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) WFLYSRV0010: Deployed "webstore-demo.war" (runtime-name : "webstore-demo.war")

Welcome to the web shop

Open the online web shop application at:
http://localhost:8080/webstore-demo

Demo Web Shop - Verify shipping costs

We'll demo a shopper using the shopping cart and the shipping values being calculated by the decision table we created:
  • select Forge Laptop Sticker and click ADD TO CART
  • shipping is 2.99, cart total is 8.50 + 2.99 = 11.49

Demo Web Shop - Change shipping table

Now go back and change the shipping table value for tier 1:

  • login and open the guided decision table Shipping Rules
  • change Shipping Tier 1 Shipping Total value to 22.99 (we're trying to discourage small purchases)

Demo Web Shop - Settings rules deployment

Now we are going to deploy the rules with a new version (change rules without having to redeploy the web front end application):
  • save the rule
  • open settings tab for project
  • bump up the Version: 1.0.1
  • SAVE settings

Demo Web Shop - Deploy modified rules

Deploy the new version of your rules project:
  • click the DEPLOY button and wait for green conformation pop-up
  • check the server log, we're looking for the KieScanner from your application to pick up the new version of your rules you just deployed:


19:35:56,968 INFO [org.kie.api.builder.KieScanner] (Timer-2) The following artifacts have been updated: {com.redhat.demo.retail:retail-webshop:1.0.0=com.redhat. demo.retail:retail-webshop:jar:1.0.1}

Demo Web Shop - Shopping with new shipping

Now let's see if the new rules are in effect without re-deploying our application, CLEAR the shopping cart and re-run scenario:
  • select Forge Laptop Sticker and click ADD TO CART
  • shipping is 22.99, cart total is 8.50 + 22.99 = 31.49

Demo Web Shop - What did we learn?

You've now seen a rules project deployed, the rules used from a front end application that you deployed successfully. You've tested the shipping price for the first tier and verified it works. Then you've updated the rules (shipping first tier) and deployed that new rule set, accessing it with the same front end application to verify the changes went into effect.

These changes demonstrate the value of externalizing rules or business logic from business applications, allowing for independent updates to rules and applications. Feel free to modify other rules, deploy them, see them picked up by the front end application, and verify their workings.

The End

This completes the workshop, thanks for your time and feedback is welcome!
Eric D. Schabell
Portfolio Architect Director
@ericschabell
http://schabell.org