use of eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessDefinitionDto in project CzechIdMng by bcvsolutions.
the class WorkflowDefinitionController method getDiagram.
/**
* Generate process definition diagram image
*
* @param definitionKey
* @return
*/
@RequestMapping(value = "/{backendId}/diagram", method = RequestMethod.GET, produces = MediaType.IMAGE_JPEG_VALUE)
@ResponseBody
@PreAuthorize("hasAuthority('" + CoreGroupPermission.WORKFLOW_DEFINITION_READ + "')")
@ApiOperation(value = "Workflow definition diagram", nickname = "getWorkflowDefinitionDiagram", tags = { WorkflowDefinitionController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = CoreGroupPermission.WORKFLOW_DEFINITION_READ, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = CoreGroupPermission.WORKFLOW_DEFINITION_READ, description = "") }) }, notes = "Returns input stream to definition's diagram.")
public ResponseEntity<InputStreamResource> getDiagram(@ApiParam(value = "Workflow definition key.", required = true) @PathVariable String backendId) {
// check rights
WorkflowProcessDefinitionDto result = definitionService.getByName(backendId);
if (result == null) {
throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("entity", backendId));
}
InputStream is = definitionService.getDiagramByKey(backendId);
try {
return ResponseEntity.ok().contentLength(is.available()).contentType(MediaType.IMAGE_PNG).body(new InputStreamResource(is));
} catch (IOException e) {
throw new ResultCodeException(CoreResultCode.INTERNAL_SERVER_ERROR, e);
}
}
use of eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessDefinitionDto in project CzechIdMng by bcvsolutions.
the class DefaultWorkflowHistoricTaskInstanceService method toResource.
private WorkflowHistoricTaskInstanceDto toResource(HistoricTaskInstance instance) {
if (instance == null) {
return null;
}
WorkflowHistoricTaskInstanceDto dto = new WorkflowHistoricTaskInstanceDto();
// Not working ... variables are not local but global in process scope
// ... may be logged level?
// if(instance.getTaskLocalVariables() != null &&
// instance.getTaskLocalVariables().containsKey(WorkflowHistoricTaskInstanceService.TASK_COMPLETE_DECISION)){
// dto.setCompleteTaskDecision((String)
// instance.getTaskLocalVariables().get(WorkflowHistoricTaskInstanceService.TASK_COMPLETE_DECISION));
// }
dto.setId(instance.getId());
dto.setName(instance.getName());
dto.setProcessDefinitionId(instance.getProcessDefinitionId());
dto.setTaskVariables(instance.getTaskLocalVariables());
dto.setDeleteReason(instance.getDeleteReason());
dto.setDurationInMillis(instance.getDurationInMillis());
dto.setEndTime(instance.getEndTime());
dto.setStartTime(instance.getStartTime());
dto.setPriority(instance.getPriority());
dto.setAssignee(instance.getAssignee());
dto.setCreateTime(instance.getCreateTime());
dto.setDueDate(instance.getDueDate());
List<HistoricIdentityLink> identityLinks = historyService.getHistoricIdentityLinksForTask(instance.getId());
if (identityLinks != null && !identityLinks.isEmpty()) {
List<String> candicateUsers = new ArrayList<>();
for (HistoricIdentityLink identity : identityLinks) {
if (IdentityLinkType.CANDIDATE.equals(identity.getType())) {
candicateUsers.add(identity.getUserId());
}
}
dto.setCandicateUsers(candicateUsers);
}
dto.setDefinition(workflowTaskDefinitionService.searchTaskDefinitionById(dto.getProcessDefinitionId(), instance.getTaskDefinitionKey()));
if (!Strings.isNullOrEmpty(dto.getProcessDefinitionId())) {
WorkflowProcessDefinitionDto processDefinition = workflowProcessDefinitionService.get(dto.getProcessDefinitionId());
if (processDefinition != null) {
dto.setProcessDefinitionKey(processDefinition.getKey());
}
}
return dto;
}
use of eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessDefinitionDto in project CzechIdMng by bcvsolutions.
the class DefaultWorkflowTaskInstanceService method toResource.
private WorkflowTaskInstanceDto toResource(Task task) {
if (task == null) {
return null;
}
WorkflowTaskInstanceDto dto = new WorkflowTaskInstanceDto();
dto.setId(task.getId());
dto.setCreated(task.getCreateTime());
dto.setFormKey(task.getFormKey());
dto.setAssignee(task.getAssignee());
dto.setName(task.getName());
dto.setDescription(task.getDescription());
dto.setProcessInstanceId(task.getProcessInstanceId());
Map<String, Object> taksVariables = task.getTaskLocalVariables();
Map<String, Object> processVariables = task.getProcessVariables();
// Add applicant username to task dto (for easier work)
if (processVariables != null && processVariables.containsKey(WorkflowProcessInstanceService.APPLICANT_IDENTIFIER)) {
dto.setApplicant((String) processVariables.get(WorkflowProcessInstanceService.APPLICANT_IDENTIFIER).toString());
}
dto.setVariables(processVariables);
convertToDtoVariables(dto, taksVariables);
dto.setDefinition(workflowTaskDefinitionService.searchTaskDefinitionById(task.getProcessDefinitionId(), task.getTaskDefinitionKey()));
if (!Strings.isNullOrEmpty(task.getProcessDefinitionId())) {
WorkflowProcessDefinitionDto processDefinition = workflowProcessDefinitionService.get(task.getProcessDefinitionId());
if (processDefinition != null) {
dto.setProcessDefinitionKey(processDefinition.getKey());
}
}
TaskFormData taskFormData = formService.getTaskFormData(task.getId());
// Add form data (it means form properties and value from WF)
List<FormProperty> formProperties = taskFormData.getFormProperties();
// Search and add identity links to dto (It means all user
// (assigned/candidates/group) for this task)
List<IdentityLink> identityLinks = taskService.getIdentityLinksForTask(task.getId());
if (identityLinks != null) {
List<IdentityLinkDto> identityLinksDtos = new ArrayList<>();
for (IdentityLink il : identityLinks) {
identityLinksDtos.add(toResource(il));
}
dto.getIdentityLinks().addAll(identityLinksDtos);
}
// Check if the logged user can complete this task
boolean canExecute = this.canExecute(dto);
if (formProperties != null && !formProperties.isEmpty()) {
for (FormProperty property : formProperties) {
resovleFormProperty(property, dto, canExecute);
}
}
return dto;
}
use of eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowProcessDefinitionDto in project CzechIdMng by bcvsolutions.
the class DeployAndRunProcessTest method testMultipleAutoDeployDefinitionLocations.
@Test
public void testMultipleAutoDeployDefinitionLocations() {
WorkflowProcessDefinitionDto definitionTwo = definitionService.getByName(TEST_PROCESS_KEY_TWO);
//
Assert.assertNotNull(definitionTwo);
}
Aggregations