use of org.kie.dmn.model.v1_1.extensions.DecisionServices in project drools by kiegroup.
the class DecisionServicesConverter method writeChildren.
@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
super.writeChildren(writer, context, parent);
DecisionServices decisionServices = (DecisionServices) parent;
for (DecisionService ds : decisionServices.getDecisionService()) {
writeChildrenNode(writer, context, ds, DECISION_SERVICE);
}
}
use of org.kie.dmn.model.v1_1.extensions.DecisionServices in project drools by kiegroup.
the class DMNCompilerImpl method processDrgElements.
private void processDrgElements(DMNCompilerContext ctx, DMNModelImpl model, Definitions dmndefs) {
for (DRGElement e : dmndefs.getDrgElement()) {
boolean foundIt = false;
for (DRGElementCompiler dc : drgCompilers) {
if (dc.accept(e)) {
foundIt = true;
dc.compileNode(e, this, model);
continue;
}
}
if (!foundIt) {
MsgUtil.reportMessage(logger, DMNMessage.Severity.ERROR, e, model, null, null, Msg.UNSUPPORTED_ELEMENT, e.getClass().getSimpleName(), e.getId());
}
}
// in DMN v1.1 the DecisionService is not on the DRGElement but as an extension
if (dmndefs.getExtensionElements() != null) {
List<DecisionServices> decisionServices = dmndefs.getExtensionElements().getAny().stream().filter(DecisionServices.class::isInstance).map(DecisionServices.class::cast).collect(Collectors.toList());
for (DecisionServices dss : decisionServices) {
for (DecisionService ds : dss.getDecisionService()) {
// compatibility with DMN v1.1, create Decision Service's variable:
if (ds.getVariable() == null) {
InformationItem variable = new TInformationItem();
variable.setId(UUID.randomUUID().toString());
variable.setName(ds.getName());
variable.setParent(ds);
// the introduction of an on-the-fly ItemDefinition has been removed. The variable type will be evaluated as feel:any, or in v1.2 will receive the (user-defined, explicit) ItemDefinition type.
ds.setVariable(variable);
}
// continuing with normal compilation of Decision Service:
boolean foundIt = false;
for (DRGElementCompiler dc : drgCompilers) {
if (dc.accept(ds)) {
foundIt = true;
dc.compileNode(ds, this, model);
continue;
}
}
}
}
}
for (DecisionServiceNode ds : model.getDecisionServices()) {
DecisionServiceNodeImpl dsi = (DecisionServiceNodeImpl) ds;
dsi.addModelImportAliases(model.getImportAliasesForNS());
for (DRGElementCompiler dc : drgCompilers) {
if (dsi.getEvaluator() == null && dc.accept(dsi)) {
// will compile in fact all DS belonging to this model (not the imported ones).
dc.compileEvaluator(dsi, this, ctx, model);
}
}
}
for (BusinessKnowledgeModelNode bkm : model.getBusinessKnowledgeModels()) {
BusinessKnowledgeModelNodeImpl bkmi = (BusinessKnowledgeModelNodeImpl) bkm;
bkmi.addModelImportAliases(model.getImportAliasesForNS());
for (DRGElementCompiler dc : drgCompilers) {
if (bkmi.getEvaluator() == null && dc.accept(bkm)) {
dc.compileEvaluator(bkm, this, ctx, model);
}
}
}
for (DecisionNode d : model.getDecisions()) {
DecisionNodeImpl di = (DecisionNodeImpl) d;
di.addModelImportAliases(model.getImportAliasesForNS());
for (DRGElementCompiler dc : drgCompilers) {
if (di.getEvaluator() == null && dc.accept(d)) {
dc.compileEvaluator(d, this, ctx, model);
}
}
}
for (AfterProcessDrgElements callback : afterDRGcallbacks) {
logger.debug("About to invoke callback: {}", callback);
callback.callback(this, ctx, model);
}
detectCycles(model);
}
use of org.kie.dmn.model.v1_1.extensions.DecisionServices in project drools by kiegroup.
the class DecisionServicesConverter method assignChildElement.
@Override
protected void assignChildElement(Object parent, String nodeName, Object child) {
DecisionServices decisionServices = (DecisionServices) parent;
// We need to clear the namespace prefix for drools:KIE because DMNModelInstrumentedBaseConverter#writeAttributes will try to write it again.
// The namespace is registered in the XStreamMapper#configureQNameMap method by the extension register
decisionServices.getNsContext().remove("drools", KieDMNModelInstrumentedBase.URI_KIE);
switch(nodeName) {
case DECISION_SERVICE:
decisionServices.getDecisionService().add((DecisionService) child);
break;
}
}
Aggregations