This is an automated email from the ASF dual-hosted git repository.
pefernan pushed a commit to branch main
in repository
https://gitbox.apache.org/repos/asf/incubator-kie-kogito-examples.git
The following commit(s) were added to refs/heads/main by this push:
new 888f22d04 [Incubator-kie-issues-1790] Business Calendar flexibility
readme update (#2064)
888f22d04 is described below
commit 888f22d041b189c92f9aebb397763d8d54255edf
Author: Abhiram Gundala <[email protected]>
AuthorDate: Thu Feb 27 15:41:46 2025 -0500
[Incubator-kie-issues-1790] Business Calendar flexibility readme update
(#2064)
* custom_calendar
* custom_calendar
* custom_calendar
* readme_update
* class_name_update
---
.../README.md | 67 +++++++++++++++++++
.../docs/images/CustomCalendarClass.png | Bin 0 -> 127704 bytes
.../README.md | 73 +++++++++++++++++++++
.../docs/images/CustomCalendarClassSpring.png | Bin 0 -> 90321 bytes
4 files changed, 140 insertions(+)
diff --git
a/kogito-quarkus-examples/process-business-calendar-quarkus-example/README.md
b/kogito-quarkus-examples/process-business-calendar-quarkus-example/README.md
index b88068dcb..5f0ab76b8 100644
---
a/kogito-quarkus-examples/process-business-calendar-quarkus-example/README.md
+++
b/kogito-quarkus-examples/process-business-calendar-quarkus-example/README.md
@@ -284,3 +284,70 @@ curl -X GET
http://localhost:8080/BusinessCalendarCreditBill \
* On next business day, timer will resume at the beginning of the next working
hour/day, after the non-working hour/holiday has ended. The timer is set to
fire after one second of active business time.
+
+## Custom Business Calendar Flexibility
+
+**Why Create a Custom Business Calendar?**
+- Custom schedules that differ from the default behavior.
+- Modify, delay, or override time calculations.
+- Implement custom business logic for when tasks should be triggered.
+
+This guide explains how to implement a custom business calendar allowing full
flexibility.
+
+---
+
+### Creating a Custom Business Calendar
+
+- By default, calendar.properties is used to configure default business
calendar.
+- If a custom business calendar has to be implemented, calendar.properties
should NOT exist. Instead, add the following property to
application.properties:
```kogito.processes.businessCalendar=org.kie.kogito.calendar.CustomCalendar```
+
+**Steps**
+1. **Navigate to**:
*kogito-quarkus-examples/process-business-calendar-quarkus-example/src/main/java/org/kie/kogito/calendar*
+2. **Create a new custom business calendar class** (e.g., CustomCalendar.java).
+3. Ensure it implements the BusinessCalendar interface.The implementation
should be a concrete class(not an interface or abstract class).
+4. Set the property
```kogito.processes.businessCalendar=org.kie.kogito.calendar.custom.CustomCalendar```
in application.properties to the fully qualified class name of the custom
business calendar.
+5. To test the created custom business calendar with property set in
application.properties, calendar.properties should not exist.
+
+
+
+**Implement your custom business logic**
+- For demonstration, an example is provided below. However, you are free to
define your own logic.
+
+```java
+package org.kie.kogito.calendar.custom;
+
+import java.util.*;
+import org.kie.kogito.calendar.BusinessCalendar;
+
+/**
+ * Custom Business Calendar Example.
+ * Modify this class to implement your own scheduling logic.
+ */
+public class CustomCalendar implements BusinessCalendar {
+
+ @Override
+ public long calculateBusinessTimeAsDuration(String timeExpression) {
+ // Implement custom logic to calculate business time duration
+ return 0;
+ }
+
+ @Override
+ public Date calculateBusinessTimeAsDate(String timeExpression) {
+ // Implement custom logic to return the scheduled date
+ return new Date();
+ }
+}
+```
+---
+
+### Testing custom calendar implementation
+
+To verify that your custom implementation works:
+1. Run:
+
+```mvn clean compile quarkus:dev```
+
+- Verify in generated sources within target folder if it reflects the expected
change
+<p align="center"><img width=75% height=50%
src="docs/images/CustomCalendarClass.png"></p>
+
+
diff --git
a/kogito-quarkus-examples/process-business-calendar-quarkus-example/docs/images/CustomCalendarClass.png
b/kogito-quarkus-examples/process-business-calendar-quarkus-example/docs/images/CustomCalendarClass.png
new file mode 100644
index 000000000..fe5ac3068
Binary files /dev/null and
b/kogito-quarkus-examples/process-business-calendar-quarkus-example/docs/images/CustomCalendarClass.png
differ
diff --git
a/kogito-springboot-examples/process-business-calendar-springboot-example/README.md
b/kogito-springboot-examples/process-business-calendar-springboot-example/README.md
index 916481386..37bcc6f06 100644
---
a/kogito-springboot-examples/process-business-calendar-springboot-example/README.md
+++
b/kogito-springboot-examples/process-business-calendar-springboot-example/README.md
@@ -276,3 +276,76 @@ curl -X GET
http://localhost:8080/BusinessCalendarCreditBill \
* On next business day, timer will resume at the beginning of the next working
hour/day, after the non-working hour/holiday has ended. The timer is set to
fire after one second of active business time.
+## Custom Business Calendar Flexibility
+
+**Why Create a Custom Business Calendar?**
+- Custom schedules that differ from the default behavior.
+- Modify, delay, or override time calculations.
+- Implement custom business logic for when tasks should be triggered.
+
+This guide explains how to implement a custom business calendar allowing full
flexibility.
+
+---
+
+### Creating a Custom Business Calendar
+
+- By default, calendar.properties is used to configure default business
calendar.
+- If a custom business calendar has to be implemented, calendar.properties
should NOT exist. Instead, add the following property to
application.properties:
```kogito.processes.businessCalendar=org.kie.kogito.calendar.CustomCalendar```
+
+**Steps**
+1. **Navigate to**:
*kogito-quarkus-examples/process-business-calendar-quarkus-example/src/main/java/org/kie/kogito/calendar*
+2. **Create a new custom business calendar class** (e.g., CustomCalendar.java).
+3. Ensure it implements the BusinessCalendar interface.The implementation
should be a concrete class(not an interface or abstract class).
+4. Set the property
```kogito.processes.businessCalendar=org.kie.kogito.calendar.custom.CustomCalendar```
in application.properties to the fully qualified class name of the custom
business calendar.
+5. To test the created custom business calendar with property set in
application.properties, calendar.properties should not exist.
+
+
+
+**Implement your custom business logic**
+- For demonstration, an example is provided below. However, you are free to
define your own logic.
+
+```java
+package org.kie.kogito.calendar.custom;
+
+import java.util.*;
+import org.kie.kogito.calendar.BusinessCalendar;
+
+/**
+ * Custom Business Calendar Example.
+ * Modify this class to implement your own scheduling logic.
+ */
+public class CustomCalendar implements BusinessCalendar {
+
+ @Override
+ public long calculateBusinessTimeAsDuration(String timeExpression) {
+ // Implement custom logic to calculate business time duration
+ return 0;
+ }
+
+ @Override
+ public Date calculateBusinessTimeAsDate(String timeExpression) {
+ // Implement custom logic to return the scheduled date
+ return new Date();
+ }
+}
+```
+---
+
+### Testing custom calendar implementation
+
+To verify that your custom implementation works:
+1. Run:
+
+```mvn clean compile spring-boot:run```
+
+or
+
+```mvn clean package```
+
+```java -jar target/process-business-rules-springboot.jar```
+
+
+- Verify in generated sources within target folder if it reflects the expected
change
+<p align="center"><img width=75% height=50%
src="docs/images/CustomCalendarClassSpring.png"></p>
+
+
diff --git
a/kogito-springboot-examples/process-business-calendar-springboot-example/docs/images/CustomCalendarClassSpring.png
b/kogito-springboot-examples/process-business-calendar-springboot-example/docs/images/CustomCalendarClassSpring.png
new file mode 100644
index 000000000..c5b58af5e
Binary files /dev/null and
b/kogito-springboot-examples/process-business-calendar-springboot-example/docs/images/CustomCalendarClassSpring.png
differ
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]