use of eu.bcvsolutions.idm.core.workflow.model.dto.WorkflowHistoricProcessInstanceDto in project CzechIdMng by bcvsolutions.
the class WorkflowHistoricProcessInstanceController method getDiagram.
/**
* Generate process instance diagram image
*
* @param historicProcessInstanceId
* @return
*/
@ResponseBody
@RequestMapping(value = "/{backendId}/diagram", method = RequestMethod.GET, produces = MediaType.IMAGE_PNG_VALUE)
@ApiOperation(value = "Historic process instance diagram", nickname = "getHistoricProcessInstanceDiagram", response = WorkflowHistoricProcessInstanceDto.class, tags = { WorkflowHistoricProcessInstanceController.TAG })
public ResponseEntity<InputStreamResource> getDiagram(@ApiParam(value = "Historic process instance id.", required = true) @PathVariable @NotNull String backendId) {
// check rights
WorkflowHistoricProcessInstanceDto result = workflowHistoricProcessInstanceService.get(backendId);
if (result == null) {
throw new ResultCodeException(CoreResultCode.FORBIDDEN);
}
InputStream is = workflowHistoricProcessInstanceService.getDiagram(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.WorkflowHistoricProcessInstanceDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmRequestItemService method toDto.
@Override
public IdmRequestItemDto toDto(IdmRequestItem entity, IdmRequestItemDto dto) {
IdmRequestItemDto requestItemDto = super.toDto(entity, dto);
// Load and add WF process DTO to embedded. Prevents of many requests from FE.
if (requestItemDto != null && requestItemDto.getWfProcessId() != null) {
if (RequestState.IN_PROGRESS == requestItemDto.getState()) {
// Instance of process should exists only in 'IN_PROGRESS' state
WorkflowProcessInstanceDto processInstanceDto = workflowProcessInstanceService.get(requestItemDto.getWfProcessId());
// size
if (processInstanceDto != null) {
processInstanceDto.setProcessVariables(null);
}
requestItemDto.getEmbedded().put(AbstractRequestDto.WF_PROCESS_FIELD, processInstanceDto);
} else {
// In others states we need load historic process
WorkflowHistoricProcessInstanceDto processHistDto = workflowHistoricProcessInstanceService.get(requestItemDto.getWfProcessId());
// size
if (processHistDto != null) {
processHistDto.setProcessVariables(null);
}
requestItemDto.getEmbedded().put(AbstractRequestDto.WF_PROCESS_FIELD, processHistDto);
}
}
// Load and add owner DTO to embedded. Prevents of many requests from FE.
if (requestItemDto != null && requestItemDto.getOwnerId() != null && requestItemDto.getOwnerType() != null) {
try {
@SuppressWarnings("unchecked") Requestable requestable = requestManager.convertItemToDto(requestItemDto, (Class<Requestable>) Class.forName(requestItemDto.getOwnerType()));
// Item for remove operation does not contains the JSON data, so we need load owner via lookupService
if (requestable == null && RequestOperationType.REMOVE == requestItemDto.getOperation()) {
requestable = (Requestable) lookupService.lookupDto(requestItemDto.getOwnerType(), requestItemDto.getOwnerId());
}
if (requestable == null) {
// Entity was not found ... maybe was deleted or not exists yet
LOG.debug(MessageFormat.format("Owner [{0}, {1}] not found for request {2}.", requestItemDto.getOwnerType(), requestItemDto.getOwnerId(), requestItemDto.getId()));
}
requestItemDto.getEmbedded().put(IdmRequestDto.OWNER_FIELD, requestable);
} catch (ClassNotFoundException e) {
// Only print warning
LOG.warn(MessageFormat.format("Class not found for request item {0}.", requestItemDto.getId()), e);
} catch (JsonParseException e) {
// Only print warning
LOG.warn(MessageFormat.format("JsonParseException for request item {0}.", requestItemDto.getId()), e);
} catch (JsonMappingException e) {
// Only print warning
LOG.warn(MessageFormat.format("JsonMappingException for request item {0}.", requestItemDto.getId()), e);
} catch (IOException e) {
// Only print warning
LOG.warn(MessageFormat.format("IOException for request item {0}.", requestItemDto.getId()), e);
}
}
return requestItemDto;
}
Aggregations