use of org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52 in project drools-wb by kiegroup.
the class DefaultGuidedDecisionTableLinkManagerTest method fieldConstraintWithActionBRLFragmentFieldWithoutTemplateKey.
@Test
public void fieldConstraintWithActionBRLFragmentFieldWithoutTemplateKey() {
// Columns: Row#[0], Description[1], Action[2]
final GuidedDecisionTable52 dt1 = new GuidedDecisionTable52();
final BRLActionColumn brl = new BRLActionColumn();
final ActionInsertFact aif = new ActionInsertFact();
aif.setFactType("Fact");
aif.addFieldValue(new ActionFieldValue() {
{
setField("field");
setValue("10");
setNature(FieldNatureType.TYPE_LITERAL);
}
});
brl.setDefinition(new ArrayList<IAction>() {
{
add(aif);
}
});
brl.getChildColumns().add(new BRLActionVariableColumn("", DataType.TYPE_BOOLEAN));
dt1.getActionCols().add(brl);
// Columns: Row#[0], Description[1], Condition[2]
final GuidedDecisionTable52 dt2 = new GuidedDecisionTable52();
final Pattern52 p2 = new Pattern52();
p2.setBoundName("$f");
p2.setFactType("Fact");
final ConditionCol52 p2c1 = new ConditionCol52();
p2c1.setFactField("field");
p2.getChildColumns().add(p2c1);
dt2.getConditions().add(p2);
manager.link(dt1, dt2, (s, t) -> {
assertEquals(2, s);
assertEquals(2, t);
});
}
use of org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52 in project drools-wb by kiegroup.
the class DefaultGuidedDecisionTableLinkManagerTest method fieldConstraintLinksToActionUpdateField.
@Test
public void fieldConstraintLinksToActionUpdateField() {
// Columns: Row#[0], Description[1], Condition[2], Action[3]
final GuidedDecisionTable52 dt1 = new GuidedDecisionTable52();
final Pattern52 p1 = new Pattern52();
p1.setBoundName("$f");
p1.setFactType("Fact");
final ConditionCol52 p1c1 = new ConditionCol52();
p1c1.setFactField("field");
p1.getChildColumns().add(p1c1);
dt1.getConditions().add(p1);
final ActionSetFieldCol52 asf = new ActionSetFieldCol52();
asf.setBoundName("$f");
asf.setFactField("field");
dt1.getActionCols().add(asf);
// Columns: Row#[0], Description[1], Condition[2]
final GuidedDecisionTable52 dt2 = new GuidedDecisionTable52();
final Pattern52 p2 = new Pattern52();
p2.setBoundName("$f");
p2.setFactType("Fact");
final ConditionCol52 p2c1 = new ConditionCol52();
p2c1.setFactField("field");
p2.getChildColumns().add(p2c1);
dt2.getConditions().add(p2);
manager.link(dt1, dt2, (s, t) -> {
assertEquals(3, s);
assertEquals(2, t);
});
}
use of org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52 in project drools-wb by kiegroup.
the class GuidedDecisionTableEditorServiceImpl method constructContent.
@Override
protected GuidedDecisionTableEditorContent constructContent(Path path, Overview overview) {
final GuidedDecisionTable52 model = load(path);
final PackageDataModelOracle oracle = dataModelService.getDataModel(path);
final PackageDataModelOracleBaselinePayload dataModel = new PackageDataModelOracleBaselinePayload();
// Get FQCN's used by model
final GuidedDecisionTableModelVisitor visitor = new GuidedDecisionTableModelVisitor(model);
final Set<String> consumedFQCNs = visitor.getConsumedModelClasses();
// Get FQCN's used by Globals
consumedFQCNs.addAll(oracle.getPackageGlobals().values());
// Get FQCN's of collections defined in project settings
// they can be used in From Collect expressions
consumedFQCNs.addAll(oracle.getModuleCollectionTypes().entrySet().stream().filter(entry -> entry.getValue()).map(entry -> entry.getKey()).collect(Collectors.toSet()));
DataModelOracleUtilities.populateDataModel(oracle, dataModel, consumedFQCNs);
final Set<PortableWorkDefinition> workItemDefinitions = workItemsService.loadWorkItemDefinitions(path);
// Signal opening to interested parties
resourceOpenedEvent.fire(new ResourceOpenedEvent(path, safeSessionInfo));
return new GuidedDecisionTableEditorContent(model, workItemDefinitions, overview, dataModel);
}
use of org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52 in project drools-wb by kiegroup.
the class GuidedDecisionTableFileIndexer method fillIndexBuilder.
@Override
public DefaultIndexBuilder fillIndexBuilder(final Path path) throws Exception {
final String content = ioService.readAllString(path);
final GuidedDecisionTable52 model = GuidedDTXMLPersistence.getInstance().unmarshal(content);
final String drl = GuidedDTDRLPersistence.getInstance().marshal(model);
return fillDrlIndexBuilder(path, drl);
}
use of org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52 in project drools-wb by kiegroup.
the class GuidedDecisionTableEditorServiceImplTest method checkSave.
@Test
@SuppressWarnings("unchecked")
public void checkSave() {
final Path path = mock(Path.class);
final GuidedDecisionTable52 model = new GuidedDecisionTable52();
final Metadata metadata = mock(Metadata.class);
final String comment = "comment";
when(path.toURI()).thenReturn("default://project/src/main/resources/mypackage/dtable.gdst");
service.save(path, model, metadata, comment);
verify(ioService, times(1)).write(any(org.uberfire.java.nio.file.Path.class), any(String.class), any(Map.class), any(CommentedOption.class));
assertEquals("mypackage", model.getPackageName());
}
Aggregations