use of com.axelor.apps.bpm.db.DmnTable in project axelor-open-suite by axelor.
the class DmnServiceImpl method executeDmn.
@Override
@Transactional
public void executeDmn(String decisionDefinitionId, Model model) throws AxelorException {
ProcessEngine processEngine = Beans.get(ProcessEngineService.class).getEngine();
FullContext context = new FullContext(model);
String varName = Beans.get(WkfCommonService.class).getVarName(EntityHelper.getEntity(model));
Map<String, Object> modelMap = new HashMap<String, Object>();
modelMap.put(varName, context);
DmnDecisionTableResult dmnDecisionTableResult = processEngine.getDecisionService().evaluateDecisionTableByKey(decisionDefinitionId, modelMap);
List<Map<String, Object>> result = dmnDecisionTableResult.getResultList();
DmnTable dmnTable = Beans.get(DmnTableRepository.class).all().filter("self.decisionId = ?1", decisionDefinitionId).fetchOne();
if (dmnTable != null) {
Map<String, Object> res = result.get(0);
for (DmnField dmnField : dmnTable.getOutputDmnFieldList()) {
if (dmnField.getField() != null) {
addValue(context, dmnField.getField(), res.get(dmnField.getName()), model);
}
}
}
JpaRepository.of(EntityHelper.getEntityClass(model)).save(model);
}
use of com.axelor.apps.bpm.db.DmnTable in project axelor-open-suite by axelor.
the class DmnDeploymentServiceImpl method setDecisionTables.
private void setDecisionTables(WkfDmnModel wkfDmnModel, DmnModelInstance dmnModelInstance) {
Map<String, DmnTable> dmnTableMap = new HashMap<String, DmnTable>();
if (wkfDmnModel.getDmnTableList() != null) {
dmnTableMap = wkfDmnModel.getDmnTableList().stream().collect(Collectors.toMap(DmnTable::getDecisionId, dmnTable -> dmnTable));
}
wkfDmnModel.clearDmnTableList();
Collection<DecisionTable> tables = dmnModelInstance.getModelElementsByType(DecisionTable.class);
for (DecisionTable table : tables) {
String decisionId = table.getParentElement().getAttributeValue("id");
String decisionName = table.getParentElement().getAttributeValue("name");
DmnTable dmnTable = dmnTableMap.get(decisionId);
log.debug("Find decision table for id: {}, found: {}", decisionId, dmnTable);
if (dmnTable == null) {
dmnTable = new DmnTable();
dmnTable.setWkfDmnModel(wkfDmnModel);
}
dmnTable.setName(decisionName);
dmnTable.setDecisionId(decisionId);
setDmnField(table, dmnTable);
wkfDmnModel.addDmnTableListItem(dmnTable);
}
}
Aggregations