martinweiler commented on code in PR #2036: URL: https://github.com/apache/incubator-kie-kogito-examples/pull/2036#discussion_r1838689652
########## kogito-quarkus-examples/process-business-calendar-example/README.md: ########## @@ -0,0 +1,300 @@ +# Process Business Calendar Example + +This example demonstrates the impact of a business calendar on process execution within a Quarkus application. It showcases a business process involving credit card bill processing, which adapts to a business calendar defined in calendar.properties. This configuration modifies timer behaviors to respect working hours, holidays, and other schedule-based constraints. + +### Main Components + +**BPMN2-BusinessCalendarBankTransaction.bpmn2**: +Defines the workflow for processing credit card transactions. +Includes tasks such as processing the credit bill, verifying payment, handling timers, cancelling and bill settlement. + +**CreditCardService.java**: +Implements the logic for handling credit card payment processes. + +**calendar.properties**: +Configures business hours, holidays, and other calendar properties that affect scheduling and timer behavior. + +### BPMN Process Details + +The BPMN model (`BPMN2-BusinessCalendarBankTransaction.bpmn2`) defines a workflow that includes the following main elements: +<p align="center"><img width=75% height=50% src="docs/images/CreditCardModel.png"></p> + +### Start Event + +The initial trigger that starts the credit card bill processing workflow. + +### Process Credit Bill +* Process Credit Bill Properties (Top) + <p align="center"><img width=75% height=50% src="docs/images/ProcessCreditBillTop.png"></p> + +* Process Credit Card Bill Assignments + <p align="center"><img width=75% height=50% src="docs/images/ProcessCreditBillAssign.png"></p> + +### Verify Payment +A service task where the credit card details are validated, ensuring the payment is processed under valid terms. + +* Verify Payment + <p align="center"><img width=75% height=50% src="docs/images/VerifyPayment.png"></p> + +### Timer + +Attached to a human task to simulate waiting for manual confirmation or user action. This timer can be configured to react differently based on the presence of the business calendar. +<p align="center"><img width=75% height=50% src="docs/images/Timer.png"></p> + +### Cancel Payment +Executed if the timer expires without human action, leading to the cancellation of the payment process. + +* Cancel Payment (Top) + <p align="center"><img width=75% height=50% src="docs/images/CancelPaymentTop.png"></p> + +* Cancel Payment Assignments + <p align="center"><img width=75% height=50% src="docs/images/CancelPaymentAssign.png"></p> + +### Settle Payment + +The final step where the payment is settled successfully on manual verification. + +* Settle Payment (Top) + <p align="center"><img width=75% height=50% src="docs/images/SettlePaymentTop.png"></p> + +* Settle Payment Assignments +<p align="center"><img width=75% height=50% src="docs/images/SettlePaymentAssign.png"></p> + +## Build and run + +### Prerequisites + +You will need: +- Java 17+ installed +- Environment variable JAVA_HOME set accordingly +- Maven 3.9.6+ installed + +When using native image compilation, you will also need: +- GraalVM 19.3+ installed +- Environment variable GRAALVM_HOME set accordingly +- GraalVM native image needs as well native-image extension: https://www.graalvm.org/reference-manual/native-image/ +- 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 + +```sh +mvn clean compile quarkus:dev +``` + +NOTE: With dev mode of Quarkus you can take advantage of hot reload for business assets like processes, rules, decision tables and java code. No need to redeploy or restart your running application. + +### Package and Run in JVM mode + +```sh +mvn clean package +java -jar target/quarkus-app/quarkus-run.jar +``` + +or on windows + +```sh +mvn clean package +java -jar target\quarkus-app\quarkus-run.jar +``` + +### Package and Run using Local Native Image +Note that the following configuration property needs to be added to `application.properties` in order to enable automatic registration of `META-INF/services` entries required by the workflow engine: +``` +quarkus.native.auto-service-loader-registration=true +``` + +Note that this requires GRAALVM_HOME to point to a valid GraalVM installation + +```sh +mvn clean package -Pnative +``` + +To run the generated native executable, generated in `target/`, execute + +```sh +./target/process-usertasks-quarkus-runner +``` + +### OpenAPI (Swagger) documentation +[Specification at swagger.io](https://swagger.io/docs/specification/about/) + +You can take a look at the [OpenAPI definition](http://localhost:8080/openapi?format=json) - automatically generated and included in this service - to determine all available operations exposed by this service. For easy readability you can visualize the OpenAPI definition file using a UI tool like for example available [Swagger UI](https://editor.swagger.io). + +In addition, various clients to interact with this service can be easily generated using this OpenAPI definition. + +When running in either Quarkus Development or Native mode, we also leverage the [Quarkus OpenAPI extension](https://quarkus.io/guides/openapi-swaggerui#use-swagger-ui-for-development) that exposes [Swagger UI](http://localhost:8080/q/swagger-ui/) that you can use to look at available REST endpoints and send test requests. + +## curl command can be found below: + +### To start the process + +```sh +curl -X POST http://localhost:8080/BusinessCalendarCreditBill \ +-H "Content-Type: application/json" \ +-d '{"creditCardNumber": null, "creditCardDetails": {"cardNumber": "434353433", "status": "Bill Due"}}' + +``` + +### To retrieve instances + +```sh +curl -X GET http://localhost:8080/BusinessCalendarCreditBill \ +-H "Content-Type: application/json" \ +-H "Accept: application/json" + +``` +### To retrieve status of particular instance using id + +```sh +curl -X GET http://localhost:8080/BusinessCalendarCreditBill/{id} \ +-H "Content-Type: application/json" \ +-H "Accept: application/json" + +``` + +## Understanding timer behaviour with respect to working and non-working days without calendar.properties Review Comment: @Abhitocode as discussed, this whole section (until line 249) needs to be updated. If there is no calendar.properties file in the application, then no BusinessCalendarImpl instance will be created. All due date calculations are then based on time only. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
