diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/timer/BusinessCalendar.java b/api/kogito-api/src/main/java/org/kie/kogito/calendar/BusinessCalendar.java
old mode 100755
new mode 100644
similarity index 97%
rename from jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/timer/BusinessCalendar.java
rename to api/kogito-api/src/main/java/org/kie/kogito/calendar/BusinessCalendar.java
index 544fbcb6ef3..6e15a6cc0e6
--- a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/timer/BusinessCalendar.java
+++ b/api/kogito-api/src/main/java/org/kie/kogito/calendar/BusinessCalendar.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.jbpm.process.core.timer;
+package org.kie.kogito.calendar;
import java.util.Date;
diff --git a/api/kogito-api/src/main/java/org/kie/kogito/process/ProcessConfig.java b/api/kogito-api/src/main/java/org/kie/kogito/process/ProcessConfig.java
index 40549bbcd90..b365c3d7647 100644
--- a/api/kogito-api/src/main/java/org/kie/kogito/process/ProcessConfig.java
+++ b/api/kogito-api/src/main/java/org/kie/kogito/process/ProcessConfig.java
@@ -20,6 +20,7 @@
import org.kie.kogito.KogitoConfig;
import org.kie.kogito.auth.IdentityProvider;
+import org.kie.kogito.calendar.BusinessCalendar;
import org.kie.kogito.jobs.JobsService;
import org.kie.kogito.signal.SignalManagerHub;
import org.kie.kogito.uow.UnitOfWorkManager;
@@ -38,4 +39,6 @@ public interface ProcessConfig extends KogitoConfig {
ProcessVersionResolver versionResolver();
IdentityProvider identityProvider();
+
+ BusinessCalendar getBusinessCalendar();
}
diff --git a/jbpm/jbpm-flow/pom.xml b/jbpm/jbpm-flow/pom.xml
index d0fc15edb26..6afcfa766ac 100755
--- a/jbpm/jbpm-flow/pom.xml
+++ b/jbpm/jbpm-flow/pom.xml
@@ -20,146 +20,146 @@
-->
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- 4.0.0
-
- org.kie.kogito
- jbpm
- 999-SNAPSHOT
-
+ 4.0.0
+
+ org.kie.kogito
+ jbpm
+ 999-SNAPSHOT
+
- jbpm-flow
- jar
+ jbpm-flow
+ jar
- Kogito :: jBPM :: Flow
- jBPM Flow
+ Kogito :: jBPM :: Flow
+ jBPM Flow
-
- org.kie.kogito.jbpm.flow.core
-
+
+ org.kie.kogito.jbpm.flow.core
+
-
-
-
- org.kie.kogito
- kogito-kie-bom
- ${project.version}
- pom
- import
-
-
-
+
+
+
+ org.kie.kogito
+ kogito-kie-bom
+ ${project.version}
+ pom
+ import
+
+
+
-
-
- org.kie.kogito
- kogito-api
-
-
- org.kie.kogito
- kogito-dmn
- true
-
-
- org.kie.kogito
- kogito-drools
-
-
- org.kie.kogito
- kogito-events-api
-
-
- org.kie.kogito
- kogito-services
-
-
- org.kie.kogito
- process-workitems
-
-
- org.drools
- drools-mvel
-
-
- org.drools
- drools-wiring-dynamic
-
-
- org.drools
- drools-core
-
-
- org.drools
- drools-compiler
-
-
- org.kie
- kie-internal
-
-
-
-
- org.slf4j
- slf4j-api
-
+
+
+ org.kie.kogito
+ kogito-api
+
+
+ org.kie.kogito
+ kogito-dmn
+ true
+
+
+ org.kie.kogito
+ kogito-drools
+
+
+ org.kie.kogito
+ kogito-events-api
+
+
+ org.kie.kogito
+ kogito-services
+
+
+ org.kie.kogito
+ process-workitems
+
+
+ org.drools
+ drools-mvel
+
+
+ org.drools
+ drools-wiring-dynamic
+
+
+ org.drools
+ drools-core
+
+
+ org.drools
+ drools-compiler
+
+
+ org.kie
+ kie-internal
+
+
+
+
+ org.slf4j
+ slf4j-api
+
-
- jakarta.xml.bind
- jakarta.xml.bind-api
- provided
-
+
+ jakarta.xml.bind
+ jakarta.xml.bind-api
+ provided
+
-
- com.fasterxml.jackson.datatype
- jackson-datatype-jsr310
-
+
+ com.fasterxml.jackson.datatype
+ jackson-datatype-jsr310
+
-
-
- org.drools
- drools-kiesession
- test
-
-
- org.drools
- drools-ruleunits-impl
- test
-
-
- org.junit.jupiter
- junit-jupiter-engine
- test
-
-
- org.junit.jupiter
- junit-jupiter-params
- test
-
-
- org.mockito
- mockito-core
- test
-
-
- ch.qos.logback
- logback-classic
- test
-
-
- org.assertj
- assertj-core
- test
-
-
+
+
+ org.drools
+ drools-kiesession
+ test
+
+
+ org.drools
+ drools-ruleunits-impl
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-params
+ test
+
+
+ org.mockito
+ mockito-core
+ test
+
+
+ ch.qos.logback
+ logback-classic
+ test
+
+
+ org.assertj
+ assertj-core
+ test
+
+
-
-
- sonarcloud-analysis
-
- **/JBPMMessages.java
-
-
-
+
+
+ sonarcloud-analysis
+
+ **/JBPMMessages.java
+
+
+
diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/timer/BusinessCalendarImpl.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/timer/BusinessCalendarImpl.java
index 29017a62307..04935767197 100755
--- a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/timer/BusinessCalendarImpl.java
+++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/core/timer/BusinessCalendarImpl.java
@@ -35,6 +35,7 @@
import java.util.regex.Matcher;
import org.jbpm.util.PatternConstants;
+import org.kie.kogito.calendar.BusinessCalendar;
import org.kie.kogito.timer.SessionClock;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/DummyKnowledgeRuntime.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/DummyKnowledgeRuntime.java
index 2f7da3c086c..fa991edd1da 100644
--- a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/DummyKnowledgeRuntime.java
+++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/DummyKnowledgeRuntime.java
@@ -21,6 +21,7 @@
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
+import java.util.Objects;
import org.drools.core.common.EndOperationListener;
import org.drools.core.common.InternalAgenda;
@@ -53,11 +54,13 @@
import org.kie.api.runtime.rule.ViewChangedEventListener;
import org.kie.api.time.SessionClock;
import org.kie.kogito.Application;
+import org.kie.kogito.calendar.BusinessCalendar;
import org.kie.kogito.internal.process.event.KogitoProcessEventSupport;
import org.kie.kogito.internal.process.runtime.KogitoProcessInstance;
import org.kie.kogito.internal.process.runtime.KogitoProcessRuntime;
import org.kie.kogito.internal.process.workitem.KogitoWorkItemManager;
import org.kie.kogito.jobs.JobsService;
+import org.kie.kogito.process.ProcessConfig;
/**
* A severely limited implementation of the WorkingMemory interface.
@@ -72,6 +75,10 @@ class DummyKnowledgeRuntime implements InternalKnowledgeRuntime, KogitoProcessRu
this.processRuntime = processRuntime;
this.environment = new EnvironmentImpl();
// register codegen-based node instances factories
+ BusinessCalendar calendar = processRuntime.getApplication().config().get(ProcessConfig.class).getBusinessCalendar();
+ if (Objects.nonNull(calendar)) {
+ environment.set("jbpm.business.calendar", calendar);
+ }
environment.set("NodeInstanceFactoryRegistry", new CodegenNodeInstanceFactoryRegistry());
}
diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/LightProcessRuntime.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/LightProcessRuntime.java
index df1b7c5ba69..6d1bde116f8 100755
--- a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/LightProcessRuntime.java
+++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/LightProcessRuntime.java
@@ -31,7 +31,6 @@
import org.drools.core.phreak.PropagationEntry;
import org.jbpm.process.core.event.EventFilter;
import org.jbpm.process.core.event.EventTypeFilter;
-import org.jbpm.process.core.timer.BusinessCalendar;
import org.jbpm.process.core.timer.DateTimeUtils;
import org.jbpm.process.core.timer.Timer;
import org.jbpm.ruleflow.core.RuleFlowProcess;
@@ -52,6 +51,7 @@
import org.kie.internal.process.CorrelationKey;
import org.kie.internal.runtime.StatefulKnowledgeSession;
import org.kie.kogito.Application;
+import org.kie.kogito.calendar.BusinessCalendar;
import org.kie.kogito.internal.process.runtime.KogitoProcessInstance;
import org.kie.kogito.internal.process.workitem.KogitoWorkItemManager;
import org.kie.kogito.jobs.DurationExpirationTime;
diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/ProcessRuntimeImpl.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/ProcessRuntimeImpl.java
index 3eaec2fce36..8636a24c3fa 100755
--- a/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/ProcessRuntimeImpl.java
+++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/process/instance/ProcessRuntimeImpl.java
@@ -35,7 +35,6 @@
import org.drools.core.time.impl.ThreadSafeTrackableTimeJobFactoryManager;
import org.jbpm.process.core.event.EventFilter;
import org.jbpm.process.core.event.EventTypeFilter;
-import org.jbpm.process.core.timer.BusinessCalendar;
import org.jbpm.process.core.timer.DateTimeUtils;
import org.jbpm.process.core.timer.Timer;
import org.jbpm.process.instance.event.DefaultSignalManagerFactory;
@@ -64,6 +63,7 @@
import org.kie.internal.process.CorrelationKey;
import org.kie.internal.runtime.StatefulKnowledgeSession;
import org.kie.kogito.Application;
+import org.kie.kogito.calendar.BusinessCalendar;
import org.kie.kogito.internal.process.runtime.KogitoProcessInstance;
import org.kie.kogito.internal.process.runtime.KogitoProcessRuntime;
import org.kie.kogito.jobs.DurationExpirationTime;
diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/impl/WorkflowProcessInstanceImpl.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/impl/WorkflowProcessInstanceImpl.java
index 7ae6edf3fb1..bcc2c192590 100755
--- a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/impl/WorkflowProcessInstanceImpl.java
+++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/impl/WorkflowProcessInstanceImpl.java
@@ -44,7 +44,6 @@
import org.jbpm.process.core.ContextResolver;
import org.jbpm.process.core.context.variable.Variable;
import org.jbpm.process.core.context.variable.VariableScope;
-import org.jbpm.process.core.timer.BusinessCalendar;
import org.jbpm.process.core.timer.DateTimeUtils;
import org.jbpm.process.core.timer.Timer;
import org.jbpm.process.instance.ContextInstance;
@@ -80,6 +79,7 @@
import org.kie.api.definition.process.WorkflowElementIdentifier;
import org.kie.api.runtime.rule.AgendaFilter;
import org.kie.internal.process.CorrelationKey;
+import org.kie.kogito.calendar.BusinessCalendar;
import org.kie.kogito.internal.process.event.KogitoEventListener;
import org.kie.kogito.internal.process.runtime.KogitoNodeInstance;
import org.kie.kogito.internal.process.runtime.KogitoNodeInstanceContainer;
diff --git a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/node/StateBasedNodeInstance.java b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/node/StateBasedNodeInstance.java
index 554da5acc51..8c5e8d04a67 100755
--- a/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/node/StateBasedNodeInstance.java
+++ b/jbpm/jbpm-flow/src/main/java/org/jbpm/workflow/instance/node/StateBasedNodeInstance.java
@@ -29,7 +29,6 @@
import org.drools.core.common.InternalAgenda;
import org.drools.core.common.ReteEvaluator;
import org.drools.core.rule.consequence.InternalMatch;
-import org.jbpm.process.core.timer.BusinessCalendar;
import org.jbpm.process.core.timer.DateTimeUtils;
import org.jbpm.process.core.timer.Timer;
import org.jbpm.process.instance.InternalProcessRuntime;
@@ -44,6 +43,7 @@
import org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl;
import org.kie.api.event.rule.MatchCreatedEvent;
import org.kie.api.runtime.KieRuntime;
+import org.kie.kogito.calendar.BusinessCalendar;
import org.kie.kogito.internal.process.event.KogitoEventListener;
import org.kie.kogito.internal.process.runtime.KogitoNodeInstance;
import org.kie.kogito.internal.process.runtime.KogitoProcessContext;
diff --git a/jbpm/jbpm-flow/src/main/java/org/kie/kogito/process/impl/AbstractProcessConfig.java b/jbpm/jbpm-flow/src/main/java/org/kie/kogito/process/impl/AbstractProcessConfig.java
index 25d278f628c..ac13e659424 100644
--- a/jbpm/jbpm-flow/src/main/java/org/kie/kogito/process/impl/AbstractProcessConfig.java
+++ b/jbpm/jbpm-flow/src/main/java/org/kie/kogito/process/impl/AbstractProcessConfig.java
@@ -28,6 +28,7 @@
import org.kie.api.event.process.ProcessEventListener;
import org.kie.kogito.Addons;
import org.kie.kogito.auth.IdentityProvider;
+import org.kie.kogito.calendar.BusinessCalendar;
import org.kie.kogito.event.EventPublisher;
import org.kie.kogito.jobs.JobsService;
import org.kie.kogito.process.ProcessConfig;
@@ -51,6 +52,7 @@ public abstract class AbstractProcessConfig implements ProcessConfig {
private final JobsService jobsService;
private final ProcessVersionResolver versionResolver;
private final IdentityProvider identityProvider;
+ private final BusinessCalendar businessCalendar;
protected AbstractProcessConfig(
Iterable workItemHandlerConfig,
@@ -62,7 +64,8 @@ protected AbstractProcessConfig(
String kogitoService,
Iterable unitOfWorkListeners,
Iterable versionResolver,
- Iterable identityProvider) {
+ Iterable identityProvider,
+ Iterable businessCalendar) {
this.workItemHandlerConfig = mergeWorkItemHandler(workItemHandlerConfig, DefaultWorkItemHandlerConfig::new);
this.processEventListenerConfig = merge(processEventListenerConfigs, processEventListeners);
@@ -72,6 +75,7 @@ protected AbstractProcessConfig(
this.jobsService = orDefault(jobsService, () -> null);
this.versionResolver = orDefault(versionResolver, () -> null);
this.identityProvider = orDefault(identityProvider, NoOpIdentityProvider::new);
+ this.businessCalendar = orDefault(businessCalendar, () -> null);
eventPublishers.forEach(publisher -> unitOfWorkManager().eventManager().addPublisher(publisher));
unitOfWorkListeners.forEach(listener -> unitOfWorkManager().register(listener));
@@ -124,6 +128,11 @@ public IdentityProvider identityProvider() {
return identityProvider;
}
+ @Override
+ public BusinessCalendar getBusinessCalendar() {
+ return this.businessCalendar;
+ }
+
public org.kie.kogito.Addons addons() {
return Addons.EMTPY;
}
diff --git a/jbpm/jbpm-flow/src/main/java/org/kie/kogito/process/impl/StaticProcessConfig.java b/jbpm/jbpm-flow/src/main/java/org/kie/kogito/process/impl/StaticProcessConfig.java
index c540407c4f9..343f232a042 100644
--- a/jbpm/jbpm-flow/src/main/java/org/kie/kogito/process/impl/StaticProcessConfig.java
+++ b/jbpm/jbpm-flow/src/main/java/org/kie/kogito/process/impl/StaticProcessConfig.java
@@ -19,6 +19,7 @@
package org.kie.kogito.process.impl;
import org.kie.kogito.auth.IdentityProvider;
+import org.kie.kogito.calendar.BusinessCalendar;
import org.kie.kogito.jobs.JobsService;
import org.kie.kogito.process.ProcessConfig;
import org.kie.kogito.process.ProcessEventListenerConfig;
@@ -41,12 +42,13 @@ public class StaticProcessConfig implements ProcessConfig {
private final ProcessVersionResolver versionResolver;
private final IdentityProvider identityProvider;
+ private final BusinessCalendar businessCalendar;
public StaticProcessConfig(
WorkItemHandlerConfig workItemHandlerConfig,
ProcessEventListenerConfig processEventListenerConfig,
UnitOfWorkManager unitOfWorkManager) {
- this(workItemHandlerConfig, processEventListenerConfig, unitOfWorkManager, null, null, new NoOpIdentityProvider());
+ this(workItemHandlerConfig, processEventListenerConfig, unitOfWorkManager, null, null, new NoOpIdentityProvider(), null);
}
public StaticProcessConfig(
@@ -55,7 +57,8 @@ public StaticProcessConfig(
UnitOfWorkManager unitOfWorkManager,
JobsService jobsService,
ProcessVersionResolver versionResolver,
- IdentityProvider identityProvider) {
+ IdentityProvider identityProvider,
+ BusinessCalendar calendar) {
this.unitOfWorkManager = unitOfWorkManager;
this.workItemHandlerConfig = workItemHandlerConfig;
this.processEventListenerConfig = processEventListenerConfig;
@@ -63,6 +66,7 @@ public StaticProcessConfig(
this.jobsService = jobsService;
this.versionResolver = versionResolver;
this.identityProvider = identityProvider;
+ this.businessCalendar = calendar;
}
public StaticProcessConfig() {
@@ -71,7 +75,8 @@ public StaticProcessConfig() {
new DefaultUnitOfWorkManager(new CollectingUnitOfWorkFactory()),
null,
null,
- new NoOpIdentityProvider());
+ new NoOpIdentityProvider(),
+ null);
}
@Override
@@ -108,4 +113,9 @@ public ProcessVersionResolver versionResolver() {
public IdentityProvider identityProvider() {
return identityProvider;
}
+
+ @Override
+ public BusinessCalendar getBusinessCalendar() {
+ return this.businessCalendar;
+ }
}
diff --git a/jbpm/jbpm-flow/src/main/resources/calendar.properties b/jbpm/jbpm-flow/src/main/resources/calendar.properties
new file mode 100644
index 00000000000..3d722189ddf
--- /dev/null
+++ b/jbpm/jbpm-flow/src/main/resources/calendar.properties
@@ -0,0 +1,5 @@
+business.end.hour=17
+business.holidays=2024-06-24, 2024-08-01:2024-08-30
+business.holiday.date.format=yyyy-MM-dd
+business.weekend.days=5,6,7,1
+#business.cal.timezone= system default timezone..
diff --git a/jbpm/jbpm-flow/src/test/java/org/jbpm/ruleflow/instance/RuleFlowProcessInstanceTest.java b/jbpm/jbpm-flow/src/test/java/org/jbpm/ruleflow/instance/RuleFlowProcessInstanceTest.java
index d0b8ced9e98..68d2e177e4d 100755
--- a/jbpm/jbpm-flow/src/test/java/org/jbpm/ruleflow/instance/RuleFlowProcessInstanceTest.java
+++ b/jbpm/jbpm-flow/src/test/java/org/jbpm/ruleflow/instance/RuleFlowProcessInstanceTest.java
@@ -27,7 +27,8 @@
import org.kie.kogito.internal.process.runtime.KogitoProcessRuntime;
import org.slf4j.LoggerFactory;
-import static org.assertj.core.api.Assertions.*;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
public class RuleFlowProcessInstanceTest extends AbstractBaseTest {
diff --git a/jbpm/jbpm-flow/src/test/resources/logback-test.xml b/jbpm/jbpm-flow/src/test/resources/logback-test.xml
index e2693493896..3f8f1307ffc 100755
--- a/jbpm/jbpm-flow/src/test/resources/logback-test.xml
+++ b/jbpm/jbpm-flow/src/test/resources/logback-test.xml
@@ -20,22 +20,22 @@
-
-
-
-
- %d [%t|%C] %-5p %m%n
-
-
+
+
+
+
+ %d [%t|%C] %-5p %m%n
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/kogito-codegen-modules/kogito-codegen-processes/src/main/java/org/kie/kogito/codegen/process/ProcessCodegen.java b/kogito-codegen-modules/kogito-codegen-processes/src/main/java/org/kie/kogito/codegen/process/ProcessCodegen.java
index 6f5ba05f7a5..a050d5b8f6a 100644
--- a/kogito-codegen-modules/kogito-codegen-processes/src/main/java/org/kie/kogito/codegen/process/ProcessCodegen.java
+++ b/kogito-codegen-modules/kogito-codegen-processes/src/main/java/org/kie/kogito/codegen/process/ProcessCodegen.java
@@ -28,6 +28,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Stream;
@@ -99,7 +100,9 @@ public class ProcessCodegen extends AbstractGenerator {
private static final String GLOBAL_OPERATIONAL_DASHBOARD_TEMPLATE = "/grafana-dashboard-template/processes/global-operational-dashboard-template.json";
private static final String PROCESS_OPERATIONAL_DASHBOARD_TEMPLATE = "/grafana-dashboard-template/processes/process-operational-dashboard-template.json";
-
+ private static final String BUSINESS_CALENDAR_PRODUCER_TEMPLATE = "BusinessCalendarProducer";
+ private static final String BUSINESS_CALENDAR_RESOURCE_KEY = "businessCalendar";
+ private static final String BUSINESS_CALENDAR_PATH = "calendar.properties";
static {
ProcessValidatorRegistry.getInstance().registerAdditonalValidator(JavaRuleFlowProcessValidator.getInstance());
BPMN_SEMANTIC_MODULES.addSemanticModule(new BPMNSemanticModule());
@@ -143,6 +146,8 @@ public static ProcessCodegen ofCollectedResources(KogitoBuildContext context, Co
if (useSvgAddon) {
context.addContextAttribute(ContextAttributesConstants.PROCESS_AUTO_SVG_MAPPING, processSVGMap);
}
+ resources.stream().filter(resource -> resource.basePath().toString().equals(BUSINESS_CALENDAR_PATH))
+ .findFirst().ifPresent(resource -> context.addContextAttribute(BUSINESS_CALENDAR_RESOURCE_KEY, true));
handleValidation(context, processesErrors);
@@ -429,10 +434,16 @@ protected Collection internalGenerate() {
}
//Generating the Producer classes for Dependency Injection
- StaticDependencyInjectionProducerGenerator.of(context())
- .generate()
+ StaticDependencyInjectionProducerGenerator staticDependencyInjectionProducerGenerator = StaticDependencyInjectionProducerGenerator.of(context());
+
+ staticDependencyInjectionProducerGenerator.generate()
.entrySet()
.forEach(entry -> storeFile(PRODUCER_TYPE, entry.getKey(), entry.getValue()));
+ Boolean businessCalendar = context().getContextAttribute(BUSINESS_CALENDAR_RESOURCE_KEY, Boolean.class);
+ if (Objects.nonNull(businessCalendar) && businessCalendar) {
+ staticDependencyInjectionProducerGenerator.generate(BUSINESS_CALENDAR_PRODUCER_TEMPLATE)
+ .forEach((key, value) -> storeFile(PRODUCER_TYPE, key, value));
+ }
if (context().hasRESTForGenerator(this)) {
for (ProcessResourceGenerator resourceGenerator : rgs) {
diff --git a/kogito-codegen-modules/kogito-codegen-processes/src/main/java/org/kie/kogito/codegen/process/StaticDependencyInjectionProducerGenerator.java b/kogito-codegen-modules/kogito-codegen-processes/src/main/java/org/kie/kogito/codegen/process/StaticDependencyInjectionProducerGenerator.java
index 9c147303e7f..caf495ea236 100644
--- a/kogito-codegen-modules/kogito-codegen-processes/src/main/java/org/kie/kogito/codegen/process/StaticDependencyInjectionProducerGenerator.java
+++ b/kogito-codegen-modules/kogito-codegen-processes/src/main/java/org/kie/kogito/codegen/process/StaticDependencyInjectionProducerGenerator.java
@@ -58,6 +58,20 @@ public Map generate() {
generator -> generator.compilationUnitOrThrow().toString()));
}
+ /**
+ * Key is the FilePath, Value is the content
+ *
+ * @return Map with the generated resources
+ */
+ public Map generate(String... templates) {
+ if (!context.hasDI()) {
+ return Collections.emptyMap();
+ }
+ return Arrays.stream(templates).map(this::buildProducerTemplatedGenerator)
+ .collect(Collectors.toMap(TemplatedGenerator::generatedFilePath,
+ generator -> generator.compilationUnitOrThrow().toString()));
+ }
+
private TemplatedGenerator buildProducerTemplatedGenerator(String template) {
return TemplatedGenerator.builder()
.withTemplateBasePath("/class-templates/producer/")
diff --git a/kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/config/ProcessConfigQuarkusTemplate.java b/kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/config/ProcessConfigQuarkusTemplate.java
index 19491e3b91b..98daf8fbdca 100644
--- a/kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/config/ProcessConfigQuarkusTemplate.java
+++ b/kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/config/ProcessConfigQuarkusTemplate.java
@@ -18,10 +18,9 @@
*/
package $Package$;
-import jakarta.enterprise.inject.Instance;
-
import org.kie.api.event.process.ProcessEventListener;
import org.kie.kogito.auth.IdentityProvider;
+import org.kie.kogito.calendar.BusinessCalendar;
import org.kie.kogito.event.EventPublisher;
import org.kie.kogito.jobs.JobsService;
import org.kie.kogito.process.ProcessEventListenerConfig;
@@ -30,6 +29,8 @@
import org.kie.kogito.uow.UnitOfWorkManager;
import org.kie.kogito.uow.events.UnitOfWorkEventListener;
+import jakarta.enterprise.inject.Instance;
+
@jakarta.inject.Singleton
public class ProcessConfig extends org.kie.kogito.process.impl.AbstractProcessConfig {
@@ -44,7 +45,8 @@ public ProcessConfig(
org.kie.kogito.config.ConfigBean configBean,
Instance unitOfWorkEventListeners,
Instance versionResolver,
- Instance identityProvider) {
+ Instance identityProvider,
+ Instance businessCalendar) {
super(workItemHandlerConfig,
processEventListenerConfigs,
@@ -55,7 +57,8 @@ public ProcessConfig(
configBean.getServiceUrl(),
unitOfWorkEventListeners,
versionResolver,
- identityProvider);
+ identityProvider,
+ businessCalendar);
}
}
diff --git a/kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/config/ProcessConfigSpringTemplate.java b/kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/config/ProcessConfigSpringTemplate.java
index df77c11433b..8152091578b 100644
--- a/kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/config/ProcessConfigSpringTemplate.java
+++ b/kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/config/ProcessConfigSpringTemplate.java
@@ -22,6 +22,7 @@
import org.kie.api.event.process.ProcessEventListener;
import org.kie.kogito.auth.IdentityProvider;
+import org.kie.kogito.calendar.BusinessCalendar;
import org.kie.kogito.event.EventPublisher;
import org.kie.kogito.jobs.JobsService;
import org.kie.kogito.process.ProcessEventListenerConfig;
@@ -44,7 +45,8 @@ public ProcessConfig(
org.kie.kogito.config.ConfigBean configBean,
List unitOfWorkEventListeners,
List versionResolver,
- List identityProvider) {
+ List identityProvider,
+ List businessCalendar) {
super(workItemHandlerConfig,
processEventListenerConfigs,
@@ -55,6 +57,7 @@ public ProcessConfig(
configBean.getServiceUrl(),
unitOfWorkEventListeners,
versionResolver,
- identityProvider);
+ identityProvider,
+ businessCalendar);
}
}
diff --git a/kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/producer/BusinessCalendarProducerQuarkusTemplate.java b/kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/producer/BusinessCalendarProducerQuarkusTemplate.java
new file mode 100644
index 00000000000..f6b31eb04ce
--- /dev/null
+++ b/kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/producer/BusinessCalendarProducerQuarkusTemplate.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package $Package$;
+
+import org.jbpm.process.core.timer.BusinessCalendarImpl;
+import org.kie.kogito.calendar.BusinessCalendar;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import jakarta.enterprise.inject.Produces;
+
+public class BusinessCalendarProducer {
+
+ private static final Logger logger = LoggerFactory.getLogger(BusinessCalendarProducer.class);
+
+ @Produces
+ public BusinessCalendar createBusinessCalendar() {
+ try {
+ BusinessCalendar businessCalendar = new BusinessCalendarImpl();
+ return businessCalendar;
+ } catch (Exception e) {
+ logger.warn("Could not create business calendar: {}", e.getMessage());
+ }
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/producer/BusinessCalendarProducerSpringTemplate.java b/kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/producer/BusinessCalendarProducerSpringTemplate.java
new file mode 100644
index 00000000000..0f2eadf4184
--- /dev/null
+++ b/kogito-codegen-modules/kogito-codegen-processes/src/main/resources/class-templates/producer/BusinessCalendarProducerSpringTemplate.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package $Package$;
+
+import org.jbpm.process.core.timer.BusinessCalendarImpl;
+import org.kie.kogito.calendar.BusinessCalendar;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class BusinessCalendarProducer {
+
+ private static final Logger logger = LoggerFactory.getLogger(BusinessCalendarProducer.class);
+
+ @Bean
+ public BusinessCalendar createBusinessCalendar() {
+ try {
+ BusinessCalendar businessCalendar = new BusinessCalendarImpl();
+ return businessCalendar;
+ } catch (Exception e) {
+ logger.warn("Could not create business calendar: {}", e.getMessage());
+ }
+ return null;
+ }
+}
\ No newline at end of file