use of org.kie.soup.project.datamodel.imports.Import in project drools-wb by kiegroup.
the class IndexGuidedDecisionTableAttributesTest method testIndexGuidedDecisionTableAttributes.
@Test
public void testIndexGuidedDecisionTableAttributes() throws IOException, InterruptedException {
// Add test files
final Path path = basePath.resolve("dtable1.gdst");
final GuidedDecisionTable52 model = GuidedDecisionTableFactory.makeTableWithAttributeCol("org.drools.workbench.screens.guided.dtable.backend.server.indexing", new ArrayList<Import>() {
{
add(new Import("org.drools.workbench.screens.guided.dtable.backend.server.indexing.classes.Applicant"));
}
}, "dtable1");
final String xml = GuidedDTXMLPersistence.getInstance().marshal(model);
ioService().write(path, xml);
// wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index
Thread.sleep(5000);
List<String> index = Arrays.asList(KObjectUtil.toKCluster(basePath).getClusterId());
// Decision Table defining a RuleFlow-Group named myRuleFlowGroup. This should match dtable1.gdst
// This checks whether there is a Rule Attribute "ruleflow-group" and its Value is "myRuleflowGroup"
{
final Query query = new SingleTermQueryBuilder(new ValueSharedPartIndexTerm("myRuleFlowGroup", PartType.RULEFLOW_GROUP)).build();
searchFor(index, query, 1, path);
}
}
use of org.kie.soup.project.datamodel.imports.Import in project drools-wb by kiegroup.
the class IndexGuidedDecisionTableBRLFragmentConditionsPredicateTest method checkSingleFieldConstraintPredicate.
@Test
public void checkSingleFieldConstraintPredicate() throws IOException, InterruptedException {
// Add test files
final Path path = basePath.resolve("dtable1.gdst");
final GuidedDecisionTable52 model = GuidedDecisionTableFactory.makeTableWithBRLFragmentConditionColWithPredicate("org.drools.workbench.screens.guided.dtable.backend.server.indexing", new ArrayList<Import>() {
{
add(new Import("org.drools.workbench.screens.guided.dtable.backend.server.indexing.classes.Applicant"));
add(new Import("org.drools.workbench.screens.guided.dtable.backend.server.indexing.classes.Mortgage"));
}
}, "dtable1");
final String xml = GuidedDTXMLPersistence.getInstance().marshal(model);
ioService().write(path, xml);
// wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index
Thread.sleep(7500);
List<String> index = Arrays.asList(KObjectUtil.toKCluster(basePath).getClusterId());
{
final Query query = new SingleTermQueryBuilder(new ValueReferenceIndexTerm("org.drools.workbench.screens.guided.dtable.backend.server.indexing.classes.Applicant", ResourceType.JAVA)).build();
searchFor(index, query, 1, path);
}
}
use of org.kie.soup.project.datamodel.imports.Import in project drools-wb by kiegroup.
the class GuidedRuleEditorServiceImpl method create.
@Override
public Path create(final Path context, final String fileName, final RuleModel model, final String comment) {
try {
final Package pkg = moduleService.resolvePackage(context);
final String packageName = (pkg == null ? null : pkg.getPackageName());
model.setPackageName(packageName);
// Temporal fix for https://bugzilla.redhat.com/show_bug.cgi?id=998922
model.getImports().addImport(new Import("java.lang.Number"));
final org.uberfire.java.nio.file.Path nioPath = Paths.convert(context).resolve(fileName);
final Path newPath = Paths.convert(nioPath);
if (ioService.exists(nioPath)) {
throw new FileAlreadyExistsException(nioPath.toString());
}
ioService.write(nioPath, toSource(newPath, model), commentedOptionFactory.makeCommentedOption(comment));
return newPath;
} catch (Exception e) {
throw ExceptionUtilities.handleException(e);
}
}
use of org.kie.soup.project.datamodel.imports.Import in project drools-wb by kiegroup.
the class ImportsPage method removeImport.
@Override
public boolean removeImport(final String fqcn) {
// Check import can be removed
if (validator.isTypeUsed(fqcn)) {
return false;
}
// Filter DMO
final Import removedImport = new Import(fqcn);
model.getImports().removeImport(removedImport);
oracle.filter(model.getImports());
// Signal change to any other interested consumers (e.g. some editors support rendering of unknown fact-types)
importRemovedEvent.fire(new ImportRemovedEvent(oracle, removedImport));
return true;
}
use of org.kie.soup.project.datamodel.imports.Import in project drools-wb by kiegroup.
the class DecisionTableAnalyzerSubsumptionResolverTest method testNoIssues.
@Test
public void testNoIssues() throws Exception {
GuidedDecisionTable52 table52 = new ExtendedGuidedDecisionTableBuilder("org.test", new ArrayList<Import>(), "mytable").withConditionIntegerColumn("application", "LoanApplication", "amount", ">").withConditionIntegerColumn("application", "LoanApplication", "amount", "<=").withConditionIntegerColumn("application", "LoanApplication", "lengthYears", "==").withConditionIntegerColumn("application", "LoanApplication", "deposit", "<").withStringColumn("income", "IncomeSource", "type", "==").withActionSetField("application", "approved", DataType.TYPE_BOOLEAN).withActionSetField("application", "insuranceCost", DataType.TYPE_NUMERIC_INTEGER).withActionSetField("application", "approvedRate", DataType.TYPE_NUMERIC_INTEGER).withData(new Object[][] { { 1, "", "description", 131000, 200000, 30, 20000, "Asset", true, 0, 2 }, { 2, "", "description", 10000, 100000, 20, 2000, "Job", true, 0, 4 }, { 3, "", "description", 100001, 130000, 20, 3000, "Job", true, 10, 6 }, { 4, "", "description", null, null, null, null, null, null, null, null }, { 5, "", "description", null, null, null, null, null, null, null, null } }).buildTable();
Analyzer analyzer = analyzerProvider.makeAnalyser(table52);
analyzer.resetChecks();
analyzer.analyze();
assertDoesNotContain(CheckType.REDUNDANT_ROWS, analyzerProvider.getAnalysisReport());
}
Aggregations