use of org.kie.dmn.model.v1_2.TInformationItem in project drools by kiegroup.
the class XLS2DMNParser method appendInputData.
private void appendInputData(Definitions definitions, Map<String, DTHeaderInfo> headerInfos) {
Set<String> usedRI = new LinkedHashSet<>();
for (DTHeaderInfo hi : headerInfos.values()) {
for (String ri : hi.getRequiredInput()) {
if (!usedRI.contains(ri)) {
InputData id = new TInputData();
id.setName(ri);
id.setId("id_" + CodegenStringUtil.escapeIdentifier(ri));
InformationItem variable = new TInformationItem();
variable.setName(ri);
variable.setId("idvar_" + CodegenStringUtil.escapeIdentifier(ri));
variable.setTypeRef(new QName("Any"));
id.setVariable(variable);
definitions.getDrgElement().add(id);
}
usedRI.add(ri);
}
}
}
use of org.kie.dmn.model.v1_2.TInformationItem in project drools by kiegroup.
the class XLS2DMNParser method appendDecisionDT.
private void appendDecisionDT(Definitions definitions, Map<String, DTHeaderInfo> headerInfos) {
for (DTHeaderInfo hi : headerInfos.values()) {
Decision decision = new TDecision();
decision.setName(hi.getSheetName());
decision.setId("d_" + CodegenStringUtil.escapeIdentifier(hi.getSheetName()));
InformationItem variable = new TInformationItem();
variable.setName(hi.getSheetName());
variable.setId("dvar_" + CodegenStringUtil.escapeIdentifier(hi.getSheetName()));
variable.setTypeRef(new QName("Any"));
decision.setVariable(variable);
for (String ri : hi.getRequiredInput()) {
InformationRequirement ir = new TInformationRequirement();
DMNElementReference er = new TDMNElementReference();
er.setHref("#id_" + CodegenStringUtil.escapeIdentifier(ri));
ir.setRequiredInput(er);
decision.getInformationRequirement().add(ir);
}
for (String ri : hi.getRequiredDecision()) {
InformationRequirement ir = new TInformationRequirement();
DMNElementReference er = new TDMNElementReference();
er.setHref("#d_" + CodegenStringUtil.escapeIdentifier(ri));
ir.setRequiredDecision(er);
decision.getInformationRequirement().add(ir);
}
DecisionTable dt = new TDecisionTable();
dt.setOutputLabel(hi.getSheetName());
dt.setId("ddt_" + CodegenStringUtil.escapeIdentifier(hi.getSheetName()));
dt.setHitPolicy(HitPolicy.ANY);
for (String ri : hi.getRequiredInput()) {
InputClause ic = new TInputClause();
ic.setLabel(ri);
LiteralExpression le = new TLiteralExpression();
le.setText(ri);
ic.setInputExpression(le);
dt.getInput().add(ic);
}
for (String rd : hi.getRequiredDecision()) {
InputClause ic = new TInputClause();
ic.setLabel(rd);
LiteralExpression le = new TLiteralExpression();
le.setText(rd);
ic.setInputExpression(le);
dt.getInput().add(ic);
}
OutputClause oc = new TOutputClause();
dt.getOutput().add(oc);
decision.setExpression(dt);
definitions.getDrgElement().add(decision);
}
}
use of org.kie.dmn.model.v1_2.TInformationItem 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_2.TInformationItem in project kie-wb-common by kiegroup.
the class InformationItemPrimaryPropertyConverter method dmnFromWB.
public static TInformationItem dmnFromWB(final InformationItemPrimary wb, final DMNModelInstrumentedBase parent) {
if (wb == null) {
return null;
}
final TInformationItem result = new TInformationItem();
final QName typeRef = wb.getTypeRef();
result.setId(wb.getId().getValue());
result.setName(getParentName(parent));
QNamePropertyConverter.setDMNfromWB(typeRef, result::setTypeRef);
return result;
}
use of org.kie.dmn.model.v1_2.TInformationItem in project kie-wb-common by kiegroup.
the class DMNMarshallerImportsHelperStandaloneImpl method updateInformationItem.
private void updateInformationItem(final String namespace, final DRGElement drgElement) {
getInformationItem(drgElement).ifPresent(informationItem -> {
final InformationItem tInformationItem = new TInformationItem();
final QName qName = informationItem.getTypeRef();
if (qName != null && !isBuiltInType(qName.getLocalPart())) {
tInformationItem.setTypeRef(new QName(qName.getNamespaceURI(), namespace + "." + qName.getLocalPart(), qName.getPrefix()));
setInformationItem(drgElement, tInformationItem);
}
});
}
Aggregations