use of org.kie.dmn.model.v1_1.Context in project drools by kiegroup.
the class DMNRuntimeTest method testUnknownVariable1.
@Test
public void testUnknownVariable1() {
DMNRuntime runtime = DMNRuntimeUtil.createRuntime("unknown_variable1.dmn", this.getClass());
DMNModel dmnModel = runtime.getModel("http://www.trisotech.com/definitions/_9105d4a6-6049-4ace-a9cd-88f18d29bc8f", "Loan Recommendation - context");
assertThat(dmnModel, notNullValue());
assertThat(DMNRuntimeUtil.formatMessages(dmnModel.getMessages()), dmnModel.getMessages().size(), is(2));
assertEquals(1, dmnModel.getMessages().stream().filter(m -> m.getMessageType().equals(DMNMessageType.ERR_COMPILING_FEEL)).filter(m -> m.getMessage().contains("Unknown variable 'NonSalaryPct'")).count());
}
use of org.kie.dmn.model.v1_1.Context in project kie-wb-common by kiegroup.
the class ContextPropertyConverter method wbFromDMN.
public static Context wbFromDMN(final org.kie.dmn.model.v1_1.Context dmn) {
Id id = new Id(dmn.getId());
Description description = new Description(dmn.getDescription());
QName typeRef = QNamePropertyConverter.wbFromDMN(dmn.getTypeRef());
Context result = new Context(id, description, typeRef);
for (org.kie.dmn.model.v1_1.ContextEntry ce : dmn.getContextEntry()) {
ContextEntry ceConverted = ContextEntryPropertyConverter.wbFromDMN(ce);
result.getContextEntry().add(ceConverted);
}
return result;
}
use of org.kie.dmn.model.v1_1.Context in project kie-wb-common by kiegroup.
the class ContextPropertyConverter method dmnFromWB.
public static org.kie.dmn.model.v1_1.Context dmnFromWB(final Context wb) {
org.kie.dmn.model.v1_1.Context result = new org.kie.dmn.model.v1_1.Context();
result.setId(wb.getId().getValue());
result.setDescription(wb.getDescription().getValue());
QNamePropertyConverter.setDMNfromWB(wb.getTypeRef(), result::setTypeRef);
for (ContextEntry ce : wb.getContextEntry()) {
org.kie.dmn.model.v1_1.ContextEntry ceConverted = ContextEntryPropertyConverter.dmnFromWB(ce);
result.getContextEntry().add(ceConverted);
}
return result;
}
use of org.kie.dmn.model.v1_1.Context in project kie-wb-common by kiegroup.
the class PMMLFunctionEditorDefinition method getModelClass.
@Override
public Optional<Context> getModelClass() {
final Context context = new Context();
final ContextEntry documentEntry = new ContextEntry();
final InformationItem documentEntryVariable = new InformationItem();
documentEntryVariable.setName(new Name(VARIABLE_DOCUMENT));
documentEntry.setVariable(documentEntryVariable);
documentEntry.setExpression(new LiteralExpression());
context.getContextEntry().add(documentEntry);
final ContextEntry modelEntry = new ContextEntry();
final InformationItem modelEntryVariable = new InformationItem();
modelEntryVariable.setName(new Name(VARIABLE_MODEL));
modelEntry.setVariable(modelEntryVariable);
modelEntry.setExpression(new LiteralExpression());
context.getContextEntry().add(modelEntry);
return Optional.of(context);
}
use of org.kie.dmn.model.v1_1.Context in project kie-wb-common by kiegroup.
the class ContextEditorDefinition method getModelClass.
@Override
public Optional<Context> getModelClass() {
// Add one ContextEntry for the User to start with
final Context context = new Context();
final ContextEntry contextEntry = new ContextEntry();
contextEntry.setVariable(new InformationItem());
context.getContextEntry().add(contextEntry);
// Add (default) "result" entry
final ContextEntry resultEntry = new ContextEntry();
resultEntry.setExpression(new LiteralExpression());
context.getContextEntry().add(resultEntry);
return Optional.of(context);
}
Aggregations