use of org.drools.verifier.core.index.model.Condition in project drools-wb by kiegroup.
the class RuleBuilder method resolveColumns.
private void resolveColumns() throws BuildException {
int columnIndex = 0;
List<BaseColumn> expandedColumns = model.getExpandedColumns();
for (final BaseColumn baseColumn : expandedColumns) {
try {
if (baseColumn instanceof AttributeCol52) {
final String attribute = ((AttributeCol52) baseColumn).getAttribute();
final DTCellValue52 realCellValue = getRealCellValue((AttributeCol52) baseColumn, row.get(columnIndex));
final Optional<RuleAttribute> ruleAttribute = AttributeBuilder.build(columnIndex, configuration, attribute, realCellValue);
if (ruleAttribute.isPresent()) {
rule.addRuleAttribute(ruleAttribute.get());
}
} else if (baseColumn instanceof ConditionCol52) {
final Condition condition = builderFactory.getConditionBuilder().with((ConditionCol52) baseColumn).with(rule).with(row).with(columnIndex).build();
rule.getConditions().add(condition);
} else if (baseColumn instanceof ActionCol52) {
final Action action = builderFactory.getActionBuilder().with(rule).with((ActionCol52) baseColumn).with(row).with(columnIndex).build();
rule.getActions().add(action);
}
columnIndex++;
} catch (BuildException e) {
throw e;
} catch (Exception e) {
throw new BuildException("Could not resolve column: Index: " + columnIndex + " header: " + baseColumn.getHeader() + " error message: " + e.getMessage());
}
}
}
use of org.drools.verifier.core.index.model.Condition in project drools by kiegroup.
the class FieldInspectorUpdateTest method makeCondition.
private FieldCondition makeCondition(final Field field) {
final FieldCondition fieldAction = new FieldCondition(field, mock(Column.class), "==", new Values(11), configurationMock);
final ArrayList<Condition> actionsList = new ArrayList<>();
actionsList.add(fieldAction);
final Conditions conditions = new Conditions(actionsList);
when(field.getConditions()).thenReturn(conditions);
return fieldAction;
}
use of org.drools.verifier.core.index.model.Condition in project drools by kiegroup.
the class RuleInspectorCache method deleteColumns.
public void deleteColumns(final int firstColumnIndex) {
final Collection<Column> all = index.getColumns().where(Column.index().is(firstColumnIndex)).select().all();
final Fields.FieldSelector fieldSelector = index.getRules().where(UUIDMatcher.uuid().any()).select().patterns().where(UUIDMatcher.uuid().any()).select().fields().where(UUIDMatcher.uuid().any()).select();
final ArrayList<Action> actions = new ArrayList<>();
final ArrayList<Condition> conditions = new ArrayList<>();
for (final Field field : fieldSelector.all()) {
for (final Column column : all) {
final Collection<Action> all1 = field.getActions().where(Action.columnUUID().is(column.getUuidKey())).select().all();
final Collection<Condition> all2 = field.getConditions().where(Condition.columnUUID().is(column.getUuidKey())).select().all();
actions.addAll(all1);
conditions.addAll(all2);
}
}
for (final Action action : actions) {
action.getUuidKey().retract();
}
for (final Condition condition : conditions) {
condition.getUuidKey().retract();
}
for (final Column column : all) {
column.getUuidKey().retract();
}
reset();
}
use of org.drools.verifier.core.index.model.Condition in project drools by kiegroup.
the class ConditionsListenerTest method testUpdate.
@Test
public void testUpdate() throws Exception {
final Condition condition = new FieldCondition(new Field(mock(ObjectField.class), "Person", "String", "name", configuration), new Column(1, configuration), "==", new Values<>(10), configuration);
conditions.add(condition);
reset(allListener);
condition.setValue(new Values<>(20));
verify(allListener).onAllChanged(anyCollection());
}
use of org.drools.verifier.core.index.model.Condition in project drools-wb by kiegroup.
the class CellBuilder method build.
public void build() throws BuildException {
if (baseColumn instanceof ActionCol52) {
final Action action = builderFactory.getActionBuilder().with(rule).with(row).with(columnIndex).with((ActionCol52) baseColumn).build();
rule.getActions().add(action);
} else if (baseColumn instanceof ConditionCol52) {
if (baseColumn instanceof BRLConditionVariableColumn) {
final Condition condition = builderFactory.getBRLConditionBuilder().with((BRLConditionVariableColumn) baseColumn).with(getRealCellValue((BRLConditionVariableColumn) baseColumn, row.get(columnIndex))).with(columnIndex).build();
rule.getConditions().add(condition);
} else {
final Condition condition = builderFactory.getFieldConditionsBuilder().with(resolvePattern(rule)).with((ConditionCol52) baseColumn).with(getRealCellValue((ConditionCol52) baseColumn, row.get(columnIndex))).with(columnIndex).build();
rule.getConditions().add(condition);
}
}
}
Aggregations