Git Product home page Git Product logo

kogito-process-with-optaplanner-poc's Introduction

Kogito Travel Agency - base version

Description

During this workshop we will create a software system for a startup travel agency called Kogito Travel Agency. The first iteration of the system will consist of a set of services that are able to deal with travel requests and the booking of hotels and flights.

Installing and Running

Prerequisites

You will need:

  • Java 1.8.0+ installed
  • Environment variable JAVA_HOME set accordingly
  • Maven 3.5.4+ installed
  • Visual Studio Code

To install the Kogito extension type in your terminal :

$ curl -L http://bit.ly/get-kogito-ext | sh     

or download and install it manually

Optionally, for native compilation, you will also need:

  • GraalVM installed
  • Environment variable GRAALVM_HOME set accordingly
  • Note that GraalVM native image compilation typically requires other packages (glibc-devel, zlib-devel and gcc) to be installed too, please refer to GraalVM installation documentation for more details.

Compile and Run in Local Dev Mode

mvn clean package quarkus:dev    

NOTE: With dev mode of Quarkus you can take advantage of hot reload for business assets like processes, rules and decision tables and java code. No need to redeploy or restart your running application.

Compile and Run using Local Native Image

Note that this requires GRAALVM_HOME to point to a valid GraalVM installation

mvn clean package -Pnative

To run the generated native executable, generated in target/, execute

./target/kogito-travel-agency-{version}-runner

Activities to perform

  • Create project using Quarkus Maven plugin with following extensions
    • Kogito
    • OpenApi
  • Import project into Visual Studio Code IDE - requires BPMN modeller plugin installed
  • Create data model
    • Traveller
    • Hotel
    • Flight
    • Address
    • Trip
  • Create service classes
    • HotelBookingService
    • FlightBookingService
  • Create decision logic
    • Visa check
  • Create business logic
    • Public business process to deal with complete travel request
    • Private business process to deal with hotel booking
    • Private business process to deal with flight booking
  • Create a test case that makes use of processes and decisions
  • Create or import UI components
  • Add metrics support for processes and decisions
  • Create dashboard based on metrics

Data model

Kogito Travel Agency booking system will be based on following data model

Traveller

A person who requests a new travel

Trip

Place/Location where the traveller wants to go and dates

Flight

Flight that has been booked for the traveller to take him/her to the destination

Hotel

Place/Location where the traveller will stay during his/her travel

Address

Location that is associated with either traveller or hotel

Decision logic

The decision logic will be implemented as DRL rules. The logic will be responsible for verifying whether a given traveller requires a visa to enter a given country or not. The decision logic reason over the following data/facts

  • Destination that the traveller wants to go - country
  • Nationality of the traveller
  • Length of the stay

e.g.:

rule "Polish citizens do not require visa to US"
	when
		$trip: /trips[ $trip.country == "US" ]
		$traveller: /travellers[ $traveller.nationality == "Polish" ]
	then
		$trip.setVisaRequired( true );
end

Business logic

Business logic will be based on business processes

Public process that will be responsible for orchestrating complete travel request

Private process that will be responsible for booking a hotel.

Private process that will be responsible for booking a flight.

Services

There will be services implemented to carry on the hotel and flight booking. Implementation will be a CDI beans that will have hard coded logic to return a booked flight or hotel.

  • org.acme.travels.service.HotelBookingService
  • org.acme.travels.service.FlightBookingService

User interface

Kogito Travel Agency comes with basic UI that allows to

plan new trips

list currently opened travel requests

show details of selected travel request

show active tasks of selected travel request

cancel selected travel request

To start Kogito Travel Agency UI just point your browser to http://localhost:8080

REST API

Once the service is up and running, you can use the following examples to interact with the service.

POST /travels

Send travel that requires does not require visa

curl -H "Content-Type: application/json" -H "Accept: application/json" -X POST http://localhost:8080/travels -d @- << EOF
{
	"traveller" : {
		"firstName" : "John",
		"lastName" : "Doe",
		"email" : "[email protected]",
		"nationality" : "American",
		"address" : {
			"street" : "main street",
			"city" : "Boston",
			"zipCode" : "10005",
			"country" : "US"
		}
	},
	"trip" : {
		"city" : "New York",
		"country" : "US",
		"begin" : "2019-12-10T00:00:00.000+02:00",
		"end" : "2019-12-15T00:00:00.000+02:00"
	}
}
EOF

This will directly go to 'ConfirmTravel' user task.

Send travel request that requires does require visa

curl -H "Content-Type: application/json" -H "Accept: application/json" -X POST http://localhost:8080/travels -d @- << EOF
{
	"traveller" : {
		"firstName" : "Jan",
		"lastName" : "Kowalski",
		"email" : "[email protected]",
		"nationality" : "Polish",
		"address" : {
			"street" : "polna",
			"city" : "Krakow",
			"zipCode" : "32000",
			"country" : "Poland"
		}
	},
	"trip" : {
		"city" : "New York",
		"country" : "US",
		"begin" : "2019-12-10T00:00:00.000+02:00",
		"end" : "2019-12-15T00:00:00.000+02:00"
	}
}
EOF

This will stop at 'VisaApplication' user task.

GET /travels

Returns list of travel requests currently active:

curl -X GET http://localhost:8080/travels

As response an array of travels is returned.

GET /travels/{id}

Returns travel request with given id (if active):

curl -X GET http://localhost:8080/travels/{uuid}

As response a single travel request is returned if found, otherwise no content (204) is returned.

DELETE /travels/{id}

Cancels travel request with given id

curl -X DELETE http://localhost:8080/travels/{uuid}

GET /travels/{id}/tasks

Returns currently assigned user tasks for give travel request:

curl -X GET http://localhost:8080/travels/{uuid}/tasks

GET /travels/{id}/VisaApplication/{taskId}

Returns visa application task information:

curl -X GET http://localhost:8080/travels/{uuid}/VisaApplication/{task-uuid}

POST /travels/{id}/VisaApplication/{taskId}

Completes visa application task

curl -H "Content-Type: application/json" -H "Accept: application/json" -X POST http://localhost:8080/travels/{uuid}/VisaApplication/{task-uuid} -d '{}'

GET /travels/{id}/ConfirmTravel/{taskId}

Returns travel (hotel, flight) task information required for confirmation:

curl -X GET http://localhost:8080/travels/{uuid}/ConfirmTravel/{task-uuid}

POST /travels/{id}/ConfirmTravel/{taskId}

Completes confirms travel task - meaning confirms (and completes) the travel request

curl -H "Content-Type: application/json" -H "Accept: application/json" -X POST http://localhost:8080/travels/{uuid}/ConfirmTravel/{task-uuid} -d '{}'

kogito-process-with-optaplanner-poc's People

Contributors

ge0ffrey avatar mswiderski avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.