use of org.kie.kogito.index.model.UserTaskInstance in project kogito-apps by kiegroup.
the class TestUtils method createUserTaskInstance.
public static UserTaskInstance createUserTaskInstance(String taskId, String processInstanceId, String processId, String rootProcessInstanceId, String rootProcessId, String state, long timeInterval) {
UserTaskInstance task = new UserTaskInstance();
task.setId(taskId);
task.setProcessInstanceId(processInstanceId);
task.setProcessId(processId);
task.setRootProcessId(rootProcessId);
task.setRootProcessInstanceId(rootProcessInstanceId);
task.setName("TaskName");
task.setDescription("TaskDescription");
task.setState(state);
task.setPriority("High");
task.setStarted(Instant.ofEpochMilli(ZonedDateTime.now().toInstant().toEpochMilli() + timeInterval).atZone(ZoneOffset.UTC));
task.setCompleted("Completed".equals(state) ? Instant.ofEpochMilli(ZonedDateTime.now().toInstant().toEpochMilli() + timeInterval).atZone(ZoneOffset.UTC).plus(1, ChronoUnit.HOURS) : null);
task.setActualOwner("kogito");
task.setAdminUsers(singleton("kogito"));
task.setAdminGroups(singleton("admin"));
task.setExcludedUsers(singleton("excluded"));
task.setPotentialUsers(singleton("potentialUser"));
task.setPotentialGroups(singleton("potentialGroup"));
task.setComments(List.of(Comment.builder().id("commentId" + taskId).content("Comment 1").updatedBy("kogito").build()));
task.setAttachments(List.of(Attachment.builder().id("attachmentId" + taskId).content("http://linltodoc.com/1").name("doc1").updatedBy("kogito").build()));
return task;
}
use of org.kie.kogito.index.model.UserTaskInstance in project kogito-apps by kiegroup.
the class UserTaskInstanceEventMapper method apply.
@Override
public UserTaskInstance apply(UserTaskInstanceDataEvent event) {
if (event == null || event.getData() == null) {
return null;
}
UserTaskInstance task = new UserTaskInstance();
task.setId(event.getData().getId());
task.setProcessInstanceId(event.getData().getProcessInstanceId());
task.setProcessId(event.getData().getProcessId());
task.setRootProcessId(event.getData().getRootProcessId());
task.setRootProcessInstanceId(event.getData().getRootProcessInstanceId());
task.setName(event.getData().getTaskName());
task.setDescription(event.getData().getTaskDescription());
task.setState(event.getData().getState());
task.setPriority(event.getData().getTaskPriority());
task.setStarted(toZonedDateTime(event.getData().getStartDate()));
task.setCompleted(toZonedDateTime(event.getData().getCompleteDate()));
task.setActualOwner(event.getData().getActualOwner());
task.setAdminUsers(event.getData().getAdminUsers());
task.setAdminGroups(event.getData().getAdminGroups());
task.setExcludedUsers(event.getData().getExcludedUsers());
task.setPotentialUsers(event.getData().getPotentialUsers());
task.setPotentialGroups(event.getData().getPotentialGroups());
task.setComments(event.getData().getComments().stream().map(comment()).collect(toList()));
task.setAttachments(event.getData().getAttachments().stream().map(attachment()).collect(toList()));
task.setInputs(getObjectMapper().valueToTree(event.getData().getInputs()));
task.setOutputs(getObjectMapper().valueToTree(event.getData().getOutputs()));
task.setEndpoint(getEndpoint(event.getSource(), event.getData().getProcessInstanceId(), event.getData().getTaskName(), event.getData().getId()));
task.setLastUpdate(toZonedDateTime(event.getTime()));
task.setReferenceName(event.getData().getReferenceName());
return task;
}
use of org.kie.kogito.index.model.UserTaskInstance in project kogito-apps by kiegroup.
the class UserTaskInstanceEntityMapper method mapToModel.
@Override
public UserTaskInstance mapToModel(UserTaskInstanceEntity entity) {
if (entity == null) {
return null;
}
UserTaskInstance instance = new UserTaskInstance();
instance.setId(entity.getId());
instance.setDescription(entity.getDescription());
instance.setName(entity.getName());
instance.setPriority(entity.getPriority());
instance.setProcessInstanceId(entity.getProcessInstanceId());
instance.setState(entity.getState());
instance.setActualOwner(entity.getActualOwner());
instance.setAdminGroups(entity.getAdminGroups());
instance.setAdminUsers(entity.getAdminUsers());
instance.setCompleted(instantToZonedDateTime(entity.getCompleted()));
instance.setStarted(instantToZonedDateTime(entity.getStarted()));
instance.setExcludedUsers(entity.getExcludedUsers());
instance.setPotentialGroups(entity.getPotentialGroups());
instance.setPotentialUsers(entity.getPotentialUsers());
instance.setReferenceName(entity.getReferenceName());
instance.setLastUpdate(instantToZonedDateTime(entity.getLastUpdate()));
instance.setProcessId(entity.getProcessId());
instance.setRootProcessId(entity.getRootProcessId());
instance.setRootProcessInstanceId(entity.getRootProcessInstanceId());
instance.setInputs(documentToJsonNode(entity.getInputs()));
instance.setOutputs(documentToJsonNode(entity.getOutputs()));
instance.setEndpoint(entity.getEndpoint());
instance.setComments(Optional.ofNullable(entity.getComments()).map(comments -> comments.stream().map(this::toComment).collect(toList())).orElse(null));
instance.setAttachments(Optional.ofNullable(entity.getAttachments()).map(attachments -> attachments.stream().map(this::toAttachment).collect(toList())).orElse(null));
return instance;
}
use of org.kie.kogito.index.model.UserTaskInstance in project kogito-apps by kiegroup.
the class UserTaskInstanceStorageIT method testCache.
@Test
void testCache() {
String taskId = UUID.randomUUID().toString();
String processInstanceId = UUID.randomUUID().toString();
UserTaskInstance userTaskInstance1 = TestUtils.createUserTaskInstance(taskId, processInstanceId, RandomStringUtils.randomAlphabetic(5), UUID.randomUUID().toString(), RandomStringUtils.randomAlphabetic(10), "InProgress", 0L);
UserTaskInstance userTaskInstance2 = TestUtils.createUserTaskInstance(taskId, processInstanceId, RandomStringUtils.randomAlphabetic(5), UUID.randomUUID().toString(), RandomStringUtils.randomAlphabetic(10), "Completed", 1000L);
testStorage(storage, taskId, userTaskInstance1, userTaskInstance2);
}
use of org.kie.kogito.index.model.UserTaskInstance in project kogito-apps by kiegroup.
the class UserTaskInstanceStorageIT method testUserTaskInstanceEntity.
@Test
@Transactional
public void testUserTaskInstanceEntity() {
String taskId = UUID.randomUUID().toString();
String processInstanceId = UUID.randomUUID().toString();
UserTaskInstance userTaskInstance1 = TestUtils.createUserTaskInstance(taskId, processInstanceId, RandomStringUtils.randomAlphabetic(5), UUID.randomUUID().toString(), RandomStringUtils.randomAlphabetic(10), "InProgress", 0L);
UserTaskInstance userTaskInstance2 = TestUtils.createUserTaskInstance(taskId, processInstanceId, RandomStringUtils.randomAlphabetic(5), UUID.randomUUID().toString(), RandomStringUtils.randomAlphabetic(10), "Completed", 1000L);
testStorage(taskId, userTaskInstance1, userTaskInstance2);
}
Aggregations