use of com.axelor.apps.bpm.db.DmnField in project axelor-open-suite by axelor.
the class DmnDeploymentServiceImpl method setDmnField.
private void setDmnField(DecisionTable decisionTable, DmnTable dmnTable) {
Map<String, DmnField> outputFieldMap = new HashMap<String, DmnField>();
if (dmnTable.getOutputDmnFieldList() != null) {
outputFieldMap = dmnTable.getOutputDmnFieldList().stream().collect(Collectors.toMap(DmnField::getName, dmnField -> dmnField));
}
dmnTable.clearOutputDmnFieldList();
for (Output output : decisionTable.getOutputs()) {
DmnField field = outputFieldMap.get(output.getName());
log.debug("Find output for name: {}, found: {}", output.getName(), field);
if (field == null) {
field = new DmnField(output.getName());
field.setOutputDmnTable(dmnTable);
} else {
field.setName(output.getName());
}
field.setFieldType(output.getTypeRef());
dmnTable.addOutputDmnFieldListItem(field);
}
}
use of com.axelor.apps.bpm.db.DmnField 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);
}
Aggregations