org.kie.kogito.examples.Application Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jbpm-quarkus-example
Show all versions of jbpm-quarkus-example
Order management service
package org.kie.kogito.examples;
import org.kie.kogito.Config;
import org.kie.kogito.process.Processes;
import org.kie.kogito.uow.UnitOfWorkManager;
@javax.inject.Singleton()
public class Application implements org.kie.kogito.Application {
@javax.inject.Inject()
javax.enterprise.inject.Instance eventPublishers;
@org.eclipse.microprofile.config.inject.ConfigProperty(name = "kogito.service.url")
java.util.Optional kogitoService;
@javax.inject.Inject()
org.kie.kogito.Config config;
RuleUnits ruleUnits = new RuleUnits();
Processes processes = new Processes();
public Config config() {
return config;
}
public UnitOfWorkManager unitOfWorkManager() {
return config().process().unitOfWorkManager();
}
@javax.annotation.PostConstruct()
public void setup() {
if (config().process() != null) {
if (eventPublishers != null) {
eventPublishers.forEach(publisher -> unitOfWorkManager().eventManager().addPublisher(publisher));
}
unitOfWorkManager().eventManager().setService(kogitoService.orElse(""));
unitOfWorkManager().eventManager().setAddons(config().addons());
}
}
public RuleUnits ruleUnits() {
return ruleUnits;
}
public class RuleUnits extends org.kie.kogito.rules.units.impl.AbstractRuleUnits {
org.kie.kogito.rules.KieRuntimeBuilder ruleRuntimeBuilder = new org.drools.project.model.ProjectRuntime();
public org.kie.kogito.rules.KieRuntimeBuilder ruleRuntimeBuilder() {
return this.ruleRuntimeBuilder;
}
protected org.kie.kogito.rules.RuleUnit> create(String fqcn) {
switch(fqcn) {
case "org.kie.kogito.examples.PersonValidationService":
return new org.kie.kogito.examples.PersonValidationServiceRuleUnit(Application.this);
default:
throw new java.lang.UnsupportedOperationException();
}
}
}
public Processes processes() {
return processes;
}
public class Processes implements org.kie.kogito.process.Processes {
public org.kie.kogito.process.Process extends org.kie.kogito.Model> processById(String processId) {
if ("persons".equals(processId))
return new org.kie.kogito.examples.demo.PersonsProcess(Application.this).configure();
if ("demo.orderItems".equals(processId))
return new org.kie.kogito.examples.OrderItemsProcess(Application.this).configure();
if ("demo.orders".equals(processId))
return new org.kie.kogito.examples.OrdersProcess(Application.this).configure();
return null;
}
public java.util.Collection processIds() {
return java.util.Arrays.asList("persons", "demo.orderItems", "demo.orders");
}
}
}