Skip to content

Instantly share code, notes, and snippets.

View tsurdilo's full-sized avatar

Tihomir Surdilovic tsurdilo

View GitHub Profile
package org.kie.kogito.serverless
import com.fasterxml.jackson.databind.JsonNode
import com.fasterxml.jackson.databind.node.ObjectNode
import java.lang.Integer
rule "Approve Application"
ruleflow-group "newapplicant"
no-loop
when
---
id: applicantworkflow
name: Applicant Workflow
version: '1.0'
events:
- name: NewApplicantEvent
source: applicants
type: kafka
- name: ApplicantDecisionEvent
source: decisions
<!-- needed for react integration -->
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>1.6</version>
<configuration>
<workingDirectory>reactapp</workingDirectory>
<installDirectory>target</installDirectory>
</configuration>
<executions>
public RuleSetNode ruleUnitNode(long id, String name, Function function, NodeContainer nodeContainer) {
RuleSetNode ruleSetNode = new RuleSetNode();
ruleSetNode.setId(id);
ruleSetNode.setName(name);
//ruleSetNode.setLanguage(RuleSetNode.DRL_LANG);
if (ServerlessWorkflowUtils.resolveFunctionMetadata(function, RF_GROUP, workflowAppContext).length() > 0) {
ruleSetNode.setRuleType(RuleSetNode.RuleType.of(ServerlessWorkflowUtils.resolveFunctionMetadata(function, RF_GROUP, workflowAppContext),
RuleSetNode.DRL_LANG));
} else {
org.jbpm.ruleflow.core.factory.RuleSetNodeFactory ruleSetNode4 = factory.ruleSetNode(4);
ruleSetNode4.name("Process Traveler");
ruleSetNode4.inMapping("traveller", "traveller");
ruleSetNode4.outMapping("traveller", "traveller");
ruleSetNode4.ruleUnit("org.acme.travel.TravellerValidationService", new org.jbpm.workflow.core.node.RuleUnitFactory<org.acme.travel.TravellerValidationService>() {
public org.acme.travel.TravellerValidationService bind(org.kie.api.runtime.process.ProcessContext kcontext) {
org.acme.travel.TravellerValidationService unit = new org.acme.travel.TravellerValidationService();
{
org.kie.kogito.rules.SingletonStore unit_traveller = unit.getTraveller();
{
"id": "decisionworkflow",
"name": "Decision Workflow",
"version": "1.0",
"functions": [
{
"name": "doapproval",
"type": "decision",
"metadata": {
"actorid": "workflow",
apiVersion: app.kiegroup.org/v1alpha1
kind: KogitoApp
metadata:
name: kogito-travel-agency
spec:
enableEvents: true
enablePersistence: true
build:
gitSource:
contextDir: kogito-travel-agency
{
"id": "jsonservicecall",
"version": "1.0",
"name": "Service Call Workflow",
"description": "JSON based service call workflow",
"functions": [
{
"name": "countryInfoFunction",
"type": "service"
},
***************** runtime updates -- application properties:
org.kogito.serverless.examples.CountriesService/mp-rest/url=https://restcountries.eu/rest
org.kogito.serverless.examples.CountriesService/mp-rest/scope=javax.inject.Singleton
# serverless workflow properties
kogito.sw.functions.countryInfoFunction.interface=org.kogito.serverless.examples.CountriesResource
kogito.sw.functions.countryInfoFunction.operation=jsonName
kogito.sw.functions.classifySmallMediumFunction.interface=org.kogito.serverless.examples.CountriesClassifierResource
kogito.sw.functions.classifySmallMediumFunction.operation=classifySmallMedium
kogito.sw.functions.classifyLargeFunction.interface=org.kogito.serverless.examples.CountriesClassifierResource