protected void applySortBy(
     HistoricDecisionInstanceQuery query,
     String sortBy,
     Map<String, Object> parameters,
     ProcessEngine engine) {
   if (sortBy.equals(SORT_BY_EVALUATION_TIME_VALUE)) {
     query.orderByEvaluationTime();
   } else if (sortBy.equals(SORT_BY_TENANT_ID)) {
     query.orderByTenantId();
   }
 }
 protected void applyFilters(HistoricDecisionInstanceQuery query) {
   if (decisionInstanceId != null) {
     query.decisionInstanceId(decisionInstanceId);
   }
   if (decisionInstanceIdIn != null) {
     query.decisionInstanceIdIn(decisionInstanceIdIn);
   }
   if (decisionDefinitionId != null) {
     query.decisionDefinitionId(decisionDefinitionId);
   }
   if (decisionDefinitionKey != null) {
     query.decisionDefinitionKey(decisionDefinitionKey);
   }
   if (decisionDefinitionName != null) {
     query.decisionDefinitionName(decisionDefinitionName);
   }
   if (processDefinitionId != null) {
     query.processDefinitionId(processDefinitionId);
   }
   if (processDefinitionKey != null) {
     query.processDefinitionKey(processDefinitionKey);
   }
   if (processInstanceId != null) {
     query.processInstanceId(processInstanceId);
   }
   if (caseDefinitionId != null) {
     query.caseDefinitionId(caseDefinitionId);
   }
   if (caseDefinitionKey != null) {
     query.caseDefinitionKey(caseDefinitionKey);
   }
   if (caseInstanceId != null) {
     query.caseInstanceId(caseInstanceId);
   }
   if (activityIdIn != null) {
     query.activityIdIn(activityIdIn);
   }
   if (activityInstanceIdIn != null) {
     query.activityInstanceIdIn(activityInstanceIdIn);
   }
   if (evaluatedBefore != null) {
     query.evaluatedBefore(evaluatedBefore);
   }
   if (evaluatedAfter != null) {
     query.evaluatedAfter(evaluatedAfter);
   }
   if (includeInputs != null && includeInputs) {
     query.includeInputs();
   }
   if (includeOutputs != null && includeOutputs) {
     query.includeOutputs();
   }
   if (disableBinaryFetching != null && disableBinaryFetching) {
     query.disableBinaryFetching();
   }
   if (disableCustomObjectDeserialization != null && disableCustomObjectDeserialization) {
     query.disableCustomObjectDeserialization();
   }
   if (tenantIds != null && !tenantIds.isEmpty()) {
     query.tenantIdIn(tenantIds.toArray(new String[tenantIds.size()]));
   }
 }