public HistoricDecisionInstanceDto getHistoricDecisionInstance() {
    HistoryService historyService = engine.getHistoryService();
    HistoricDecisionInstance instance =
        historyService
            .createHistoricDecisionInstanceQuery()
            .decisionInstanceId(decisionInstanceId)
            .singleResult();

    if (instance == null) {
      throw new InvalidRequestException(
          Status.NOT_FOUND,
          "Historic decision instance with id '" + decisionInstanceId + "' does not exist");
    }

    return HistoricDecisionInstanceDto.fromHistoricDecisionInstance(instance);
  }
  public static HistoricDecisionInstanceDto fromHistoricDecisionInstance(
      HistoricDecisionInstance historicDecisionInstance) {
    HistoricDecisionInstanceDto dto = new HistoricDecisionInstanceDto();

    dto.id = historicDecisionInstance.getId();
    dto.decisionDefinitionId = historicDecisionInstance.getDecisionDefinitionId();
    dto.decisionDefinitionKey = historicDecisionInstance.getDecisionDefinitionKey();
    dto.decisionDefinitionName = historicDecisionInstance.getDecisionDefinitionName();
    dto.evaluationTime = historicDecisionInstance.getEvaluationTime();
    dto.processDefinitionId = historicDecisionInstance.getProcessDefinitionId();
    dto.processDefinitionKey = historicDecisionInstance.getProcessDefinitionKey();
    dto.processInstanceId = historicDecisionInstance.getProcessInstanceId();
    dto.activityId = historicDecisionInstance.getActivityId();
    dto.activityInstanceId = historicDecisionInstance.getActivityInstanceId();
    dto.collectResultValue = historicDecisionInstance.getCollectResultValue();

    try {
      List<HistoricDecisionInputInstanceDto> inputs =
          new ArrayList<HistoricDecisionInputInstanceDto>();
      for (HistoricDecisionInputInstance input : historicDecisionInstance.getInputs()) {
        HistoricDecisionInputInstanceDto inputDto =
            HistoricDecisionInputInstanceDto.fromHistoricDecisionInputInstance(input);
        inputs.add(inputDto);
      }
      dto.inputs = inputs;
    } catch (ProcessEngineException e) {
      // no inputs fetched
    }

    try {
      List<HistoricDecisionOutputInstanceDto> outputs =
          new ArrayList<HistoricDecisionOutputInstanceDto>();
      for (HistoricDecisionOutputInstance output : historicDecisionInstance.getOutputs()) {
        HistoricDecisionOutputInstanceDto outputDto =
            HistoricDecisionOutputInstanceDto.fromHistoricDecisionOutputInstance(output);
        outputs.add(outputDto);
      }
      dto.outputs = outputs;
    } catch (ProcessEngineException e) {
      // no outputs fetched
    }

    return dto;
  }