From 094c9d8a32d4660640511b0f5c4870b53ac6483e Mon Sep 17 00:00:00 2001 From: nmirasch Date: Wed, 9 Aug 2023 19:14:56 +0200 Subject: [PATCH] KOGITO-8940: Creator/owner field at process --- .../event/ProcessInstanceEventMapper.java | 1 + .../index/json/ProcessInstanceMetaMapper.java | 3 ++ .../src/main/resources/basic.schema.graphqls | 3 ++ .../java/org/kie/kogito/index/TestUtils.java | 6 ++-- .../json/ProcessInstanceMetaMapperTest.java | 8 +++-- .../src/main/resources/domain.schema.graphqls | 2 ++ .../AbstractDomainIndexingServiceIT.java | 20 +++++------ .../service/AbstractIndexingServiceIT.java | 36 ++++--------------- .../kogito/index/service/GraphQLUtils.java | 4 +++ .../AbstractWebSocketSubscriptionIT.java | 4 +-- .../AbstractGraphQLRuntimesQueriesIT.java | 20 +++++------ ...AbstractDomainMessagingHttpConsumerIT.java | 2 +- .../AbstractMessagingHttpConsumerIT.java | 2 +- .../AbstractMessagingLoadKafkaIT.java | 4 +-- .../messaging/DomainEventConsumerTest.java | 2 +- .../ReactiveMessagingEventConsumerTest.java | 2 +- .../src/test/resources/graphql_queries.json | 6 ++++ .../src/main/resources/application.properties | 2 ++ .../index/model/ProcessInstanceMeta.java | 11 ++++++ .../ProcessInstanceMarshaller.java | 3 ++ .../ProcessInstanceMarshallerTest.java | 26 ++++---------- .../mongodb/model/ProcessInstanceEntity.java | 10 ++++++ .../model/ProcessInstanceEntityMapper.java | 2 ++ .../ProcessInstanceEntityMapperTest.java | 3 ++ .../oracle/model/ProcessInstanceEntity.java | 9 +++++ ...33.1__add_identity_to_process_instance.sql | 2 ++ .../mapper/ProcessInstanceEntityMapperIT.java | 3 ++ .../model/ProcessInstanceEntity.java | 9 +++++ ...32.1__add_identity_to_process_instance.sql | 2 ++ .../mapper/ProcessInstanceEntityMapperIT.java | 3 ++ .../resources/META-INF/kogito-index.proto | 3 ++ .../addon/DataIndexEventPublisherTest.java | 2 +- 32 files changed, 133 insertions(+), 82 deletions(-) create mode 100644 data-index/data-index-storage/data-index-storage-oracle/src/main/resources/db/migration/V1.33.1__add_identity_to_process_instance.sql create mode 100644 data-index/data-index-storage/data-index-storage-postgresql/src/main/resources/db/migration/V1.32.1__add_identity_to_process_instance.sql diff --git a/data-index/data-index-common/src/main/java/org/kie/kogito/index/event/ProcessInstanceEventMapper.java b/data-index/data-index-common/src/main/java/org/kie/kogito/index/event/ProcessInstanceEventMapper.java index 2239b4746c..05f0ba3f6f 100644 --- a/data-index/data-index-common/src/main/java/org/kie/kogito/index/event/ProcessInstanceEventMapper.java +++ b/data-index/data-index-common/src/main/java/org/kie/kogito/index/event/ProcessInstanceEventMapper.java @@ -61,6 +61,7 @@ public ProcessInstance apply(ProcessInstanceDataEvent event) { pi.setAddons(isNullOrEmpty(event.getKogitoAddons()) ? null : Set.of(event.getKogitoAddons().split(","))); pi.setEndpoint(event.getSource() == null ? null : event.getSource().toString()); pi.setLastUpdate(toZonedDateTime(event.getTime())); + pi.setIdentity(event.getData().getIdentity()); return pi; } diff --git a/data-index/data-index-common/src/main/java/org/kie/kogito/index/json/ProcessInstanceMetaMapper.java b/data-index/data-index-common/src/main/java/org/kie/kogito/index/json/ProcessInstanceMetaMapper.java index c4aa5eba41..874f5f0713 100644 --- a/data-index/data-index-common/src/main/java/org/kie/kogito/index/json/ProcessInstanceMetaMapper.java +++ b/data-index/data-index-common/src/main/java/org/kie/kogito/index/json/ProcessInstanceMetaMapper.java @@ -79,6 +79,9 @@ private ObjectNode getProcessJson(ProcessInstanceDataEvent event) { if (!isNullOrEmpty(event.getData().getBusinessKey())) { json.put("businessKey", event.getData().getBusinessKey()); } + if (!isNullOrEmpty(event.getData().getIdentity())) { + json.put("identity", event.getData().getIdentity()); + } return json; } } diff --git a/data-index/data-index-common/src/main/resources/basic.schema.graphqls b/data-index/data-index-common/src/main/resources/basic.schema.graphqls index f6d22aa649..8007f7cc57 100644 --- a/data-index/data-index-common/src/main/resources/basic.schema.graphqls +++ b/data-index/data-index-common/src/main/resources/basic.schema.graphqls @@ -37,6 +37,7 @@ type ProcessInstance { nodeDefinitions: [Node!] diagram: String source: String + identity: String } type ProcessInstanceError { @@ -93,6 +94,7 @@ input ProcessInstanceOrderBy { error: ProcessInstanceErrorOrderBy lastUpdate: OrderBy businessKey: OrderBy + identity: OrderBy } input ProcessInstanceErrorOrderBy { @@ -121,6 +123,7 @@ input ProcessInstanceArgument { addons: StringArrayArgument lastUpdate: DateArgument businessKey: StringArgument + identity: StringArgument } input ProcessInstanceErrorArgument { diff --git a/data-index/data-index-common/src/test/java/org/kie/kogito/index/TestUtils.java b/data-index/data-index-common/src/test/java/org/kie/kogito/index/TestUtils.java index b98819762e..2c00b92f7e 100644 --- a/data-index/data-index-common/src/test/java/org/kie/kogito/index/TestUtils.java +++ b/data-index/data-index-common/src/test/java/org/kie/kogito/index/TestUtils.java @@ -96,7 +96,7 @@ public static String readFileContent(String file) throws IOException { } public static ProcessInstanceDataEvent getProcessCloudEvent(String processId, String processInstanceId, ProcessInstanceState status, String rootProcessInstanceId, String rootProcessId, - String parentProcessInstanceId) { + String parentProcessInstanceId, String identity) { ProcessInstanceEventBody body = ProcessInstanceEventBody.create() .id(processInstanceId) @@ -109,6 +109,7 @@ public static ProcessInstanceDataEvent getProcessCloudEvent(String processId, St .endDate(status == ProcessInstanceState.COMPLETED ? Date.from(Instant.now().plus(1, ChronoUnit.HOURS)) : null) .state(status.ordinal()) .businessKey(RandomStringUtils.randomAlphabetic(10)) + .identity(identity) .variables(getProcessInstanceVariablesMap()) .milestones(Set.of( MilestoneEventBody.create() @@ -132,7 +133,7 @@ public static ProcessInstanceDataEvent getProcessCloudEvent(String processId, St .build() : null) .build(); - return new ProcessInstanceDataEvent(URI.create("http://localhost:8080/" + processId).toString(), "jobs-management,prometheus-monitoring,process-management", null, body.metaData(), body); + return new ProcessInstanceDataEvent(URI.create("http://localhost:8080/" + processId).toString(), "jobs-management,prometheus-monitoring,process-management", identity, body.metaData(), body); } public static ProcessInstance getProcessInstance(String processId, String processInstanceId, Integer status, String rootProcessInstanceId, String rootProcessId) { @@ -154,6 +155,7 @@ public static ProcessInstance getProcessInstance(String processId, String proces } pi.setMilestones(getMilestones()); pi.setBusinessKey(RandomStringUtils.randomAlphabetic(10)); + pi.setIdentity("currentUser"); return pi; } diff --git a/data-index/data-index-common/src/test/java/org/kie/kogito/index/json/ProcessInstanceMetaMapperTest.java b/data-index/data-index-common/src/test/java/org/kie/kogito/index/json/ProcessInstanceMetaMapperTest.java index dcdf81a31a..de1f8d9258 100644 --- a/data-index/data-index-common/src/test/java/org/kie/kogito/index/json/ProcessInstanceMetaMapperTest.java +++ b/data-index/data-index-common/src/test/java/org/kie/kogito/index/json/ProcessInstanceMetaMapperTest.java @@ -38,7 +38,7 @@ public void testProcessInstanceMapper() { String processInstanceId = UUID.randomUUID().toString(); String rootProcessInstanceId = UUID.randomUUID().toString(); String piPrefix = KOGITO_DOMAIN_ATTRIBUTE + "." + PROCESS_INSTANCES_DOMAIN_ATTRIBUTE; - ProcessInstanceDataEvent event = getProcessCloudEvent(processId, processInstanceId, ProcessInstanceState.COMPLETED, rootProcessInstanceId, rootProcessId, rootProcessInstanceId); + ProcessInstanceDataEvent event = getProcessCloudEvent(processId, processInstanceId, ProcessInstanceState.COMPLETED, rootProcessInstanceId, rootProcessId, rootProcessInstanceId, "currentUser"); ObjectNode json = new ProcessInstanceMetaMapper().apply(event); assertThat(json).isNotNull(); assertThatJson(json.toString()).and( @@ -59,6 +59,7 @@ public void testProcessInstanceMapper() { a -> a.node(piPrefix + "[0].endpoint").isEqualTo(event.getSource().toString()), a -> a.node(piPrefix + "[0].start").isEqualTo(event.getData().getStartDate().toInstant().toEpochMilli()), a -> a.node(piPrefix + "[0].end").isEqualTo(event.getData().getEndDate().toInstant().toEpochMilli()), + a -> a.node(piPrefix + "[0].identity").isEqualTo(event.getData().getIdentity().toString()), a -> a.node(piPrefix + "[0].lastUpdate").isEqualTo(event.getTime().toInstant().toEpochMilli())); } @@ -69,7 +70,7 @@ public void testProcessInstanceMapperWithBusinessKey() { String processInstanceId = UUID.randomUUID().toString(); String rootProcessInstanceId = UUID.randomUUID().toString(); String piPrefix = KOGITO_DOMAIN_ATTRIBUTE + "." + PROCESS_INSTANCES_DOMAIN_ATTRIBUTE; - ProcessInstanceDataEvent event = getProcessCloudEvent(processId, processInstanceId, ProcessInstanceState.COMPLETED, rootProcessInstanceId, rootProcessId, rootProcessInstanceId); + ProcessInstanceDataEvent event = getProcessCloudEvent(processId, processInstanceId, ProcessInstanceState.COMPLETED, rootProcessInstanceId, rootProcessId, rootProcessInstanceId, "currentUser"); event.getData().update().businessKey("custom-key"); ObjectNode json = new ProcessInstanceMetaMapper().apply(event); assertThat(json).isNotNull(); @@ -92,6 +93,7 @@ public void testProcessInstanceMapperWithBusinessKey() { a -> a.node(piPrefix + "[0].start").isEqualTo(event.getData().getStartDate().toInstant().toEpochMilli()), a -> a.node(piPrefix + "[0].end").isEqualTo(event.getData().getEndDate().toInstant().toEpochMilli()), a -> a.node(piPrefix + "[0].lastUpdate").isEqualTo(event.getTime().toInstant().toEpochMilli()), - a -> a.node(piPrefix + "[0].businessKey").isEqualTo(event.getData().getBusinessKey())); + a -> a.node(piPrefix + "[0].businessKey").isEqualTo(event.getData().getBusinessKey()), + a -> a.node(piPrefix + "[0].identity").isEqualTo(event.getData().getIdentity().toString())); } } diff --git a/data-index/data-index-service/data-index-service-common/src/main/resources/domain.schema.graphqls b/data-index/data-index-service/data-index-service-common/src/main/resources/domain.schema.graphqls index e50c8dc121..a7e5ce7245 100644 --- a/data-index/data-index-service/data-index-service-common/src/main/resources/domain.schema.graphqls +++ b/data-index/data-index-service/data-index-service-common/src/main/resources/domain.schema.graphqls @@ -55,6 +55,7 @@ type ProcessInstanceMeta { end: DateTime lastUpdate: DateTime! businessKey: String + identity: String } input ProcessInstanceMetaArgument { @@ -70,6 +71,7 @@ input ProcessInstanceMetaArgument { start: DateArgument end: DateArgument businessKey: StringArgument + identity: StringArgument } extend type UserTaskInstance { diff --git a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/AbstractDomainIndexingServiceIT.java b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/AbstractDomainIndexingServiceIT.java index 03b26e573c..e95cc4a75c 100644 --- a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/AbstractDomainIndexingServiceIT.java +++ b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/AbstractDomainIndexingServiceIT.java @@ -174,7 +174,7 @@ void testAddProtoFile() throws Exception { .when().post("/graphql") .then().log().ifValidationFails().statusCode(200).body("data.Travels", isA(Collection.class)); - ProcessInstanceDataEvent startEvent = getProcessCloudEvent(processId, processInstanceId, ACTIVE, null, null, null); + ProcessInstanceDataEvent startEvent = getProcessCloudEvent(processId, processInstanceId, ACTIVE, null, null, null, "currentUser"); indexProcessCloudEvent(startEvent); validateProcessInstance(getProcessInstanceByIdAndState(processInstanceId, ACTIVE), startEvent); @@ -203,7 +203,7 @@ void testAddProtoFile() throws Exception { .body("data.Travels[0].flight.flightNumber", is("MX555")); ProcessInstanceDataEvent subProcessStartEvent = getProcessCloudEvent(subProcessId, subProcessInstanceId, ACTIVE, - processInstanceId, processId, processInstanceId); + processInstanceId, processId, processInstanceId, "currentUser"); Map travellerMap = new HashMap<>(); travellerMap.put("firstName", "Maciej"); travellerMap.put("email", "mail@mail.com"); @@ -269,7 +269,7 @@ void testAddProtoFile() throws Exception { .body("data.Travels[0].flight.arrival", is("2019-08-20T22:12:57.34Z")) .body("data.Travels[0].flight.departure", is("2019-08-20T07:12:57.34Z")); - ProcessInstanceDataEvent endEvent = getProcessCloudEvent(processId, processInstanceId, COMPLETED, null, null, null); + ProcessInstanceDataEvent endEvent = getProcessCloudEvent(processId, processInstanceId, COMPLETED, null, null, null, "currentUser"); indexProcessCloudEvent(endEvent); validateProcessInstance(getProcessInstanceByIdAndState(processInstanceId, COMPLETED), endEvent, subProcessInstanceId); @@ -418,7 +418,7 @@ void testIndexingDomainUsingUserTaskEventFirst() throws Exception { .body("data.Travels[0].metadata.userTasks[0].lastUpdate", is(formatOffsetDateTime(userTaskEvent.getTime()))) .body("data.Travels[0].metadata.processInstances", is(nullValue())); - ProcessInstanceDataEvent processEvent = getProcessCloudEvent(processId, processInstanceId, ACTIVE, null, null, null); + ProcessInstanceDataEvent processEvent = getProcessCloudEvent(processId, processInstanceId, ACTIVE, null, null, null, "currentUser"); indexProcessCloudEvent(processEvent); given().contentType(ContentType.JSON) @@ -464,7 +464,7 @@ void testIndexingDomainUsingProcessEventFirst() throws Exception { .when().post("/graphql") .then().log().ifValidationFails().statusCode(200).body("data.Travels", isA(Collection.class)); - ProcessInstanceDataEvent processEvent = getProcessCloudEvent(processId, processInstanceId, ACTIVE, null, null, null); + ProcessInstanceDataEvent processEvent = getProcessCloudEvent(processId, processInstanceId, ACTIVE, null, null, null, "currentUser"); indexProcessCloudEvent(processEvent); given().contentType(ContentType.JSON) @@ -533,7 +533,7 @@ void testIndexingDomainParallelEvents() throws Exception { .when().post("/graphql") .then().log().ifValidationFails().statusCode(200).body("data.Travels", isA(Collection.class)); - ProcessInstanceDataEvent processEvent = getProcessCloudEvent(processId, processInstanceId, ACTIVE, null, null, null); + ProcessInstanceDataEvent processEvent = getProcessCloudEvent(processId, processInstanceId, ACTIVE, null, null, null, "currentUser"); UserTaskInstanceDataEvent userTaskEvent = getUserTaskCloudEvent(taskId, processId, processInstanceId, null, null, state); CompletableFuture.allOf( @@ -583,7 +583,7 @@ void testProcessInstanceDomainIndex() throws Exception { .when().post("/graphql") .then().log().ifValidationFails().statusCode(200).body("data.Travels", isA(Collection.class)); - ProcessInstanceDataEvent startEvent = getProcessCloudEvent(processId, processInstanceId, ACTIVE, null, null, null); + ProcessInstanceDataEvent startEvent = getProcessCloudEvent(processId, processInstanceId, ACTIVE, null, null, null, "currentUser"); indexProcessCloudEvent(startEvent); validateProcessInstance(getProcessInstanceById(processInstanceId), startEvent); @@ -611,7 +611,7 @@ void testProcessInstanceDomainIndex() throws Exception { .body("data.Travels[0].hotel.name", is("Meriton")) .body("data.Travels[0].traveller.firstName", is("Maciej")); - ProcessInstanceDataEvent endEvent = getProcessCloudEvent(processId, processInstanceId, COMPLETED, null, null, null); + ProcessInstanceDataEvent endEvent = getProcessCloudEvent(processId, processInstanceId, COMPLETED, null, null, null, "currentUser"); endEvent.getData().update().endDate(new Date()); Map variablesMap = getProcessInstanceVariablesMap(); ((Map) variablesMap.get("hotel")).put("name", "Ibis"); @@ -645,13 +645,13 @@ void testProcessInstanceDomainIndex() throws Exception { .body("data.Travels[0].traveller.firstName", is("Maciej")); ProcessInstanceDataEvent event = getProcessCloudEvent(subProcessId, subProcessInstanceId, ACTIVE, processInstanceId, - processId, processInstanceId); + processId, processInstanceId, "currentUser"); indexProcessCloudEvent(event); validateProcessInstance(getProcessInstanceByParentProcessInstanceId(processInstanceId), event); ProcessInstanceDataEvent errorEvent = getProcessCloudEvent(subProcessId, subProcessInstanceId, ERROR, processInstanceId, - processId, processInstanceId); + processId, processInstanceId, "currentUser"); indexProcessCloudEvent(errorEvent); validateProcessInstance( diff --git a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/AbstractIndexingServiceIT.java b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/AbstractIndexingServiceIT.java index c911150057..97deb3d1c9 100644 --- a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/AbstractIndexingServiceIT.java +++ b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/AbstractIndexingServiceIT.java @@ -60,30 +60,7 @@ import static org.kie.kogito.index.model.ProcessInstanceState.ACTIVE; import static org.kie.kogito.index.model.ProcessInstanceState.COMPLETED; import static org.kie.kogito.index.model.ProcessInstanceState.ERROR; -import static org.kie.kogito.index.service.GraphQLUtils.getJobById; -import static org.kie.kogito.index.service.GraphQLUtils.getProcessInstanceByBusinessKey; -import static org.kie.kogito.index.service.GraphQLUtils.getProcessInstanceById; -import static org.kie.kogito.index.service.GraphQLUtils.getProcessInstanceByIdAndAddon; -import static org.kie.kogito.index.service.GraphQLUtils.getProcessInstanceByIdAndErrorNode; -import static org.kie.kogito.index.service.GraphQLUtils.getProcessInstanceByIdAndMilestoneName; -import static org.kie.kogito.index.service.GraphQLUtils.getProcessInstanceByIdAndMilestoneStatus; -import static org.kie.kogito.index.service.GraphQLUtils.getProcessInstanceByIdAndNullParentProcessInstanceId; -import static org.kie.kogito.index.service.GraphQLUtils.getProcessInstanceByIdAndNullRootProcessInstanceId; -import static org.kie.kogito.index.service.GraphQLUtils.getProcessInstanceByIdAndParentProcessInstanceId; -import static org.kie.kogito.index.service.GraphQLUtils.getProcessInstanceByIdAndProcessId; -import static org.kie.kogito.index.service.GraphQLUtils.getProcessInstanceByIdAndStart; -import static org.kie.kogito.index.service.GraphQLUtils.getProcessInstanceByIdAndState; -import static org.kie.kogito.index.service.GraphQLUtils.getProcessInstanceByParentProcessInstanceId; -import static org.kie.kogito.index.service.GraphQLUtils.getProcessInstanceByRootProcessInstanceId; -import static org.kie.kogito.index.service.GraphQLUtils.getUserTaskInstanceById; -import static org.kie.kogito.index.service.GraphQLUtils.getUserTaskInstanceByIdAndActualOwner; -import static org.kie.kogito.index.service.GraphQLUtils.getUserTaskInstanceByIdAndCompleted; -import static org.kie.kogito.index.service.GraphQLUtils.getUserTaskInstanceByIdAndPotentialGroups; -import static org.kie.kogito.index.service.GraphQLUtils.getUserTaskInstanceByIdAndPotentialUsers; -import static org.kie.kogito.index.service.GraphQLUtils.getUserTaskInstanceByIdAndProcessId; -import static org.kie.kogito.index.service.GraphQLUtils.getUserTaskInstanceByIdAndStarted; -import static org.kie.kogito.index.service.GraphQLUtils.getUserTaskInstanceByIdAndState; -import static org.kie.kogito.index.service.GraphQLUtils.getUserTaskInstanceByIdNoActualOwner; +import static org.kie.kogito.index.service.GraphQLUtils.*; public abstract class AbstractIndexingServiceIT extends AbstractIndexingIT { @@ -176,7 +153,7 @@ void testProcessInstancePagination() { IntStream.range(0, 100).forEach(i -> { String pId = UUID.randomUUID().toString(); - ProcessInstanceDataEvent startEvent = getProcessCloudEvent(processId, pId, ACTIVE, null, null, null); + ProcessInstanceDataEvent startEvent = getProcessCloudEvent(processId, pId, ACTIVE, null, null, null, "currentUser"); indexProcessCloudEvent(startEvent); pIds.add(pId); await() @@ -269,7 +246,7 @@ void testProcessInstanceIndex() throws Exception { String subProcessId = processId + "_sub"; String subProcessInstanceId = UUID.randomUUID().toString(); - ProcessInstanceDataEvent startEvent = getProcessCloudEvent(processId, processInstanceId, ACTIVE, null, null, null); + ProcessInstanceDataEvent startEvent = getProcessCloudEvent(processId, processInstanceId, ACTIVE, null, null, null, "currentUser"); indexProcessCloudEvent(startEvent); validateProcessInstance(getProcessInstanceById(processInstanceId), startEvent); @@ -283,8 +260,9 @@ void testProcessInstanceIndex() throws Exception { validateProcessInstance(getProcessInstanceByIdAndMilestoneStatus(processInstanceId, MilestoneStatus.AVAILABLE.name()), startEvent); validateProcessInstance(getProcessInstanceByBusinessKey(startEvent.getData().getBusinessKey()), startEvent); + validateProcessInstance(getProcessInstanceByIdentity(startEvent.getKogitoIdentity()), startEvent); - ProcessInstanceDataEvent endEvent = getProcessCloudEvent(processId, processInstanceId, COMPLETED, null, null, null); + ProcessInstanceDataEvent endEvent = getProcessCloudEvent(processId, processInstanceId, COMPLETED, null, null, null, "currentUser"); endEvent.getData().update().endDate(new Date()); Map variablesMap = getProcessInstanceVariablesMap(); ((Map) variablesMap.get("hotel")).put("name", "Ibis"); @@ -297,7 +275,7 @@ void testProcessInstanceIndex() throws Exception { validateProcessInstance(getProcessInstanceByIdAndMilestoneStatus(processInstanceId, MilestoneStatus.COMPLETED.name()), endEvent); ProcessInstanceDataEvent event = getProcessCloudEvent(subProcessId, subProcessInstanceId, ACTIVE, processInstanceId, - processId, processInstanceId); + processId, processInstanceId, "currentUser"); indexProcessCloudEvent(event); validateProcessInstance(getProcessInstanceByParentProcessInstanceId(processInstanceId), event); @@ -311,7 +289,7 @@ void testProcessInstanceIndex() throws Exception { event); ProcessInstanceDataEvent errorEvent = getProcessCloudEvent(subProcessId, subProcessInstanceId, ERROR, processInstanceId, - processId, processInstanceId); + processId, processInstanceId, "currentUser"); indexProcessCloudEvent(errorEvent); validateProcessInstance( diff --git a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/GraphQLUtils.java b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/GraphQLUtils.java index 6026abaf57..889e682a32 100644 --- a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/GraphQLUtils.java +++ b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/GraphQLUtils.java @@ -127,6 +127,10 @@ public static String getProcessInstanceByBusinessKey(String businessKeys) { return getProcessInstanceQuery("ProcessInstanceByBusinessKey", businessKeys); } + public static String getProcessInstanceByIdentity(String identity) { + return getProcessInstanceQuery("ProcessInstanceByIdentity", identity); + } + public static String getUserTaskInstanceById(String id) { return getUserTaskInstanceQuery("UserTaskInstanceById", id); } diff --git a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/graphql/AbstractWebSocketSubscriptionIT.java b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/graphql/AbstractWebSocketSubscriptionIT.java index 5ea7277153..3578d9fc88 100644 --- a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/graphql/AbstractWebSocketSubscriptionIT.java +++ b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/graphql/AbstractWebSocketSubscriptionIT.java @@ -148,7 +148,7 @@ private void assertDomainSubscription(String processId, String processInstanceId .when().post("/graphql") .then().log().ifValidationFails().statusCode(200).body("data.Travels", isA(Collection.class)); - ProcessInstanceDataEvent event = getProcessCloudEvent(processId, processInstanceId, state, null, null, null); + ProcessInstanceDataEvent event = getProcessCloudEvent(processId, processInstanceId, state, null, null, null, "currentUser"); indexProcessCloudEvent(event); JsonObject json = cf.get(1, TimeUnit.MINUTES); @@ -167,7 +167,7 @@ private void assertProcessInstanceSubscription(String processId, String processI .when().post("/graphql") .then().log().ifValidationFails().statusCode(200).body("data.Travels", isA(Collection.class)); - ProcessInstanceDataEvent event = getProcessCloudEvent(processId, processInstanceId, state, null, null, null); + ProcessInstanceDataEvent event = getProcessCloudEvent(processId, processInstanceId, state, null, null, null, "currentUser"); indexProcessCloudEvent(event); JsonObject json = cf.get(1, TimeUnit.MINUTES); diff --git a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/graphql/query/AbstractGraphQLRuntimesQueriesIT.java b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/graphql/query/AbstractGraphQLRuntimesQueriesIT.java index 95af0e64b0..26f4639c23 100644 --- a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/graphql/query/AbstractGraphQLRuntimesQueriesIT.java +++ b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/graphql/query/AbstractGraphQLRuntimesQueriesIT.java @@ -78,7 +78,7 @@ public void setup() throws Exception { @Test void testProcessInstanceAbort() { String processInstanceId = UUID.randomUUID().toString(); - ProcessInstanceDataEvent startEvent = getProcessCloudEvent(processId, processInstanceId, ACTIVE, null, null, null); + ProcessInstanceDataEvent startEvent = getProcessCloudEvent(processId, processInstanceId, ACTIVE, null, null, null, "currentUser"); indexProcessCloudEvent(startEvent); checkOkResponse("{ \"query\" : \"mutation{ ProcessInstanceAbort ( id: \\\"" + processInstanceId + "\\\")}\"}"); @@ -90,7 +90,7 @@ void testProcessInstanceAbort() { @Test void testProcessInstanceRetry() { String processInstanceId = UUID.randomUUID().toString(); - ProcessInstanceDataEvent startEvent = getProcessCloudEvent(processId, processInstanceId, ACTIVE, null, null, null); + ProcessInstanceDataEvent startEvent = getProcessCloudEvent(processId, processInstanceId, ACTIVE, null, null, null, "currentUser"); indexProcessCloudEvent(startEvent); checkOkResponse("{ \"query\" : \"mutation{ ProcessInstanceRetry ( id: \\\"" + processInstanceId + "\\\")}\"}"); @@ -102,7 +102,7 @@ void testProcessInstanceRetry() { @Test void testProcessInstanceSkip() { String processInstanceId = UUID.randomUUID().toString(); - ProcessInstanceDataEvent startEvent = getProcessCloudEvent(processId, processInstanceId, ACTIVE, null, null, null); + ProcessInstanceDataEvent startEvent = getProcessCloudEvent(processId, processInstanceId, ACTIVE, null, null, null, "currentUser"); indexProcessCloudEvent(startEvent); checkOkResponse("{ \"query\" : \"mutation{ ProcessInstanceSkip ( id: \\\"" + processInstanceId + "\\\")}\"}"); @@ -116,7 +116,7 @@ void testProcessInstanceUpdateVariables() { String variablesUpdated = "variablesUpdated"; String processInstanceId = UUID.randomUUID().toString(); - ProcessInstanceDataEvent startEvent = getProcessCloudEvent(processId, processInstanceId, ACTIVE, null, null, null); + ProcessInstanceDataEvent startEvent = getProcessCloudEvent(processId, processInstanceId, ACTIVE, null, null, null, "currentUser"); indexProcessCloudEvent(startEvent); checkOkResponse("{ \"query\" : \"mutation{ ProcessInstanceUpdateVariables ( id: \\\"" + processInstanceId + "\\\", variables: \\\"" + variablesUpdated + "\\\")}\"}"); @@ -128,7 +128,7 @@ void testProcessInstanceUpdateVariables() { @Test void testProcessInstanceNodeDefinitions() { String processInstanceId = UUID.randomUUID().toString(); - ProcessInstanceDataEvent startEvent = getProcessCloudEvent(processId, processInstanceId, ACTIVE, null, null, null); + ProcessInstanceDataEvent startEvent = getProcessCloudEvent(processId, processInstanceId, ACTIVE, null, null, null, "currentUser"); indexProcessCloudEvent(startEvent); checkOkResponse("{ \"query\" : \"query { ProcessInstances (where: { id: {equal: \\\"" + processInstanceId + "\\\"}}) { nodeDefinitions { id }} }\" }"); @@ -139,7 +139,7 @@ void testProcessInstanceNodeDefinitions() { @Test void testProcessInstanceDiagram() { String processInstanceId = UUID.randomUUID().toString(); - ProcessInstanceDataEvent startEvent = getProcessCloudEvent(processId, processInstanceId, ACTIVE, null, null, null); + ProcessInstanceDataEvent startEvent = getProcessCloudEvent(processId, processInstanceId, ACTIVE, null, null, null, "currentUser"); indexProcessCloudEvent(startEvent); checkOkResponse("{ \"query\" : \"query { ProcessInstances (where: { id: {equal: \\\"" + processInstanceId + "\\\"}}) {diagram} }\" }"); @@ -151,7 +151,7 @@ void testProcessInstanceDiagram() { @Test void testProcessInstanceSource() { String processInstanceId = UUID.randomUUID().toString(); - ProcessInstanceDataEvent startEvent = getProcessCloudEvent(processId, processInstanceId, ACTIVE, null, null, null); + ProcessInstanceDataEvent startEvent = getProcessCloudEvent(processId, processInstanceId, ACTIVE, null, null, null, "currentUser"); indexProcessCloudEvent(startEvent); checkOkResponse("{ \"query\" : \"query { ProcessInstances (where: { id: {equal: \\\"" + processInstanceId + "\\\"}}) {source} }\" }"); @@ -164,7 +164,7 @@ void testProcessInstanceSource() { void testNodeInstanceTrigger() { String nodeId = "nodeIdToTrigger"; String processInstanceId = UUID.randomUUID().toString(); - ProcessInstanceDataEvent startEvent = getProcessCloudEvent(processId, processInstanceId, ACTIVE, null, null, null); + ProcessInstanceDataEvent startEvent = getProcessCloudEvent(processId, processInstanceId, ACTIVE, null, null, null, "currentUser"); indexProcessCloudEvent(startEvent); checkOkResponse("{ \"query\" : \"mutation{ NodeInstanceTrigger ( id: \\\"" + processInstanceId + "\\\", nodeId: \\\"" + nodeId + "\\\")}\"}"); @@ -177,7 +177,7 @@ void testNodeInstanceTrigger() { void testNodeInstanceRetrigger() { String nodeInstanceId = "nodeInstanceIdToRetrigger"; String processInstanceId = UUID.randomUUID().toString(); - ProcessInstanceDataEvent startEvent = getProcessCloudEvent(processId, processInstanceId, ACTIVE, null, null, null); + ProcessInstanceDataEvent startEvent = getProcessCloudEvent(processId, processInstanceId, ACTIVE, null, null, null, "currentUser"); indexProcessCloudEvent(startEvent); checkOkResponse("{ \"query\" : \"mutation{ NodeInstanceRetrigger ( id: \\\"" + processInstanceId + "\\\", nodeInstanceId: \\\"" + nodeInstanceId + "\\\")}\"}"); @@ -190,7 +190,7 @@ void testNodeInstanceRetrigger() { void testNodeInstanceCancel() { String nodeInstanceId = "nodeInstanceIdToCancel"; String processInstanceId = UUID.randomUUID().toString(); - ProcessInstanceDataEvent startEvent = getProcessCloudEvent(processId, processInstanceId, ACTIVE, null, null, null); + ProcessInstanceDataEvent startEvent = getProcessCloudEvent(processId, processInstanceId, ACTIVE, null, null, null, "currentUser"); indexProcessCloudEvent(startEvent); checkOkResponse("{ \"query\" : \"mutation{ NodeInstanceCancel ( id: \\\"" + processInstanceId + "\\\", nodeInstanceId: \\\"" + nodeInstanceId + "\\\")}\"}"); diff --git a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/AbstractDomainMessagingHttpConsumerIT.java b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/AbstractDomainMessagingHttpConsumerIT.java index b28e550146..d5b9fd7fa5 100644 --- a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/AbstractDomainMessagingHttpConsumerIT.java +++ b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/AbstractDomainMessagingHttpConsumerIT.java @@ -45,7 +45,7 @@ protected void sendUserTaskInstanceEvent() throws Exception { protected void sendProcessInstanceEvent() throws Exception { ProcessInstanceDataEvent event = getProcessCloudEvent("travels", "2308e23d-9998-47e9-a772-a078cf5b891b", ProcessInstanceState.ACTIVE, null, - null, null); + null, null, "currentUser"); connector.source(KOGITO_PROCESSINSTANCES_EVENTS).send(event); } diff --git a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/AbstractMessagingHttpConsumerIT.java b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/AbstractMessagingHttpConsumerIT.java index 5acf897b25..e5bb163c11 100644 --- a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/AbstractMessagingHttpConsumerIT.java +++ b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/AbstractMessagingHttpConsumerIT.java @@ -44,7 +44,7 @@ protected void sendUserTaskInstanceEvent() throws Exception { protected void sendProcessInstanceEvent() throws Exception { ProcessInstanceDataEvent event = getProcessCloudEvent("travels", "2308e23d-9998-47e9-a772-a078cf5b891b", ProcessInstanceState.ACTIVE, null, - null, null); + null, null, "currentUser"); connector.source(KOGITO_PROCESSINSTANCES_EVENTS).send(event); } diff --git a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/AbstractMessagingLoadKafkaIT.java b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/AbstractMessagingLoadKafkaIT.java index b63a883d0f..eab8bc90e6 100644 --- a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/AbstractMessagingLoadKafkaIT.java +++ b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/AbstractMessagingLoadKafkaIT.java @@ -106,7 +106,7 @@ void testMessagingEvents() { String processInstanceId = UUID.randomUUID().toString(); String taskId = UUID.randomUUID().toString(); - ProcessInstanceDataEvent startEvent = getProcessCloudEvent(processId, processInstanceId, ACTIVE, null, null, null); + ProcessInstanceDataEvent startEvent = getProcessCloudEvent(processId, processInstanceId, ACTIVE, null, null, null, "currentUser"); sendProcessInstanceEvent(client, startEvent); @@ -116,7 +116,7 @@ void testMessagingEvents() { userTaskEvent = getUserTaskCloudEvent(taskId, processId, processInstanceId, null, null, "Completed"); sendUserTaskEvent(client, userTaskEvent); - ProcessInstanceDataEvent endEvent = getProcessCloudEvent(processId, processInstanceId, COMPLETED, null, null, null); + ProcessInstanceDataEvent endEvent = getProcessCloudEvent(processId, processInstanceId, COMPLETED, null, null, null, "currentUser"); sendProcessInstanceEvent(client, endEvent); return processInstanceId; diff --git a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/DomainEventConsumerTest.java b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/DomainEventConsumerTest.java index 6b9346b7c9..3cbb79513b 100644 --- a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/DomainEventConsumerTest.java +++ b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/DomainEventConsumerTest.java @@ -115,7 +115,7 @@ public void testOnProcessInstanceDomainEventIndexingException() { String processInstanceId = UUID.randomUUID().toString(); ProcessInstanceDataEvent event = getProcessCloudEvent(processId, processInstanceId, ProcessInstanceState.ACTIVE, null, - null, null); + null, null, "currentUser"); assertThatExceptionOfType(RuntimeException.class).isThrownBy(() -> consumer.onDomainEvent(event)); verify(service).indexModel(any()); diff --git a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/ReactiveMessagingEventConsumerTest.java b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/ReactiveMessagingEventConsumerTest.java index 9796b85019..d668a6f349 100644 --- a/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/ReactiveMessagingEventConsumerTest.java +++ b/data-index/data-index-service/data-index-service-common/src/test/java/org/kie/kogito/index/service/messaging/ReactiveMessagingEventConsumerTest.java @@ -61,7 +61,7 @@ public void testOnProcessInstanceEvent() { String processInstanceId = UUID.randomUUID().toString(); ProcessInstanceDataEvent event = getProcessCloudEvent(processId, processInstanceId, ProcessInstanceState.ACTIVE, null, - null, null); + null, null, "currentUser"); UniAssertSubscriber future = consumer.onProcessInstanceEvent(event).subscribe() .withSubscriber(UniAssertSubscriber.create()); diff --git a/data-index/data-index-service/data-index-service-common/src/test/resources/graphql_queries.json b/data-index/data-index-service/data-index-service-common/src/test/resources/graphql_queries.json index 6f0f723967..00835085bf 100644 --- a/data-index/data-index-service/data-index-service-common/src/test/resources/graphql_queries.json +++ b/data-index/data-index-service/data-index-service-common/src/test/resources/graphql_queries.json @@ -93,6 +93,12 @@ "bk": "%s" } }, + "ProcessInstanceByIdentity": { + "query": "query ( $ident: String ) { ProcessInstances(where: { identity : { equal : $ident } }) { %s } }", + "variables": { + "ident": "%s" + } + }, "UserTaskInstanceById": { "query": "query ( $id: String ) { UserTaskInstances( where: { id: { equal : $id } } ){ %s } }", "variables": { diff --git a/data-index/data-index-service/data-index-service-oracle/src/main/resources/application.properties b/data-index/data-index-service/data-index-service-oracle/src/main/resources/application.properties index bf3355c458..7cd7a6ab9d 100644 --- a/data-index/data-index-service/data-index-service-oracle/src/main/resources/application.properties +++ b/data-index/data-index-service/data-index-service-oracle/src/main/resources/application.properties @@ -16,3 +16,5 @@ quarkus.hibernate-orm.physical-naming-strategy=org.hibernate.boot.model.naming.C quarkus.container-image.build=${quarkus.build.image:true} quarkus.container-image.group=org.kie.kogito quarkus.jib.jvm-arguments=-Dquarkus.http.port=8080 + +quarkus.flyway.baseline-on-migrate=true diff --git a/data-index/data-index-storage/data-index-storage-api/src/main/java/org/kie/kogito/index/model/ProcessInstanceMeta.java b/data-index/data-index-storage/data-index-storage-api/src/main/java/org/kie/kogito/index/model/ProcessInstanceMeta.java index 2ca51c1cfc..897aa7fc24 100644 --- a/data-index/data-index-storage/data-index-storage-api/src/main/java/org/kie/kogito/index/model/ProcessInstanceMeta.java +++ b/data-index/data-index-storage/data-index-storage-api/src/main/java/org/kie/kogito/index/model/ProcessInstanceMeta.java @@ -39,6 +39,8 @@ public class ProcessInstanceMeta { private String rootProcessId; @JsonProperty("parentInstanceId") private String parentProcessInstanceId; + @JsonProperty("identity") + private String identity; private ZonedDateTime lastUpdate; public String getId() { @@ -153,6 +155,14 @@ public void setLastUpdate(ZonedDateTime lastUpdate) { this.lastUpdate = lastUpdate; } + public String getIdentity() { + return identity; + } + + public void setIdentity(String identity) { + this.identity = identity; + } + @Override public String toString() { return "ProcessInstanceMeta{" + @@ -169,6 +179,7 @@ public String toString() { ", rootProcessId='" + rootProcessId + '\'' + ", parentProcessInstanceId='" + parentProcessInstanceId + '\'' + ", lastUpdated=" + lastUpdate + + ", identity=" + identity + '}'; } diff --git a/data-index/data-index-storage/data-index-storage-infinispan/src/main/java/org/kie/kogito/index/infinispan/protostream/ProcessInstanceMarshaller.java b/data-index/data-index-storage/data-index-storage-infinispan/src/main/java/org/kie/kogito/index/infinispan/protostream/ProcessInstanceMarshaller.java index 15a13cd24e..2c514429e2 100644 --- a/data-index/data-index-storage/data-index-storage-infinispan/src/main/java/org/kie/kogito/index/infinispan/protostream/ProcessInstanceMarshaller.java +++ b/data-index/data-index-storage/data-index-storage-infinispan/src/main/java/org/kie/kogito/index/infinispan/protostream/ProcessInstanceMarshaller.java @@ -49,6 +49,7 @@ public class ProcessInstanceMarshaller extends AbstractMarshaller implements Mes protected static final String LAST_UPDATE = "lastUpdate"; protected static final String BUSINESS_KEY = "businessKey"; protected static final String MILESTONES = "milestones"; + protected static final String IDENTITY = "identity"; public ProcessInstanceMarshaller(ObjectMapper mapper) { super(mapper); @@ -75,6 +76,7 @@ public ProcessInstance readFrom(ProtoStreamReader reader) throws IOException { pi.setLastUpdate(dateToZonedDateTime(reader.readDate(LAST_UPDATE))); pi.setBusinessKey(reader.readString(BUSINESS_KEY)); pi.setMilestones(reader.readCollection(MILESTONES, new ArrayList<>(), Milestone.class)); + pi.setIdentity(reader.readString(IDENTITY)); return pi; } @@ -98,6 +100,7 @@ public void writeTo(ProtoStreamWriter writer, ProcessInstance pi) throws IOExcep writer.writeDate(LAST_UPDATE, zonedDateTimeToDate(pi.getLastUpdate())); writer.writeString(BUSINESS_KEY, pi.getBusinessKey()); writer.writeCollection(MILESTONES, pi.getMilestones(), Milestone.class); + writer.writeString(IDENTITY, pi.getIdentity()); } @Override diff --git a/data-index/data-index-storage/data-index-storage-infinispan/src/test/java/org/kie/kogito/index/infinispan/protostream/ProcessInstanceMarshallerTest.java b/data-index/data-index-storage/data-index-storage-infinispan/src/test/java/org/kie/kogito/index/infinispan/protostream/ProcessInstanceMarshallerTest.java index 6c8a59f5f9..111d84ed21 100644 --- a/data-index/data-index-storage/data-index-storage-infinispan/src/test/java/org/kie/kogito/index/infinispan/protostream/ProcessInstanceMarshallerTest.java +++ b/data-index/data-index-storage/data-index-storage-infinispan/src/test/java/org/kie/kogito/index/infinispan/protostream/ProcessInstanceMarshallerTest.java @@ -34,24 +34,7 @@ import static java.util.Collections.emptyList; import static java.util.Collections.singleton; import static org.assertj.core.api.Assertions.assertThat; -import static org.kie.kogito.index.infinispan.protostream.ProcessInstanceMarshaller.ADDONS; -import static org.kie.kogito.index.infinispan.protostream.ProcessInstanceMarshaller.BUSINESS_KEY; -import static org.kie.kogito.index.infinispan.protostream.ProcessInstanceMarshaller.END; -import static org.kie.kogito.index.infinispan.protostream.ProcessInstanceMarshaller.ENDPOINT; -import static org.kie.kogito.index.infinispan.protostream.ProcessInstanceMarshaller.ERROR; -import static org.kie.kogito.index.infinispan.protostream.ProcessInstanceMarshaller.ID; -import static org.kie.kogito.index.infinispan.protostream.ProcessInstanceMarshaller.LAST_UPDATE; -import static org.kie.kogito.index.infinispan.protostream.ProcessInstanceMarshaller.MILESTONES; -import static org.kie.kogito.index.infinispan.protostream.ProcessInstanceMarshaller.NODES; -import static org.kie.kogito.index.infinispan.protostream.ProcessInstanceMarshaller.PARENT_PROCESS_INSTANCE_ID; -import static org.kie.kogito.index.infinispan.protostream.ProcessInstanceMarshaller.PROCESS_ID; -import static org.kie.kogito.index.infinispan.protostream.ProcessInstanceMarshaller.PROCESS_NAME; -import static org.kie.kogito.index.infinispan.protostream.ProcessInstanceMarshaller.ROLES; -import static org.kie.kogito.index.infinispan.protostream.ProcessInstanceMarshaller.ROOT_PROCESS_ID; -import static org.kie.kogito.index.infinispan.protostream.ProcessInstanceMarshaller.ROOT_PROCESS_INSTANCE_ID; -import static org.kie.kogito.index.infinispan.protostream.ProcessInstanceMarshaller.START; -import static org.kie.kogito.index.infinispan.protostream.ProcessInstanceMarshaller.STATE; -import static org.kie.kogito.index.infinispan.protostream.ProcessInstanceMarshaller.VARIABLES; +import static org.kie.kogito.index.infinispan.protostream.ProcessInstanceMarshaller.*; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.inOrder; @@ -82,6 +65,7 @@ void testReadFrom() throws IOException { when(reader.readDate(LAST_UPDATE)).thenReturn(now); when(reader.readString(BUSINESS_KEY)).thenReturn("businessKey"); when(reader.readCollection(eq(MILESTONES), any(), eq(Milestone.class))).thenReturn(new ArrayList<>()); + when(reader.readString(IDENTITY)).thenReturn("currentUser"); ProcessInstanceMarshaller marshaller = new ProcessInstanceMarshaller(null); ProcessInstance pi = marshaller.readFrom(reader); @@ -105,7 +89,8 @@ void testReadFrom() throws IOException { .hasFieldOrPropertyWithValue(ERROR, null) .hasFieldOrPropertyWithValue(LAST_UPDATE, marshaller.dateToZonedDateTime(now)) .hasFieldOrPropertyWithValue(BUSINESS_KEY, "businessKey") - .hasFieldOrPropertyWithValue(MILESTONES, emptyList()); + .hasFieldOrPropertyWithValue(MILESTONES, emptyList()) + .hasFieldOrPropertyWithValue(IDENTITY, "currentUser"); InOrder inOrder = inOrder(reader); inOrder.verify(reader).readString(ID); @@ -126,6 +111,7 @@ void testReadFrom() throws IOException { inOrder.verify(reader).readDate(LAST_UPDATE); inOrder.verify(reader).readString(BUSINESS_KEY); inOrder.verify(reader).readCollection(MILESTONES, new ArrayList<>(), Milestone.class); + inOrder.verify(reader).readString(IDENTITY); } @Test @@ -145,6 +131,7 @@ void testWriteTo() throws IOException { pi.setStart(ZonedDateTime.now()); pi.setError(new ProcessInstanceError("StartEvent_1", "Something went wrong")); pi.setMilestones(emptyList()); + pi.setIdentity("currentUser"); MessageMarshaller.ProtoStreamWriter writer = mock(MessageMarshaller.ProtoStreamWriter.class); @@ -170,5 +157,6 @@ void testWriteTo() throws IOException { inOrder.verify(writer).writeDate(LAST_UPDATE, marshaller.zonedDateTimeToDate(pi.getLastUpdate())); inOrder.verify(writer).writeString(BUSINESS_KEY, pi.getBusinessKey()); inOrder.verify(writer).writeCollection(MILESTONES, pi.getMilestones(), Milestone.class); + inOrder.verify(writer).writeString(IDENTITY, pi.getIdentity()); } } diff --git a/data-index/data-index-storage/data-index-storage-mongodb/src/main/java/org/kie/kogito/index/mongodb/model/ProcessInstanceEntity.java b/data-index/data-index-storage/data-index-storage-mongodb/src/main/java/org/kie/kogito/index/mongodb/model/ProcessInstanceEntity.java index 347a29f52b..8f260927ac 100644 --- a/data-index/data-index-storage/data-index-storage-mongodb/src/main/java/org/kie/kogito/index/mongodb/model/ProcessInstanceEntity.java +++ b/data-index/data-index-storage/data-index-storage-mongodb/src/main/java/org/kie/kogito/index/mongodb/model/ProcessInstanceEntity.java @@ -62,6 +62,8 @@ public class ProcessInstanceEntity { List milestones; + String identity; + public String getId() { return id; } @@ -206,6 +208,14 @@ public void setMilestones(List milestones) { this.milestones = milestones; } + public String getIdentity() { + return identity; + } + + public void setIdentity(String identity) { + this.identity = identity; + } + @Override public boolean equals(Object o) { if (this == o) { diff --git a/data-index/data-index-storage/data-index-storage-mongodb/src/main/java/org/kie/kogito/index/mongodb/model/ProcessInstanceEntityMapper.java b/data-index/data-index-storage/data-index-storage-mongodb/src/main/java/org/kie/kogito/index/mongodb/model/ProcessInstanceEntityMapper.java index c167809f86..cf946d052f 100644 --- a/data-index/data-index-storage/data-index-storage-mongodb/src/main/java/org/kie/kogito/index/mongodb/model/ProcessInstanceEntityMapper.java +++ b/data-index/data-index-storage/data-index-storage-mongodb/src/main/java/org/kie/kogito/index/mongodb/model/ProcessInstanceEntityMapper.java @@ -72,6 +72,7 @@ public ProcessInstanceEntity mapToEntity(String key, ProcessInstance instance) { entity.setLastUpdate(zonedDateTimeToInstant(instance.getLastUpdate())); entity.setBusinessKey(instance.getBusinessKey()); entity.setMilestones(Optional.ofNullable(instance.getMilestones()).map(milestones -> milestones.stream().map(this::fromMilestone).collect(toList())).orElse(null)); + entity.setIdentity(instance.getIdentity()); return entity; } @@ -100,6 +101,7 @@ public ProcessInstance mapToModel(ProcessInstanceEntity entity) { instance.setLastUpdate(instantToZonedDateTime(entity.getLastUpdate())); instance.setBusinessKey(entity.getBusinessKey()); instance.setMilestones(Optional.ofNullable(entity.getMilestones()).map(milesteons -> milesteons.stream().map(this::toMilestone).collect(toList())).orElse(null)); + instance.setIdentity(entity.getIdentity()); return instance; } diff --git a/data-index/data-index-storage/data-index-storage-mongodb/src/test/java/org/kie/kogito/index/mongodb/model/ProcessInstanceEntityMapperTest.java b/data-index/data-index-storage/data-index-storage-mongodb/src/test/java/org/kie/kogito/index/mongodb/model/ProcessInstanceEntityMapperTest.java index 4d63c4673e..7f8e36603a 100644 --- a/data-index/data-index-storage/data-index-storage-mongodb/src/test/java/org/kie/kogito/index/mongodb/model/ProcessInstanceEntityMapperTest.java +++ b/data-index/data-index-storage/data-index-storage-mongodb/src/test/java/org/kie/kogito/index/mongodb/model/ProcessInstanceEntityMapperTest.java @@ -73,6 +73,7 @@ static void setup() { String processName = "testProcessName"; Set addons = Set.of("testAddons"); String businessKey = "testBusinessKey"; + String identity = "testIdentity"; NodeInstance nodeInstance = new NodeInstance(); nodeInstance.setId(nodeInstanceId); @@ -111,6 +112,7 @@ static void setup() { processInstance.setLastUpdate(time); processInstance.setBusinessKey(businessKey); processInstance.setMilestones(List.of(milestone)); + processInstance.setIdentity(identity); ProcessInstanceEntity.NodeInstanceEntity nodeInstanceEntity = new ProcessInstanceEntity.NodeInstanceEntity(); nodeInstanceEntity.setId(nodeInstanceId); @@ -149,6 +151,7 @@ static void setup() { processInstanceEntity.setLastUpdate(zonedDateTimeToInstant(time)); processInstanceEntity.setBusinessKey(businessKey); processInstanceEntity.setMilestones(List.of(milestoneEntity)); + processInstanceEntity.setIdentity(identity); } @Test diff --git a/data-index/data-index-storage/data-index-storage-oracle/src/main/java/org/kie/kogito/index/oracle/model/ProcessInstanceEntity.java b/data-index/data-index-storage/data-index-storage-oracle/src/main/java/org/kie/kogito/index/oracle/model/ProcessInstanceEntity.java index 73d1c94268..fefc25b80b 100644 --- a/data-index/data-index-storage/data-index-storage-oracle/src/main/java/org/kie/kogito/index/oracle/model/ProcessInstanceEntity.java +++ b/data-index/data-index-storage/data-index-storage-oracle/src/main/java/org/kie/kogito/index/oracle/model/ProcessInstanceEntity.java @@ -68,6 +68,7 @@ public class ProcessInstanceEntity extends AbstractEntity { private String parentProcessInstanceId; @Column(name = "lastUpdateTime") private ZonedDateTime lastUpdate; + private String identity; @Type(type = "jsonb") private ObjectNode variables; @OneToMany(cascade = CascadeType.ALL, mappedBy = "processInstance") @@ -188,6 +189,14 @@ public void setLastUpdate(ZonedDateTime lastUpdate) { this.lastUpdate = lastUpdate; } + public String getIdentity() { + return identity; + } + + public void setIdentity(String identity) { + this.identity = identity; + } + public ObjectNode getVariables() { return variables; } diff --git a/data-index/data-index-storage/data-index-storage-oracle/src/main/resources/db/migration/V1.33.1__add_identity_to_process_instance.sql b/data-index/data-index-storage/data-index-storage-oracle/src/main/resources/db/migration/V1.33.1__add_identity_to_process_instance.sql new file mode 100644 index 0000000000..4a344e922a --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-oracle/src/main/resources/db/migration/V1.33.1__add_identity_to_process_instance.sql @@ -0,0 +1,2 @@ +ALTER TABLE processes + ADD identity varchar(255); \ No newline at end of file diff --git a/data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/mapper/ProcessInstanceEntityMapperIT.java b/data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/mapper/ProcessInstanceEntityMapperIT.java index ee86435234..2b868b1408 100644 --- a/data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/mapper/ProcessInstanceEntityMapperIT.java +++ b/data-index/data-index-storage/data-index-storage-oracle/src/test/java/org/kie/kogito/index/oracle/mapper/ProcessInstanceEntityMapperIT.java @@ -81,6 +81,7 @@ void setup() { String processName = "testProcessName"; Set addons = singleton("testAddons"); String businessKey = "testBusinessKey"; + String identity = "currentUser"; NodeInstance nodeInstance = new NodeInstance(); nodeInstance.setId(nodeInstanceId); @@ -118,6 +119,7 @@ void setup() { processInstance.setLastUpdate(time); processInstance.setBusinessKey(businessKey); processInstance.setMilestones(singletonList(milestone)); + processInstance.setIdentity(identity); NodeInstanceEntity nodeInstanceEntity = new NodeInstanceEntity(); nodeInstanceEntity.setId(nodeInstanceId); @@ -159,6 +161,7 @@ void setup() { processInstanceEntity.setAddons(addons); processInstanceEntity.setLastUpdate(time); processInstanceEntity.setBusinessKey(businessKey); + processInstanceEntity.setIdentity(identity); processInstanceEntity.setMilestones(singletonList(milestoneEntity)); } diff --git a/data-index/data-index-storage/data-index-storage-postgresql/src/main/java/org/kie/kogito/index/postgresql/model/ProcessInstanceEntity.java b/data-index/data-index-storage/data-index-storage-postgresql/src/main/java/org/kie/kogito/index/postgresql/model/ProcessInstanceEntity.java index a50ee0230e..1425dcfdd6 100644 --- a/data-index/data-index-storage/data-index-storage-postgresql/src/main/java/org/kie/kogito/index/postgresql/model/ProcessInstanceEntity.java +++ b/data-index/data-index-storage/data-index-storage-postgresql/src/main/java/org/kie/kogito/index/postgresql/model/ProcessInstanceEntity.java @@ -68,6 +68,7 @@ public class ProcessInstanceEntity extends AbstractEntity { private String parentProcessInstanceId; @Column(name = "lastUpdateTime") private ZonedDateTime lastUpdate; + private String identity; @Type(type = "jsonb") @Column(columnDefinition = "jsonb") private ObjectNode variables; @@ -189,6 +190,14 @@ public void setLastUpdate(ZonedDateTime lastUpdate) { this.lastUpdate = lastUpdate; } + public String getIdentity() { + return identity; + } + + public void setIdentity(String identity) { + this.identity = identity; + } + public ObjectNode getVariables() { return variables; } diff --git a/data-index/data-index-storage/data-index-storage-postgresql/src/main/resources/db/migration/V1.32.1__add_identity_to_process_instance.sql b/data-index/data-index-storage/data-index-storage-postgresql/src/main/resources/db/migration/V1.32.1__add_identity_to_process_instance.sql new file mode 100644 index 0000000000..a726d078c8 --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-postgresql/src/main/resources/db/migration/V1.32.1__add_identity_to_process_instance.sql @@ -0,0 +1,2 @@ +ALTER TABLE processes + ADD COLUMN identity VARCHAR(255); \ No newline at end of file diff --git a/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/mapper/ProcessInstanceEntityMapperIT.java b/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/mapper/ProcessInstanceEntityMapperIT.java index b76c8823df..dc1446f176 100644 --- a/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/mapper/ProcessInstanceEntityMapperIT.java +++ b/data-index/data-index-storage/data-index-storage-postgresql/src/test/java/org/kie/kogito/index/postgresql/mapper/ProcessInstanceEntityMapperIT.java @@ -81,6 +81,7 @@ void setup() { String processName = "testProcessName"; Set addons = singleton("testAddons"); String businessKey = "testBusinessKey"; + String identity = "currentUser"; NodeInstance nodeInstance = new NodeInstance(); nodeInstance.setId(nodeInstanceId); @@ -118,6 +119,7 @@ void setup() { processInstance.setLastUpdate(time); processInstance.setBusinessKey(businessKey); processInstance.setMilestones(singletonList(milestone)); + processInstance.setIdentity(identity); NodeInstanceEntity nodeInstanceEntity = new NodeInstanceEntity(); nodeInstanceEntity.setId(nodeInstanceId); @@ -160,6 +162,7 @@ void setup() { processInstanceEntity.setLastUpdate(time); processInstanceEntity.setBusinessKey(businessKey); processInstanceEntity.setMilestones(singletonList(milestoneEntity)); + processInstanceEntity.setIdentity(identity); } @Test diff --git a/data-index/data-index-storage/data-index-storage-protobuf/src/main/resources/META-INF/kogito-index.proto b/data-index/data-index-storage/data-index-storage-protobuf/src/main/resources/META-INF/kogito-index.proto index f8b0199f1f..3860902b74 100644 --- a/data-index/data-index-storage/data-index-storage-protobuf/src/main/resources/META-INF/kogito-index.proto +++ b/data-index/data-index-storage/data-index-storage-protobuf/src/main/resources/META-INF/kogito-index.proto @@ -36,6 +36,8 @@ message ProcessInstanceMeta { optional int64 lastUpdate = 12; /* @Field(store = Store.YES) */ optional string businessKey = 13; + /* @Field(store = Store.YES) */ + optional string identity = 14; } /* @Indexed */ @@ -73,6 +75,7 @@ message ProcessInstance { /* @Field(store = Store.YES) @SortableField */ optional string businessKey = 17; repeated Milestone milestones = 18; + optional string identity = 19; } /* @Indexed */ diff --git a/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-common/runtime/src/test/java/org/kie/kogito/index/addon/DataIndexEventPublisherTest.java b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-common/runtime/src/test/java/org/kie/kogito/index/addon/DataIndexEventPublisherTest.java index c5061a1db9..014254e7d8 100644 --- a/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-common/runtime/src/test/java/org/kie/kogito/index/addon/DataIndexEventPublisherTest.java +++ b/data-index/kogito-addons-quarkus-data-index/kogito-addons-quarkus-data-index-common/runtime/src/test/java/org/kie/kogito/index/addon/DataIndexEventPublisherTest.java @@ -74,7 +74,7 @@ void onProcessInstanceEvent() throws Exception { ProcessInstance pi = new ProcessInstance(); byte[] jsonContent = getObjectMapper().writeValueAsBytes(pi); ProcessInstanceDataEvent event = getProcessCloudEvent(PROCESS_ID, PROCESS_INSTANCE_ID, COMPLETED, - ROOT_PROCESS_INSTANCE_ID, ROOT_PROCESS_ID, ROOT_PROCESS_INSTANCE_ID); + ROOT_PROCESS_INSTANCE_ID, ROOT_PROCESS_ID, ROOT_PROCESS_INSTANCE_ID, "currentUser"); dataIndexEventPublisher.publish(event);