Solar Village is the home work assignment for advanced process development with Red Hat JBoss BPM Suite 6.4 on top of JBoss EAP 7.0.0
This POC uses the gpte-bpms-advanced virtual machine from the advanced course. You can download a copy of the VM from:
- Direct download: https://drive.google.com/file/d/0B8mmXW6hJKdibi1nZkFtQlNycmc/view
- BitTorrent: https://github.com/gpe-mw-training/advanced-process-development-labs-etc/blob/master/etc/gpte-bpms-advanced-630.vdi.torrent
It is required to clone the remote maven repository in order to build and deploy the jars and wars that will serve the government permit services:
- Add electrical/structural permit requests
- Rescind electrical/structural permit requests
- Query the government permit requests status
- Create a folder to organize the project's git repository.
$ mkdir ~/bpms-lab/solarVillage
$ cd ~/bpms-lab/solarVillage
- Execute the git clone command:
$ git clone https://github.com/mvocale/solarVillage.git
The war and jar components that will serve the government permit SOAP web services are built during this step. We are using Maven, and as an standard practice, those components will be generated in their respective target
folders.
Using the git repository that we cloned in the previous step, execute the maven install command:
$ cd ~/bpms-lab/solarVillage/governmentPermitServices
$ mvn install -P war
Note: the war profile is configured to generate a war component for the service tier project.
The war and jar components that provide the SOAP web service finctionality are Spring-Boot
components that can be deployed to any java web server environment.
Copy the target resources from the Maven projects to JBoss Server:
$ cp ~/bpms-lab/solarVillage/governmentPermitServices/permitServiceTier/target/governmentPermitServices.war \
~/lab/bpms/standalone/deployments
Note: the POM for OrderPermit project includes the dependency instruction for governmentPermitServices parent project.
In this section we will deploy the Solar Village project kjar to our Kie Server.
Just to refresh our memory: The Kie Server is a Java web application that allow us to expose rules and business process to be executed remotely using REST and JMS interfaces. The difference between the Kie Server and the business-central is that Kie Server is focused in remote execution, while business-central offers a complete authoring evironment, including process execution features and a remote API.
The Kie Server is a web application that can be deployed in JBoss EAP, Wildfly, Tomcat or any other Java application server or web container. It works by accessing kjars from a Maven repository and exposing its rules and processes throught HTTP or JMS.
When a Kie Server uses the Business-Central as its Controller, it happens to be a Managed Kie Server.
- In some cases, deploying kjar projects to a Managed Kie Server, the process behavior is constrained by some overlapping properties and resources, hence we will undeploy the business_central from our JBoss EAP installation by executing the following command:
$ mv ~/lab/bpms/standalone/deployments/dashbuilder.war.deployed ~/lab/bpms/standalone/deployments/dashbuilder.war.undeploy
$ mv ~/lab/bpms/standalone/deployments/business-central.war.deployed ~/lab/bpms/standalone/deployments/business-central.war.undeploy
- Modify the startup parameters that register the business-central as the Kie Server controller by editing the file
~/lab/bpms/bin/standalone.conf
:
JAVA_OPTS="$JAVA_OPTS -Dorg.kie.server.id=kie-server-advanced-vm "
JAVA_OPTS="$JAVA_OPTS -Dorg.kie.server.location=http://localhost:8080/kie-server/services/rest/server "
# JAVA_OPTS="$JAVA_OPTS -Dorg.kie.server.controller=http://localhost:8080/business-central/rest/controller "
JAVA_OPTS="$JAVA_OPTS -Dorg.kie.server.controller.user=kieserver "
Note: We are commenting the line that specifies the kie server controller (-Dorg.kie.server.controller)
- Restart the JBoss EAP instance.
- Test the Kie Server availabillity by curl:
$ curl -u 'kieserver:kieserver1!' http://localhost:8080/kie-server/services/rest/server
Should return the main information about the Kie Server installation:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<response type="SUCCESS" msg="Kie Server info">
<kie-server-info>
<capabilities>KieServer</capabilities>
<capabilities>BRM</capabilities>
<capabilities>BPM-UI</capabilities>
<capabilities>BPM</capabilities>
<location>http://localhost:8080/kie-server/services/rest/server</location>
<messages>
<content>Server KieServerInfo{serverId='kie-server-advanced-vm', version='6.5.0.Final-redhat-2', location='http://localhost:8080/kie-server/services/rest/server'}started successfully at Tue Apr 10 11:40:44 EDT 2018</content>
<severity>INFO</severity>
<timestamp>2018-04-10T11:40:44.121-04:00</timestamp>
</messages>
<name>kie-server-advanced-vm</name>
<id>kie-server-advanced-vm</id>
<version>6.5.0.Final-redhat-2</version>
</kie-server-info>
</response>
To create the container we use the REST API by sending a PUT HTTP request to the endpoint http://localhost:8080/kie-server/services/rest/server/containers/order_permit, where order_permit
is the name and the ID of the container. This request uses authentication and we must send the kjar artifact maven information (GAV).
- Execute the curl PUT request command:
$ curl -X PUT -H "Accept:application/json" -H "Content-Type:application/json" --user jboss:bpms \
-d '{"release-id":{"group-id":"org.solarVillage","artifact-id":"OrderPermit","version":"1.0"}}' \
"http://localhost:8080/kie-server/services/rest/server/containers/order_permit"
- You should receive a response like the following:
{
"type" : "SUCCESS",
"msg" : "Container order_permit successfully deployed with module org.solarVillage:OrderPermit:1.0",
"result" : {
"kie-container" : {
"status" : "STARTED",
"messages" : [ ],
"container-id" : "order_permit",
"release-id" : {
"version" : "8.3",
"group-id" : "org.solarVillage",
"artifact-id" : "OrderPermit"
},
"resolved-release-id" : {
"version" : "8.3",
"group-id" : "org.solarVillage",
"artifact-id" : "OrderPermit"
},
"config-items" : [ ]
}
}
}
- Start a RESIDENTIAL permit request:
$ curl -X POST -H "Accept: application/json" -H "Content-Type: application/json" --user jboss:bpms \
-d '{"address":"123 main street", "beneficiary":"Mauro Vocale", \
"buildingDescription":"my new big house", "electricalContractNumber":"32019283749"}' \
http://localhost:8080/kie-server/services/rest/server/containers/order_permit/processes/residential-permit-process/instances
- watch the government processes pass through the log and finally state the approval or denial of the permits.
- Start a HOME OWNER ASSOCIATION permit:
$ curl -X POST -H "Accept: application/json" -H "Content-Type: application/json" --user jboss:bpms \
-d '{"address":"123 main street", "beneficiary":"Mauro Vocale", \
"buildingDescription":"my big house", "electricalContract":"32019283749", \
"associationMeetingDate":"10/04/2018"}' \
http://localhost:8080/kie-server/services/rest/server/containers/order_permit/processes/hoa_permit_process/instances
Use a date 8 days or more in the future so the task can be assigned to the sales group, otherwise it will be assigned to executives automatically.
- use sales or executives roles to claim tasks for Home owner association approval.
- After Home owner association approval, watch the government permits pass through the log.
-
Claim a Home owner association approval task.
-
Add a sales user by executing the following command:
```
$ ~/lab/bpms/bin/add-user.sh -u sales_user -p secret -g sales -a -s -sc ~/lab/bpms/standalone/configuration
```
- Add an executive user:
```
$ ~/lab/bpms/bin/add-user.sh -u executive_user -p secret -g executives -a -s -sc ~/lab/bpms/standalone/configuration
```
- List the available tasks to be claimed by the sales group:
```
$ curl -X GET -H "Accept: application/json" --user jboss:bpms "http://localhost:8080/kie-server/services/rest/server/queries/tasks/instances/pot-owners?groups=sales"
```
- Claim a task:
```
$ curl -X PUT -H "Accept: application/json" --user sales_user:secret "http://localhost:8080/kie-server/services/rest/server/containers/order_permit/tasks/1/states/claimed"
```
> **NOTE**: This can only be done when authenticating as a user who is a potential owner of the task. If the user is not a potential owner, an exception message is returned.
- List claimed tasks (owned by a user):
```
$ curl -X GET -H "Accept: application/json" --user sales_user:secret "http://localhost:8080/kie-server/services/rest/server/queries/tasks/instances/owners"
```
- Approve the Home owner association permit.
Complete the claimed task with approval result:
$ curl -X PUT -H "Accept: application/json" --user sales_user:secret "http://localhost:8080/kie-server/services/rest/server/containers/order_permit/tasks/1/states/completed"