История для DMN решений
|
Этот раздел перенесён из документации Camunda 7 и в дальнейшем будет доработан с учётом особенностей OpenBPM Engine |
После того как определение решения прошло оценку либо со стороны BPMN process, или CMMN сценария, либо через сервис решений, входные и выходные данные сохраняются в истории (History) платформы. Сущность, сохраняемая в истории, принадлежит к типу HistoricDecisionInstance и имеет тип события evaluate.
Чтобы узнать больше подробностей о механизме работы истории как таковой, см. История и логи событий аудита.
|
Требуется уровень истории FULL. Иначе история для решений вообще не создается. |
Запрос для оцененных решений
Сервис истории (History Service) может использоваться для отправки запроса для HistoricDecisionInstances. Например, вы модете использовать следующий запрос, чтобы получить все записи в истории для определения решения с ключом checkOrder, упорядоченные по времени оценки решения.
List<HistoricDecisionInstance> historicDecisions = processEngine
.getHistoryService()
.createHistoricDecisionInstanceQuery()
.decisionDefinitionKey("checkOrder")
.orderByEvaluationTime()
.asc()
.list();
Решения, получившие оценку из from a задачи с BPMN бизнес правилом, могут быть отфильтрованы по id определения решения и по id экземпляра процесса.
HistoryService historyService = processEngine.getHistoryService();
List<HistoricDecisionInstance> historicDecisionInstances = historyService
.createHistoricDecisionInstanceQuery()
.processDefinitionId("processDefinitionId")
.list();
historicDecisionInstances = historyService
.createHistoricDecisionInstanceQuery()
.processDefinitionKey("processDefinitionKey")
.list();
historicDecisionInstances = historyService
.createHistoricDecisionInstanceQuery()
.processInstanceId("processInstanceId")
.list();
Решения, которые получили оценку из задачи с CMMN решением, могут быть отфильтрованы по id определения сценария и по id экземпляра сценария.
HistoryService historyService = processEngine.getHistoryService();
List<HistoricDecisionInstance> historicDecisionInstances = historyService
.createHistoricDecisionInstanceQuery()
.caseDefinitionId("caseDefinitionId")
.list();
historicDecisionInstances = historyService
.createHistoricDecisionInstanceQuery()
.caseDefinitionKey("caseDefinitionKey")
.list();
historicDecisionInstances = historyService
.createHistoricDecisionInstanceQuery()
.caseInstanceId("caseInstanceId")
.list();
Обратите внимание, что входные и выходные данные решения не включены в результат запроса по умолчанию. Вызывайте методы includeInputs() и includeOutputs() на запросе, чтобы получить входные и выходные данные из результата.
List<HistoricDecisionInstance> historicDecisions = processEngine
.getHistoryService()
.createHistoricDecisionInstanceQuery()
.decisionDefinitionKey("checkOrder")
.includeInputs()
.includeOutputs()
.list();
Исторический экземпляр решения
https://docs.camunda.org/manual/latest/reference/javadoc/?org/camunda/bpm/engine/history/HistoricDecisionInstance[HistoricDecisionInstance] содержит информацию об одной оценке решения.
HistoricDecisionInstance historicDecision = ...;
// id of the decision definition
String decisionDefinitionId = historicDecision.getDecisionDefinitionId();
// key of the decision definition
String decisionDefinitionKey = historicDecision.getDecisionDefinitionKey();
// name of the decision
String decisionDefinitionName = historicDecision.getDecisionDefinitionName();
// time when the decision was evaluated
Date evaluationTime = historicDecision.getEvaluationTime();
// inputs of the decision (if includeInputs was specified in the query)
List<HistoricDecisionInputInstance> inputs = historicDecision.getInputs();
// outputs of the decision (if includeOutputs was specified in the query)
List<HistoricDecisionOutputInstance> outputs = historicDecision.getOutputs();
В случае, когда оценка решения была проведена из процесса, информация об определении процесса, экземпляре процесса и активности помещается в HistoricDecisionInstance. То де самое справедливо для решений, оцененных в сценарии, где экземпляры истории будут ссылаться на соответствующие экземпляры сценариев.
Кроме того, если решение представляет собой таблицу с hit policy collect и функцией агрегатора, результат агрегации может извлекаться черезщ метод getCollectResultValue().
Чтобы найти больше информации по поддерживаемым hit policies, см. Справочник по DMN 1.3.
Экземпляр входных данных исторического решения
HistoricDecisionInputInstance представляет один элемент входных данных оцененного решения (например, элемент входных данных таблицы решений).
HistoricDecisionInputInstance input = ...;
// id of the input clause
String clauseId = input.getClauseId();
// label of the input clause
String clauseName = input.getClauseName();
// evaluated value of the input expression
Object value = input.getValue();
// evaluated value of the input expression as typed value
// which contains type information
TypedValue typedValue = input.getTypedValue();
Обратите внимание, что это значение может быт результатом преобразования типов в том случае, когда для входных данных задан тип.
Экземпляр выходных данных исторического решения
HistoricDecisionOutputInstance представляет один элемент выходных данных оцененного решения. Если решение реализовано как таблица, HistoricDecisionInstance содержит один HistoricDecisionOutputInstance для каждого элемента выходных данных и выполненного правила.
HistoricDecisionOutputInstance output = ...;
// id of the output clause
String clauseId = output.getClauseId();
// label of the output clause
String clauseName = output.getClauseName();
// evaluated value of the output entry
Object value = output.getValue();
// evaluated value of the output entry as typed value
// which contains type information
TypedValue typedValue = output.getTypedValue();
// id of matched rule the output belongs to
String ruleId = output.getRuleId();
// the position of the rule in the list of matched rules
Integer ruleOrder = output.getRuleOrder();
// name of the output clause used as output variable identifier
String variableName = output.getVariableName();
Обратите внимание, что значение может быть результатом преобразования типов в том случае, когда для выходных данных задан тип.
Cockpit
Вы можете проводить аудит для оцененных решений в веб-приложении Cockpit.
Лицензия и атрибуция
Эта документация была создана на базе материала "Camunda 7 Docs" от Camunda, находится под лицензией Creative Commons Attribution-ShareAlike 3.0 Unported License .
Оригинал документации: https://docs.camunda.org