Search in sources :

Example 6 with FieldCondition

use of org.drools.verifier.core.index.model.FieldCondition in project drools by kiegroup.

the class ConditionsListenerTest method testListen.

@Test
public void testListen() throws Exception {
    conditions.add(new FieldCondition(new Field(mock(ObjectField.class), "Person", "String", "name", configuration), new Column(1, configuration), "==", new Values<>(10), configuration));
    verify(allListener).onAllChanged(anyCollection());
}
Also used : FieldCondition(org.drools.verifier.core.index.model.FieldCondition) ObjectField(org.drools.verifier.core.index.model.ObjectField) Field(org.drools.verifier.core.index.model.Field) Column(org.drools.verifier.core.index.model.Column) ObjectField(org.drools.verifier.core.index.model.ObjectField) Values(org.drools.verifier.core.index.keys.Values) Test(org.junit.Test)

Example 7 with FieldCondition

use of org.drools.verifier.core.index.model.FieldCondition in project drools-wb by kiegroup.

the class RegularCellUpdateManager method updateCondition.

@Override
protected boolean updateCondition(final Condition condition) {
    final Values oldValues = condition.getValues();
    Values values = null;
    final DTCellValue52 cell = model.getData().get(coordinate.getRow()).get(coordinate.getCol());
    final BaseColumn baseColumn = model.getExpandedColumns().get(coordinate.getCol());
    if (baseColumn instanceof ConditionCol52 && condition instanceof FieldCondition) {
        final DTCellValue52 realCellValue = getRealCellValue((ConditionCol52) baseColumn, cell);
        final Optional<String> operatorFromCell = Utils.findOperatorFromCell(realCellValue);
        if (operatorFromCell.isPresent()) {
            ((FieldCondition) condition).setOperator(operatorFromCell.get());
        }
        values = useResolver(configuration, (FieldCondition) condition, realCellValue, (ConditionCol52) baseColumn);
    } else {
        values = getValue(cell);
    }
    if (values == null && oldValues == null) {
        return false;
    } else if (values == null || oldValues == null) {
        condition.setValue(values);
        return true;
    } else if (values.isThereChanges(oldValues)) {
        condition.setValue(values);
        return true;
    } else {
        return false;
    }
}
Also used : FieldCondition(org.drools.verifier.core.index.model.FieldCondition) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Values(org.drools.verifier.core.index.keys.Values) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)

Aggregations

FieldCondition (org.drools.verifier.core.index.model.FieldCondition)7 Column (org.drools.verifier.core.index.model.Column)6 Test (org.junit.Test)5 Field (org.drools.verifier.core.index.model.Field)4 ObjectField (org.drools.verifier.core.index.model.ObjectField)4 ConditionsInspectorMultiMap (org.drools.verifier.core.cache.inspectors.condition.ConditionsInspectorMultiMap)3 Values (org.drools.verifier.core.index.keys.Values)3 Condition (org.drools.verifier.core.index.model.Condition)2 ArrayList (java.util.ArrayList)1 Conditions (org.drools.verifier.core.index.model.Conditions)1 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)1 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)1 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)1