use of org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52 in project drools by kiegroup.
the class GuidedDTDRLPersistence method doAttribs.
void doAttribs(List<BaseColumn> allColumns, List<AttributeCol52> attributeCols, List<DTCellValue52> row, RuleModel rm) {
List<RuleAttribute> attribs = new ArrayList<RuleAttribute>();
for (int j = 0; j < attributeCols.size(); j++) {
AttributeCol52 at = attributeCols.get(j);
int index = allColumns.indexOf(at);
final DTCellValue52 dcv = row.get(index);
String cell = GuidedDTDRLUtilities.convertDTCellValueToString(dcv);
if (validateAttributeCell(cell)) {
// If instance of "otherwise" column then flag RuleModel as being negated
if (at.getAttribute().equals(GuidedDecisionTable52.NEGATE_RULE_ATTR)) {
rm.setNegated(Boolean.valueOf(cell));
} else {
attribs.add(new RuleAttribute(at.getAttribute(), cell));
}
}
}
if (attribs.size() > 0) {
rm.attributes = attribs.toArray(new RuleAttribute[attribs.size()]);
}
}
use of org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52 in project drools by kiegroup.
the class GuidedDecisionTableUpgradeHelper3 method upgrade.
/**
* Convert the Default Values in the Decision Table model
*
* @param source
* @return The new DTModel
*/
public GuidedDecisionTable52 upgrade(GuidedDecisionTable52 source) {
final GuidedDecisionTable52 destination = source;
for (BaseColumn column : source.getExpandedColumns()) {
DTColumnConfig52 dtColumn = null;
if (column instanceof MetadataCol52) {
dtColumn = (DTColumnConfig52) column;
} else if (column instanceof AttributeCol52) {
dtColumn = (DTColumnConfig52) column;
} else if (column instanceof ConditionCol52) {
dtColumn = (DTColumnConfig52) column;
} else if (column instanceof ActionCol52) {
dtColumn = (DTColumnConfig52) column;
}
if (dtColumn instanceof LimitedEntryCol) {
dtColumn = null;
}
if (dtColumn instanceof BRLVariableColumn) {
dtColumn = null;
}
if (dtColumn != null) {
final String legacyDefaultValue = dtColumn.defaultValue;
if (legacyDefaultValue != null) {
dtColumn.setDefaultValue(new DTCellValue52(legacyDefaultValue));
dtColumn.defaultValue = null;
}
}
}
return destination;
}
use of org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52 in project drools by kiegroup.
the class DecisionTableHitPolicyEnhancer method addActivationGroup.
private void addActivationGroup(final String activationGroupType) {
final AttributeCol52 attributeCol52 = new AttributeCol52();
attributeCol52.setAttribute(GuidedDecisionTable52.ACTIVATION_GROUP_ATTR);
dtable.getAttributeCols().add(attributeCol52);
final int columnIndex = dtable.getExpandedColumns().indexOf(attributeCol52);
for (final List<DTCellValue52> row : dtable.getData()) {
row.add(columnIndex, new DTCellValue52(activationGroupType + " " + dtable.getTableName()));
}
}
use of org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52 in project drools by kiegroup.
the class DecisionTableHitPolicyEnhancer method makeSalienceColumn.
private int makeSalienceColumn() {
final AttributeCol52 attributeCol = new AttributeCol52();
attributeCol.setAttribute("salience");
dtable.getAttributeCols().add(attributeCol);
int columnIndex = dtable.getExpandedColumns().indexOf(attributeCol);
for (final List<DTCellValue52> row : dtable.getData()) {
row.add(columnIndex, new DTCellValue52(0));
}
return columnIndex;
}
use of org.drools.workbench.models.guided.dtable.shared.model.AttributeCol52 in project drools by kiegroup.
the class GuidedDTDRLPersistenceTest method testInOperator.
@Test
public void testInOperator() {
GuidedDecisionTable52 dt = new GuidedDecisionTable52();
dt.setTableName("michael");
AttributeCol52 attr = new AttributeCol52();
attr.setAttribute("salience");
attr.setDefaultValue(new DTCellValue52("66"));
dt.getAttributeCols().add(attr);
Pattern52 p1 = new Pattern52();
p1.setBoundName("f1");
p1.setFactType("Driver");
ConditionCol52 con = new ConditionCol52();
con.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
con.setFactField("age");
con.setHeader("Driver f1 age");
con.setOperator("==");
p1.getChildColumns().add(con);
ConditionCol52 con2 = new ConditionCol52();
con2.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
con2.setFactField("name");
con2.setHeader("Driver f1 name");
con2.setOperator("in");
p1.getChildColumns().add(con2);
ConditionCol52 con3 = new ConditionCol52();
con3.setConstraintValueType(BaseSingleFieldConstraint.TYPE_RET_VALUE);
con3.setFactField("rating");
con3.setHeader("Driver rating");
con3.setOperator("==");
p1.getChildColumns().add(con3);
ConditionCol52 con4 = new ConditionCol52();
con4.setConstraintValueType(BaseSingleFieldConstraint.TYPE_PREDICATE);
con4.setHeader("Driver 2 pimp");
con4.setFactField("(not needed)");
p1.getChildColumns().add(con4);
dt.getConditions().add(p1);
ActionInsertFactCol52 ins = new ActionInsertFactCol52();
ins.setBoundName("ins");
ins.setFactType("Cheese");
ins.setFactField("price");
ins.setType(DataType.TYPE_NUMERIC_INTEGER);
dt.getActionCols().add(ins);
ActionRetractFactCol52 ret = new ActionRetractFactCol52();
dt.getActionCols().add(ret);
ActionSetFieldCol52 set = new ActionSetFieldCol52();
set.setBoundName("f1");
set.setFactField("goo1");
set.setType(DataType.TYPE_STRING);
dt.getActionCols().add(set);
ActionSetFieldCol52 set2 = new ActionSetFieldCol52();
set2.setBoundName("f1");
set2.setFactField("goo2");
set2.setDefaultValue(new DTCellValue52("whee"));
set2.setType(DataType.TYPE_STRING);
dt.getActionCols().add(set2);
dt.setData(DataUtilities.makeDataLists(new String[][] { new String[] { "1", "desc", "42", "33", "michael, manik", "age * 0.2", "age > 7", "6.60", "true", "gooVal1", "f2" }, new String[] { "2", "desc", "", "39", "bob, frank", "age * 0.3", "age > 7", "6.60", "", "gooVal1", null } }));
GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
String drl = p.marshal(dt);
assertTrue(drl.indexOf("name in ( \"michael\",") > 0);
}
Aggregations