use of org.drools.workbench.models.guided.dtree.shared.model.nodes.ConstraintNode in project drools by kiegroup.
the class GuidedDecisionTreeDRLPersistenceMarshallingTest method testValue_String.
@Test
public void testValue_String() throws Exception {
final String expected = "rule \"test_0\"" + "when\n" + " Person( stringField == \"Michael\" )\n" + "then\n" + "end";
final GuidedDecisionTree model = new GuidedDecisionTree();
model.setTreeName("test");
final TypeNode type = new TypeNodeImpl("Person");
final ConstraintNode c1 = new ConstraintNodeImpl("Person", "stringField", "==", new StringValue("Michael"));
model.setRoot(type);
type.addChild(c1);
final String drl = GuidedDecisionTreeDRLPersistence.getInstance().marshal(model);
assertEqualsIgnoreWhitespace(expected, drl);
}
use of org.drools.workbench.models.guided.dtree.shared.model.nodes.ConstraintNode in project drools by kiegroup.
the class GuidedDecisionTreeDRLPersistenceMarshallingTest method testValue_Short.
@Test
public void testValue_Short() throws Exception {
final String expected = "rule \"test_0\"" + "when\n" + " Person( shortField == 1000 )\n" + "then\n" + "end";
final GuidedDecisionTree model = new GuidedDecisionTree();
model.setTreeName("test");
final TypeNode type = new TypeNodeImpl("Person");
final ConstraintNode c1 = new ConstraintNodeImpl("Person", "shortField", "==", new ShortValue(new Short("1000")));
model.setRoot(type);
type.addChild(c1);
final String drl = GuidedDecisionTreeDRLPersistence.getInstance().marshal(model);
assertEqualsIgnoreWhitespace(expected, drl);
}
use of org.drools.workbench.models.guided.dtree.shared.model.nodes.ConstraintNode in project drools by kiegroup.
the class GuidedDecisionTreeDRLPersistenceMarshallingTest method testMultipleRules_2Rules.
@Test
public void testMultipleRules_2Rules() throws Exception {
final String expected = "rule \"test_0\"" + "when\n" + " Person( name == \"Michael\" )\n" + "then\n" + "end" + "rule \"test_1\"" + "when\n" + " Person( age == 41 )\n" + "then\n" + "end";
final GuidedDecisionTree model = new GuidedDecisionTree();
model.setTreeName("test");
final TypeNode type = new TypeNodeImpl("Person");
final ConstraintNode c1 = new ConstraintNodeImpl("Person", "name", "==", new StringValue("Michael"));
final ConstraintNode c2 = new ConstraintNodeImpl("Person", "age", "==", new IntegerValue(41));
model.setRoot(type);
type.addChild(c1);
type.addChild(c2);
final String drl = GuidedDecisionTreeDRLPersistence.getInstance().marshal(model);
assertEqualsIgnoreWhitespace(expected, drl);
}
use of org.drools.workbench.models.guided.dtree.shared.model.nodes.ConstraintNode in project drools-wb by kiegroup.
the class GuidedDecisionTreeEditorPresenter method editModelNode.
public void editModelNode(final Node node, final Command callback) {
if (node instanceof TypeNode) {
final EditTypePopup popup = new EditTypePopup((TypeNode) node, new com.google.gwt.user.client.Command() {
@Override
public void execute() {
callback.execute();
}
});
popup.show();
} else if (node instanceof ConstraintNode) {
final EditConstraintPopup popup = new EditConstraintPopup((ConstraintNode) node, oracle, new com.google.gwt.user.client.Command() {
@Override
public void execute() {
callback.execute();
}
});
popup.show();
} else if (node instanceof ActionInsertNode) {
final EditActionInsertPopup popup = new EditActionInsertPopup((ActionInsertNode) node, oracle, new com.google.gwt.user.client.Command() {
@Override
public void execute() {
callback.execute();
}
});
popup.show();
} else if (node instanceof ActionUpdateNode) {
final EditActionUpdatePopup popup = new EditActionUpdatePopup((ActionUpdateNode) node, oracle, new com.google.gwt.user.client.Command() {
@Override
public void execute() {
callback.execute();
}
});
popup.show();
} else if (node instanceof ActionRetractNode) {
final EditActionRetractPopup popup = new EditActionRetractPopup((ActionRetractNode) node, new com.google.gwt.user.client.Command() {
@Override
public void execute() {
callback.execute();
}
});
popup.show();
}
}
use of org.drools.workbench.models.guided.dtree.shared.model.nodes.ConstraintNode in project drools-wb by kiegroup.
the class ConstraintNodeFactory method getShape.
/**
* This returns a new Shape following a drag operation from the palette
* @param helper
* @return
*/
@Override
public WiresBaseShape getShape(final FactoryHelper helper) {
final ConstraintFactoryHelper cnHelper = (ConstraintFactoryHelper) helper;
final ConstraintNode node = cnHelper.getContext();
// drag proxy. We need to create a new instance of the ConstraintNode for use in the Decision Tree Widget
return new ConstraintShape(makeShape(), new ConstraintNodeImpl(node.getClassName(), node.getFieldName()), cnHelper.isReadOnly());
}
Aggregations