Skip to content

Commit

Permalink
Merge pull request #20 from rgdoliveira/sync_main
Browse files Browse the repository at this point in the history
Sync main branch with Apache main branch
  • Loading branch information
rgdoliveira authored Apr 16, 2024
2 parents 2ad3dd7 + 58206ce commit c799f4b
Show file tree
Hide file tree
Showing 16 changed files with 57 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,10 @@ public void testProcessGatewayAPI() throws IOException {
.statusCode(200)
.body("data.ProcessInstances[0].nodeDefinitions", notNullValue())
.body("data.ProcessInstances[0].nodeDefinitions.size()", is(4))
.body("data.ProcessInstances[0].nodeDefinitions[0].id", is("1"))
.body("data.ProcessInstances[0].nodeDefinitions[0].id", is("_8B62D3CA-5D03-4B2B-832B-126469288BB4"))
.body("data.ProcessInstances[0].nodeDefinitions[0].name", is("First Line Approval"))
.body("data.ProcessInstances[0].nodeDefinitions[0].type", is("HumanTaskNode"))
.body("data.ProcessInstances[0].nodeDefinitions[0].uniqueId", is("1"))
.body("data.ProcessInstances[0].nodeDefinitions[0].uniqueId", is("_8B62D3CA-5D03-4B2B-832B-126469288BB4"))
.body("data.ProcessInstances[0].nodeDefinitions[0].metadata.UniqueId", is("_8B62D3CA-5D03-4B2B-832B-126469288BB4"))
.body("data.ProcessInstances[0].nodes.size()", is(2))
.body("data.ProcessInstances[0].nodes.name", hasItem("First Line Approval"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import org.kie.kogito.event.process.ProcessInstanceNodeEventBody;
import org.kie.kogito.event.process.ProcessInstanceSLADataEvent;
import org.kie.kogito.event.process.ProcessInstanceStateDataEvent;
import org.kie.kogito.event.process.ProcessInstanceStateEventBody;
import org.kie.kogito.event.process.ProcessInstanceVariableDataEvent;
import org.kie.kogito.event.usertask.UserTaskInstanceAssignmentDataEvent;
import org.kie.kogito.event.usertask.UserTaskInstanceAttachmentDataEvent;
Expand All @@ -64,7 +65,6 @@
import org.kie.kogito.event.usertask.UserTaskInstanceDeadlineDataEvent;
import org.kie.kogito.event.usertask.UserTaskInstanceStateDataEvent;
import org.kie.kogito.event.usertask.UserTaskInstanceVariableDataEvent;
import org.kie.kogito.internal.process.runtime.KogitoProcessInstance;
import org.kie.kogito.jobs.service.model.ScheduledJob;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -95,29 +95,17 @@ public void storeProcessInstanceDataEvent(DataAuditContext context, ProcessInsta
log.setRoles(event.getData().getRoles());

EntityManager entityManager = context.getContext();
switch (event.getData().getState()) {
case KogitoProcessInstance.STATE_ACTIVE:
switch (event.getData().getEventType()) {
case ProcessInstanceStateEventBody.EVENT_TYPE_STARTED:
log.setEventType(ProcessStateLogType.ACTIVE);
entityManager.persist(log);
break;
case KogitoProcessInstance.STATE_ABORTED:
log.setEventType(ProcessStateLogType.ABORTED);
entityManager.persist(log);
break;
case KogitoProcessInstance.STATE_COMPLETED:
case ProcessInstanceStateEventBody.EVENT_TYPE_ENDED:
log.setEventType(ProcessStateLogType.COMPLETED);
entityManager.persist(log);
break;
case KogitoProcessInstance.STATE_PENDING:
log.setEventType(ProcessStateLogType.PENDING);
entityManager.persist(log);
break;
case KogitoProcessInstance.STATE_SUSPENDED:
log.setEventType(ProcessStateLogType.SUSPENDING);
entityManager.persist(log);
break;
case KogitoProcessInstance.STATE_ERROR:
log.setEventType(ProcessStateLogType.ERROR);
case ProcessInstanceStateEventBody.EVENT_TYPE_MIGRATED:
log.setEventType(ProcessStateLogType.MIGRATED);
entityManager.persist(log);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,9 @@ public class ProcessInstanceStateLog extends AbstractProcessInstanceLog {

public enum ProcessStateLogType {
ACTIVE,
STARTED,
COMPLETED,
ABORTED,
MIGRATED,
SLA_VIOLATION,
PENDING,
SUSPENDING,
ERROR
}

@Id
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE Process_Instance_State_Log DROP CONSTRAINT Process_Instance_State_Log_event_type_check;
ALTER TABLE Process_Instance_State_Log ADD CONSTRAINT Process_Instance_State_Log_event_type_check CHECK (event_type IN ( 'ACTIVE','COMPLETED','SLA_VIOLATION', 'MIGRATED' ));
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE Process_Instance_State_Log DROP CONSTRAINT Process_Instance_State_Log_event_type_check;
ALTER TABLE Process_Instance_State_Log ADD CONSTRAINT Process_Instance_State_Log_event_type_check CHECK (event_type IN ( 'ACTIVE','COMPLETED','SLA_VIOLATION', 'MIGRATED' ));
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public CompletableFuture<List<Node>> getProcessDefinitionNodes(String serviceURL
List<org.kie.api.definition.process.Node> nodes = ((KogitoWorkflowProcess) ((AbstractProcess<?>) process).get()).getNodesRecursively();
List<Node> list = nodes.stream().map(n -> {
Node data = new Node();
data.setId(String.valueOf(n.getId()));
data.setId(n.getId().toExternalFormat());
data.setUniqueId(((org.jbpm.workflow.core.Node) n).getUniqueId());
data.setMetadata(n.getMetaData() == null ? null : mapMetadata(n));
data.setType(n.getClass().getSimpleName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ void testDataIndexAddon() {
.body("data.ProcessDefinitions[0].addons", hasItem("infinispan-persistence"))
.body("data.ProcessDefinitions[0].source", is(not(emptyOrNullString())))
.body("data.ProcessDefinitions[0].nodes.size()", is(2))
.body("data.ProcessDefinitions[0].nodes[0].id", is("1"))
.body("data.ProcessDefinitions[0].nodes[0].id", is("_B3241ACF-97BE-443B-A49F-964AB3DD006C"))
.body("data.ProcessDefinitions[0].nodes[0].name", is("End"))
.body("data.ProcessDefinitions[0].nodes[0].type", is("EndNode"))
.body("data.ProcessDefinitions[0].nodes[0].uniqueId", is("1"))
.body("data.ProcessDefinitions[0].nodes[0].uniqueId", is("_B3241ACF-97BE-443B-A49F-964AB3DD006C"))
.body("data.ProcessDefinitions[0].nodes[0].metadata.UniqueId", is("_B3241ACF-97BE-443B-A49F-964AB3DD006C"));

given().contentType(ContentType.JSON)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void testDataIndexAddon() {
.body("data.ProcessDefinitions[0].nodes[0].name", is("Start"))
.body("data.ProcessDefinitions[0].nodes[0].type", is("StartNode"))
.body("data.ProcessDefinitions[0].nodes[0].uniqueId", is("1"))
.body("data.ProcessDefinitions[0].nodes[0].metadata.UniqueId", is("_jbpm-unique-0"))
.body("data.ProcessDefinitions[0].nodes[0].metadata.UniqueId", is("1"))
.extract().path("data.ProcessDefinitions[0].source");

assertThat(JsonPath.from(source).getString("id")).isEqualTo("greet");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ void testDataIndexAddon() {
.body("data.ProcessDefinitions[0].addons", hasItem("mongodb-persistence"))
.body("data.ProcessDefinitions[0].source", is(not(emptyOrNullString())))
.body("data.ProcessDefinitions[0].nodes.size()", is(2))
.body("data.ProcessDefinitions[0].nodes[0].id", is("1"))
.body("data.ProcessDefinitions[0].nodes[0].id", is("_B3241ACF-97BE-443B-A49F-964AB3DD006C"))
.body("data.ProcessDefinitions[0].nodes[0].name", is("End"))
.body("data.ProcessDefinitions[0].nodes[0].type", is("EndNode"))
.body("data.ProcessDefinitions[0].nodes[0].uniqueId", is("1"))
.body("data.ProcessDefinitions[0].nodes[0].uniqueId", is("_B3241ACF-97BE-443B-A49F-964AB3DD006C"))
.body("data.ProcessDefinitions[0].nodes[0].metadata.UniqueId", is("_B3241ACF-97BE-443B-A49F-964AB3DD006C"));

given().contentType(ContentType.JSON)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void testDataIndexAddon() {
.body("data.ProcessDefinitions[0].nodes[0].name", is("Start"))
.body("data.ProcessDefinitions[0].nodes[0].type", is("StartNode"))
.body("data.ProcessDefinitions[0].nodes[0].uniqueId", is("1"))
.body("data.ProcessDefinitions[0].nodes[0].metadata.UniqueId", is("_jbpm-unique-0"))
.body("data.ProcessDefinitions[0].nodes[0].metadata.UniqueId", is("1"))
.extract().path("data.ProcessDefinitions[0].source");

assertThat(JsonPath.from(source).getString("id")).isEqualTo("greet");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ void testDataIndexAddon() {
.body("data.ProcessDefinitions[0].addons", hasItem("jdbc-persistence"))
.body("data.ProcessDefinitions[0].source", is(not(emptyOrNullString())))
.body("data.ProcessDefinitions[0].nodes.size()", is(2))
.body("data.ProcessDefinitions[0].nodes[0].id", is("1"))
.body("data.ProcessDefinitions[0].nodes[0].id", is("_B3241ACF-97BE-443B-A49F-964AB3DD006C"))
.body("data.ProcessDefinitions[0].nodes[0].name", is("End"))
.body("data.ProcessDefinitions[0].nodes[0].type", is("EndNode"))
.body("data.ProcessDefinitions[0].nodes[0].uniqueId", is("1"))
.body("data.ProcessDefinitions[0].nodes[0].uniqueId", is("_B3241ACF-97BE-443B-A49F-964AB3DD006C"))
.body("data.ProcessDefinitions[0].nodes[0].metadata.UniqueId", is("_B3241ACF-97BE-443B-A49F-964AB3DD006C"));

given().contentType(ContentType.JSON)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void testDataIndexAddon() {
.body("data.ProcessDefinitions[0].nodes[0].name", is("Start"))
.body("data.ProcessDefinitions[0].nodes[0].type", is("StartNode"))
.body("data.ProcessDefinitions[0].nodes[0].uniqueId", is("1"))
.body("data.ProcessDefinitions[0].nodes[0].metadata.UniqueId", is("_jbpm-unique-0"))
.body("data.ProcessDefinitions[0].nodes[0].metadata.UniqueId", is("1"))
.extract().path("data.ProcessDefinitions[0].source");

assertThat(JsonPath.from(source).getString("id")).isEqualTo("greet");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,23 @@ public static void setup() {
}

@Test
void unnamedImport() throws IOException {
String URI1 = "valid_models/DMNv1_5/Importing_EmptyNamed_Model.dmn";
String URI2 = "valid_models/DMNv1_5/Imported_Model_Unamed.dmn";
ResourceWithURI model1 = new ResourceWithURI(URI1, getModelFromIoUtils(URI1));
ResourceWithURI model2 = new ResourceWithURI(URI2, getModelFromIoUtils(URI2));
void unnamedImportWithHrefNamespace() throws IOException {
commonUnnamedImport("valid_models/DMNv1_5/Importing_EmptyNamed_Model_With_Href_Namespace.dmn",
"valid_models/DMNv1_5/Imported_Model_Unamed.dmn");
}

@Test
void unnamedImportWithoutHrefNamespace() throws IOException {
commonUnnamedImport("valid_models/DMNv1_5/Importing_EmptyNamed_Model_Without_Href_Namespace.dmn",
"valid_models/DMNv1_5/Imported_Model_Unamed.dmn");
}

private void commonUnnamedImport(String importingModelRef, String importedModelRef) throws IOException {
ResourceWithURI model1 = new ResourceWithURI(importingModelRef, getModelFromIoUtils(importingModelRef));
ResourceWithURI model2 = new ResourceWithURI(importedModelRef, getModelFromIoUtils(importedModelRef));

JITDMNPayload jitdmnpayload = new JITDMNPayload(URI1, List.of(model1, model2), Collections.EMPTY_MAP);
JITDMNPayload jitdmnpayload = new JITDMNPayload(importingModelRef, List.of(model1, model2),
Collections.EMPTY_MAP);
given()
.contentType(ContentType.JSON)
.body(jitdmnpayload)
Expand All @@ -79,7 +89,7 @@ void unnamedImport() throws IOException {

String response = given()
.contentType(ContentType.JSON)
.body(new MultipleResourcesPayload(URI1, List.of(model1, model2)))
.body(new MultipleResourcesPayload(importingModelRef, List.of(model1, model2)))
.when()
.post("/jitdmn/validate")
.then()
Expand All @@ -92,7 +102,7 @@ void unnamedImport() throws IOException {

Map<String, Object> context =
Map.of("A Person", Map.of("name", "John", "age", 47));
jitdmnpayload = new JITDMNPayload(URI1, List.of(model1, model2), context);
jitdmnpayload = new JITDMNPayload(importingModelRef, List.of(model1, model2), context);
given()
.contentType(ContentType.JSON)
.body(jitdmnpayload)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package org.kie.kogito.jobs.embedded;

import java.util.Optional;

import org.kie.kogito.Application;
import org.kie.kogito.Model;
import org.kie.kogito.jobs.service.api.Recipient;
Expand Down Expand Up @@ -53,12 +55,21 @@ public Uni<JobExecutionResponse> execute(JobDetails jobDetails) {
RecipientInstance recipientModel = (RecipientInstance) jobDetails.getRecipient();
InVMRecipient recipient = (InVMRecipient) recipientModel.getRecipient();
String timerId = recipient.getPayload().getData().timerId();
String processId = recipient.getPayload().getData().processId();
Process<? extends Model> process = processes.processById(processId);
String processInstanceId = recipient.getPayload().getData().processInstanceId();
Optional<Process<? extends Model>> process = processes.processByProcessInstanceId(processInstanceId);
if (process.isEmpty()) {
return Uni.createFrom().item(
JobExecutionResponse.builder()
.code("401")
.jobId(jobDetails.getId())
.now()
.message("job does not belong to this container")
.build());
}

Integer limit = jobDetails.getRetries();

TriggerJobCommand command = new TriggerJobCommand(processInstanceId, correlationId, timerId, limit, process, application.unitOfWorkManager());
TriggerJobCommand command = new TriggerJobCommand(processInstanceId, correlationId, timerId, limit, process.get(), application.unitOfWorkManager());

return Uni.createFrom().item(command::execute)
.onFailure()
Expand Down
2 changes: 1 addition & 1 deletion kogito-apps-build-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<version.org.hibernate>6.2.13.Final</version.org.hibernate>
<version.org.apache.opennlp>2.3.1</version.org.apache.opennlp>
<version.org.apache.commons.csv>1.10.0</version.org.apache.commons.csv>
<version.org.jredisearch>2.0.0</version.org.jredisearch>
<version.org.jredisearch>2.2.0</version.org.jredisearch>
<version.org.mapstruct>1.5.5.Final</version.org.mapstruct>
<version.org.skyscreamer>1.5.0</version.org.skyscreamer>
<version.com.graphql-java-extended-scalars>19.0</version.com.graphql-java-extended-scalars>
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">


<modelVersion>4.0.0</modelVersion>

<parent>
Expand Down

0 comments on commit c799f4b

Please sign in to comment.