use of org.kie.kogito.index.model.UserTaskInstance in project kogito-apps by kiegroup.
the class UserTaskInstanceMarshaller method readFrom.
@Override
public UserTaskInstance readFrom(ProtoStreamReader reader) throws IOException {
UserTaskInstance ut = new UserTaskInstance();
ut.setId(reader.readString(ID));
ut.setDescription(reader.readString(DESCRIPTION));
ut.setName(reader.readString(NAME));
ut.setPriority(reader.readString(PRIORITY));
ut.setProcessInstanceId(reader.readString(PROCESS_INSTANCE_ID));
ut.setProcessId(reader.readString(PROCESS_ID));
ut.setRootProcessInstanceId(reader.readString(ROOT_PROCESS_INSTANCE_ID));
ut.setRootProcessId(reader.readString(ROOT_PROCESS_ID));
ut.setState(reader.readString(STATE));
ut.setActualOwner(reader.readString(ACTUAL_OWNER));
ut.setAdminGroups(reader.readCollection(ADMIN_GROUPS, new HashSet<>(), String.class));
ut.setAdminUsers(reader.readCollection(ADMIN_USERS, new HashSet<>(), String.class));
ut.setCompleted(dateToZonedDateTime(reader.readDate(COMPLETED)));
ut.setStarted(dateToZonedDateTime(reader.readDate(STARTED)));
ut.setExcludedUsers(reader.readCollection(EXCLUDED_USERS, new HashSet<>(), String.class));
ut.setPotentialGroups(reader.readCollection(POTENTIAL_GROUPS, new HashSet<>(), String.class));
ut.setPotentialUsers(reader.readCollection(POTENTIAL_USERS, new HashSet<>(), String.class));
ut.setInputs((ObjectNode) jsonFromString(reader.readString(INPUTS)));
ut.setOutputs((ObjectNode) jsonFromString(reader.readString(OUTPUTS)));
ut.setReferenceName(reader.readString(REFERENCE_NAME));
ut.setLastUpdate(dateToZonedDateTime(reader.readDate(LAST_UPDATE)));
ut.setEndpoint(reader.readString(ENDPOINT));
ut.setComments(reader.readCollection(COMMENTS, new ArrayList<>(), Comment.class));
ut.setAttachments(reader.readCollection(ATTACHMENTS, new ArrayList<>(), Attachment.class));
return ut;
}
use of org.kie.kogito.index.model.UserTaskInstance in project kogito-apps by kiegroup.
the class AbstractUserTaskInstanceQueryIT method testUserTaskInstanceQuery.
@Test
void testUserTaskInstanceQuery() {
String taskId1 = UUID.randomUUID().toString();
String processInstanceId1 = UUID.randomUUID().toString();
String taskId2 = UUID.randomUUID().toString();
String processInstanceId2 = UUID.randomUUID().toString();
UserTaskInstance userTaskInstance1 = TestUtils.createUserTaskInstance(taskId1, processInstanceId1, RandomStringUtils.randomAlphabetic(5), UUID.randomUUID().toString(), RandomStringUtils.randomAlphabetic(10), "InProgress", 0L);
UserTaskInstance userTaskInstance2 = TestUtils.createUserTaskInstance(taskId2, processInstanceId2, RandomStringUtils.randomAlphabetic(5), null, null, "Completed", 1000L);
Storage<String, UserTaskInstance> storage = getStorage();
storage.put(taskId1, userTaskInstance1);
storage.put(taskId2, userTaskInstance2);
queryAndAssert(assertWithId(), storage, singletonList(in("state", asList("InProgress", "Completed"))), null, null, null, taskId1, taskId2);
queryAndAssert(assertWithId(), storage, singletonList(equalTo("state", "InProgress")), null, null, null, taskId1);
queryAndAssert(assertWithId(), storage, singletonList(greaterThan("started", getDateTime())), null, null, null);
queryAndAssert(assertWithId(), storage, singletonList(greaterThanEqual("completed", getDateTime(userTaskInstance2.getCompleted()))), null, null, null, taskId2);
queryAndAssert(assertWithId(), storage, singletonList(lessThan("completed", getDateTime())), null, null, null, taskId2);
queryAndAssert(assertWithId(), storage, singletonList(lessThanEqual("started", getDateTime())), null, null, null, taskId1, taskId2);
queryAndAssert(assertWithId(), storage, singletonList(between("completed", getDateTime(userTaskInstance2.getCompleted()), getDateTime())), null, null, null, taskId2);
queryAndAssert(assertWithId(), storage, singletonList(isNull("rootProcessInstanceId")), null, null, null, taskId2);
queryAndAssert(assertWithId(), storage, singletonList(notNull("rootProcessInstanceId")), null, null, null, taskId1);
queryAndAssert(assertWithId(), storage, singletonList(contains("adminUsers", "kogito")), null, null, null, taskId1, taskId2);
queryAndAssert(assertWithId(), storage, singletonList(containsAny("adminGroups", asList("admin", "agroup"))), null, null, null, taskId1, taskId2);
queryAndAssert(assertWithId(), storage, singletonList(containsAll("adminGroups", asList("admin", "agroup"))), null, null, null);
queryAndAssert(assertWithId(), storage, singletonList(like("state", "*ss")), null, null, null, taskId1);
queryAndAssert(assertWithId(), storage, singletonList(and(asList(equalTo("id", taskId1), equalTo("processInstanceId", processInstanceId1)))), null, null, null, taskId1);
queryAndAssert(assertWithId(), storage, singletonList(or(asList(equalTo("id", taskId1), equalTo("id", taskId2)))), null, null, null, taskId1, taskId2);
queryAndAssert(assertWithId(), storage, asList(equalTo("id", taskId1), equalTo("processInstanceId", processInstanceId2)), null, null, null);
queryAndAssert(assertWithIdInOrder(), storage, asList(in("id", asList(taskId1, taskId2)), in("processInstanceId", asList(processInstanceId1, processInstanceId2))), singletonList(orderBy("state", SortDirection.ASC)), 1, 1, taskId1);
queryAndAssert(assertWithIdInOrder(), storage, null, singletonList(orderBy("state", SortDirection.DESC)), null, null, taskId1, taskId2);
queryAndAssert(assertWithIdInOrder(), storage, null, null, 1, 1, taskId2);
queryAndAssert(assertWithIdInOrder(), storage, null, asList(orderBy("state", SortDirection.ASC), orderBy("completed", SortDirection.ASC)), 1, 1, taskId1);
}
use of org.kie.kogito.index.model.UserTaskInstance in project kogito-apps by kiegroup.
the class GraphQLSchemaManager method deleteUserTaskComment.
private CompletableFuture<String> deleteUserTaskComment(DataFetchingEnvironment env) {
Query<UserTaskInstance> query = cacheService.getUserTaskInstancesCache().query();
query.filter(singletonList(equalTo("comments.id", env.getArgument("commentId"))));
UserTaskInstance userTaskInstance = query.execute().get(0);
return dataIndexApiExecutor.deleteUserTaskInstanceComment(getServiceUrl(userTaskInstance.getEndpoint(), userTaskInstance.getProcessId()), userTaskInstance, env.getArgument("user"), env.getArgument("groups"), env.getArgument("commentId"));
}
use of org.kie.kogito.index.model.UserTaskInstance in project kogito-apps by kiegroup.
the class GraphQLSchemaManager method updateUserTaskAttachment.
private CompletableFuture<String> updateUserTaskAttachment(DataFetchingEnvironment env) {
Query<UserTaskInstance> query = cacheService.getUserTaskInstancesCache().query();
query.filter(singletonList(equalTo("attachments.id", env.getArgument("attachmentId"))));
UserTaskInstance userTaskInstance = query.execute().get(0);
return dataIndexApiExecutor.updateUserTaskInstanceAttachment(getServiceUrl(userTaskInstance.getEndpoint(), userTaskInstance.getProcessId()), userTaskInstance, env.getArgument("user"), env.getArgument("groups"), env.getArgument("attachmentId"), env.getArgument("name"), env.getArgument("uri"));
}
use of org.kie.kogito.index.model.UserTaskInstance in project kogito-apps by kiegroup.
the class GraphQLSchemaManager method createSchema.
private GraphQLSchema createSchema() {
InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("schema.graphqls");
SchemaParser schemaParser = new SchemaParser();
TypeDefinitionRegistry typeDefinitionRegistry = schemaParser.parse(new InputStreamReader(stream));
RuntimeWiring runtimeWiring = RuntimeWiring.newRuntimeWiring().type("Query", builder -> {
builder.dataFetcher("ProcessInstances", this::getProcessInstancesValues);
builder.dataFetcher("UserTaskInstances", this::getUserTaskInstancesValues);
builder.dataFetcher("Jobs", this::getJobsValues);
return builder;
}).type("Mutation", builder -> {
builder.dataFetcher("ProcessInstanceAbort", this::abortProcessInstance);
builder.dataFetcher("ProcessInstanceRetry", this::retryProcessInstance);
builder.dataFetcher("ProcessInstanceSkip", this::skipProcessInstance);
builder.dataFetcher("ProcessInstanceUpdateVariables", this::updateProcessInstanceVariables);
builder.dataFetcher("NodeInstanceTrigger", this::triggerNodeInstance);
builder.dataFetcher("NodeInstanceRetrigger", this::retriggerNodeInstance);
builder.dataFetcher("NodeInstanceCancel", this::cancelNodeInstance);
builder.dataFetcher("JobCancel", this::cancelJob);
builder.dataFetcher("JobReschedule", this::rescheduleJob);
builder.dataFetcher("UserTaskInstanceUpdate", this::updateUserTaskInstance);
builder.dataFetcher("UserTaskInstanceCommentCreate", this::createTaskInstanceComment);
builder.dataFetcher("UserTaskInstanceAttachmentCreate", this::createTaskInstanceAttachment);
builder.dataFetcher("UserTaskInstanceCommentUpdate", this::updateUserTaskComment);
builder.dataFetcher("UserTaskInstanceCommentDelete", this::deleteUserTaskComment);
builder.dataFetcher("UserTaskInstanceAttachmentUpdate", this::updateUserTaskAttachment);
builder.dataFetcher("UserTaskInstanceAttachmentDelete", this::deleteUserTaskAttachment);
return builder;
}).type("ProcessInstance", builder -> {
builder.dataFetcher("parentProcessInstance", this::getParentProcessInstanceValue);
builder.dataFetcher("childProcessInstances", this::getChildProcessInstancesValues);
builder.dataFetcher("serviceUrl", this::getProcessInstanceServiceUrl);
builder.dataFetcher("diagram", this::getProcessInstanceDiagram);
builder.dataFetcher("nodeDefinitions", this::getProcessNodes);
return builder;
}).type("UserTaskInstance", builder -> {
builder.dataFetcher("schema", this::getUserTaskInstanceSchema);
return builder;
}).type("ProcessInstanceMeta", builder -> {
builder.dataFetcher("serviceUrl", this::getProcessInstanceJsonServiceUrl);
return builder;
}).type("ProcessInstanceState", builder -> {
builder.enumValues(name -> ProcessInstanceState.valueOf(name).ordinal());
return builder;
}).type("Subscription", builder -> {
builder.dataFetcher(PROCESS_INSTANCE_ADDED, getProcessInstanceAddedDataFetcher());
builder.dataFetcher(PROCESS_INSTANCE_UPDATED, getProcessInstanceUpdatedDataFetcher());
builder.dataFetcher(USER_TASK_INSTANCE_ADDED, getUserTaskInstanceAddedDataFetcher());
builder.dataFetcher(USER_TASK_INSTANCE_UPDATED, getUserTaskInstanceUpdatedDataFetcher());
builder.dataFetcher(JOB_ADDED, getJobAddedDataFetcher());
builder.dataFetcher(JOB_UPDATED, getJobUpdatedDataFetcher());
return builder;
}).scalar(qlDateTimeScalarType).build();
SchemaGenerator schemaGenerator = new SchemaGenerator();
return schemaGenerator.makeExecutableSchema(typeDefinitionRegistry, runtimeWiring);
}
Aggregations