use of org.kie.dmn.model.api.BusinessKnowledgeModel in project drools by kiegroup.
the class BusinessKnowledgeModelCompiler method compileNode.
@Override
public void compileNode(DRGElement de, DMNCompilerImpl compiler, DMNModelImpl model) {
BusinessKnowledgeModel bkm = (BusinessKnowledgeModel) de;
BusinessKnowledgeModelNodeImpl bkmn = new BusinessKnowledgeModelNodeImpl(bkm);
DMNType type = null;
DMNType fnType = null;
if (bkm.getVariable() == null) {
DMNCompilerHelper.reportMissingVariable(model, de, bkm, Msg.MISSING_VARIABLE_FOR_BKM);
return;
}
DMNCompilerHelper.checkVariableName(model, bkm, bkm.getName());
if (bkm.getVariable().getTypeRef() != null) {
// variable must be present, otherwise error was already reported above.
type = compiler.resolveTypeRef(model, bkm, bkm.getVariable(), bkm.getVariable().getTypeRef());
if (type instanceof SimpleFnTypeImpl) {
fnType = type;
type = ((SimpleFnTypeImpl) type).getReturnType();
}
// consistency checks
if (bkm.getEncapsulatedLogic() != null && bkm.getEncapsulatedLogic().getTypeRef() != null) {
DMNType bkmELType = compiler.resolveTypeRef(model, bkm, bkm.getEncapsulatedLogic(), bkm.getEncapsulatedLogic().getTypeRef());
if (!areSameDMNType(fnType != null ? fnType : type, bkmELType)) {
MsgUtil.reportMessage(LOG, DMNMessage.Severity.WARN, bkm.getEncapsulatedLogic(), model, null, null, Msg.VARIABLE_TYPE_MISMATCH_FOR_BKM_EL, bkm.getEncapsulatedLogic().getTypeRef(), bkm.getVariable().getTypeRef());
}
}
if (fnType == null && bkm.getEncapsulatedLogic() != null && bkm.getEncapsulatedLogic().getExpression() != null && bkm.getEncapsulatedLogic().getExpression().getTypeRef() != null) {
// if fnType != null, this is already taken care of DROOLS-6488 in method checkFnConsistency, further below.
DMNType elExprType = compiler.resolveTypeRef(model, bkm, bkm.getEncapsulatedLogic().getExpression(), bkm.getEncapsulatedLogic().getExpression().getTypeRef());
if (!areSameDMNType(type, elExprType)) {
MsgUtil.reportMessage(LOG, DMNMessage.Severity.WARN, bkm.getEncapsulatedLogic(), model, null, null, Msg.VARIABLE_TYPE_MISMATCH_FOR_BKM_EL_BODY, bkm.getEncapsulatedLogic().getExpression().getTypeRef(), type.getName());
}
}
} else if (bkm.getVariable().getTypeRef() == null && bkm.getEncapsulatedLogic().getExpression() != null && bkm.getEncapsulatedLogic().getExpression().getTypeRef() != null) {
type = compiler.resolveTypeRef(model, bkm, bkm.getEncapsulatedLogic().getExpression(), bkm.getEncapsulatedLogic().getExpression().getTypeRef());
} else {
// for now the call bellow will return type UNKNOWN
type = compiler.resolveTypeRef(model, bkm, bkm, null);
}
bkmn.setType(fnType);
bkmn.setResultType(type);
model.addBusinessKnowledgeModel(bkmn);
}
use of org.kie.dmn.model.api.BusinessKnowledgeModel 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";
}
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.BusinessKnowledgeModel 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";
}
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";
}
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);
}
}
use of org.kie.dmn.model.api.BusinessKnowledgeModel in project drools by kiegroup.
the class BusinessKnowledgeModelConverter method writeChildren.
@Override
protected void writeChildren(HierarchicalStreamWriter writer, MarshallingContext context, Object parent) {
super.writeChildren(writer, context, parent);
BusinessKnowledgeModel bkm = (BusinessKnowledgeModel) parent;
if (bkm.getEncapsulatedLogic() != null)
writeChildrenNode(writer, context, bkm.getEncapsulatedLogic(), ENCAPSULATED_LOGIC);
if (bkm.getVariable() != null)
writeChildrenNode(writer, context, bkm.getVariable(), VARIABLE);
for (KnowledgeRequirement i : bkm.getKnowledgeRequirement()) {
writeChildrenNode(writer, context, i, KNOWLEDGE_REQUIREMENT);
}
for (AuthorityRequirement a : bkm.getAuthorityRequirement()) {
writeChildrenNode(writer, context, a, AUTHORITY_REQUIREMENT);
}
}
use of org.kie.dmn.model.api.BusinessKnowledgeModel 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");
}
}
Aggregations