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-tools.git
The following commit(s) were added to refs/heads/main by this push:
new 2a6cac280d7 No-Issue: Enhancing Business calendar flexibility (#2952)
2a6cac280d7 is described below
commit 2a6cac280d737012d09c21c26c79623efa490b87
Author: Abhiram Gundala <[email protected]>
AuthorDate: Tue Mar 4 10:51:43 2025 -0500
No-Issue: Enhancing Business calendar flexibility (#2952)
Co-authored-by: Jozef Marko <[email protected]>
---
examples/process-business-calendar/README.md | 71 +++++++++++++++++++++
.../docs/images/CustomCalendarClass.png | Bin 0 -> 100676 bytes
2 files changed, 71 insertions(+)
diff --git a/examples/process-business-calendar/README.md
b/examples/process-business-calendar/README.md
index b9672333ae3..e6dbcb9706a 100644
--- a/examples/process-business-calendar/README.md
+++ b/examples/process-business-calendar/README.md
@@ -331,6 +331,77 @@ curl -X GET
http://localhost:8080/BusinessCalendarCreditBill \
---
+## 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.custom.CustomCalendar`
+
+**Steps**
+
+1. **Navigate to**:
_examples/process-business-calendar/src/main/java/org/kie/kogito/calendar/custom
(create the org/kie/kogito/calendar/custom directory if it does not exist)_
+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. Remove the `calendar.properties` file within `src/main/resources` to allow
the `CustomCalendar` class to be registered instead of the default
`BusinessCalendarImpl` provided out of the box.
+
+**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
+ // Note:The returned long value is in milliseconds. Duration can be set
at least 1000 ms or longer to prevent immediate execution.
+ return 1000;
+ }
+
+ @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>
+
+---
+
Apache KIE (incubating) is an effort undergoing incubation at The Apache
Software
Foundation (ASF), sponsored by the name of Apache Incubator. Incubation is
required of all newly accepted projects until a further review indicates that
diff --git
a/examples/process-business-calendar/docs/images/CustomCalendarClass.png
b/examples/process-business-calendar/docs/images/CustomCalendarClass.png
new file mode 100644
index 00000000000..b202922cb3f
Binary files /dev/null and
b/examples/process-business-calendar/docs/images/CustomCalendarClass.png differ
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]