use of org.kie.dmn.model.api.DecisionService in project drools by kiegroup.
the class DecisionServiceConverter method writeChildren.
@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
super.writeChildren(writer, context, parent);
DecisionService decisionService = (DecisionService) parent;
for (DMNElementReference ref : decisionService.getOutputDecision()) {
writeChildrenNode(writer, context, ref, OUTPUT_DECISION);
}
for (DMNElementReference ref : decisionService.getEncapsulatedDecision()) {
writeChildrenNode(writer, context, ref, ENCAPSULATED_DECISION);
}
for (DMNElementReference ref : decisionService.getInputDecision()) {
writeChildrenNode(writer, context, ref, INPUT_DECISION);
}
for (DMNElementReference ref : decisionService.getInputData()) {
writeChildrenNode(writer, context, ref, INPUT_DATA);
}
}
use of org.kie.dmn.model.api.DecisionService 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.api.DecisionService in project drools by kiegroup.
the class DefinitionsConverter method writeChildren.
@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
super.writeChildren(writer, context, parent);
Definitions def = (Definitions) parent;
for (Import i : def.getImport()) {
writeChildrenNode(writer, context, i, IMPORT);
}
for (ItemDefinition id : def.getItemDefinition()) {
writeChildrenNode(writer, context, id, ITEM_DEFINITION);
}
for (DRGElement e : def.getDrgElement()) {
String nodeName = DRG_ELEMENT;
if (e instanceof BusinessKnowledgeModel) {
nodeName = "businessKnowledgeModel";
} else if (e instanceof Decision) {
nodeName = "decision";
} else if (e instanceof InputData) {
nodeName = "inputData";
} else if (e instanceof KnowledgeSource) {
nodeName = "knowledgeSource";
} else if (e instanceof DecisionService) {
nodeName = "decisionService";
}
writeChildrenNode(writer, context, e, nodeName);
}
for (Artifact a : def.getArtifact()) {
String nodeName = ARTIFACT;
if (a instanceof Association) {
nodeName = "association";
} else if (a instanceof TextAnnotation) {
nodeName = "textAnnotation";
} else if (a instanceof Group) {
nodeName = "group";
}
writeChildrenNode(writer, context, a, nodeName);
}
for (ElementCollection ec : def.getElementCollection()) {
writeChildrenNode(writer, context, ec, ELEMENT_COLLECTION);
}
for (BusinessContextElement bce : def.getBusinessContextElement()) {
String nodeName = BUSINESS_CONTEXT_ELEMENT;
if (bce instanceof OrganizationUnit) {
nodeName = "organizationUnit";
} else if (bce instanceof PerformanceIndicator) {
nodeName = "performanceIndicator";
}
writeChildrenNode(writer, context, bce, nodeName);
}
if (def.getDMNDI() != null) {
writeChildrenNode(writer, context, def.getDMNDI(), "DMNDI");
}
}
use of org.kie.dmn.model.api.DecisionService in project drools by kiegroup.
the class DecisionServiceCompiler method compileNode.
@Override
public void compileNode(DRGElement drge, DMNCompilerImpl compiler, DMNModelImpl model) {
DecisionService ds = (DecisionService) drge;
compileNode(ds, compiler, model);
}
use of org.kie.dmn.model.api.DecisionService 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);
}
Aggregations