Search in sources :

Example 1 with Conditions

use of org.drools.workbench.services.verifier.api.client.index.Conditions in project drools-wb by kiegroup.

the class RuleInspector method isDeficient.

@Override
public boolean isDeficient(final RuleInspector other) {
    if (other.atLeastOneActionHasAValue() && !getActionsInspectors().conflicts(other.getActionsInspectors())) {
        return false;
    }
    final Collection<Condition> allConditionsFromTheOtherRule = other.rule.getConditions().where(Condition.value().any()).select().all();
    if (allConditionsFromTheOtherRule.isEmpty()) {
        return true;
    } else {
        for (final Condition condition : allConditionsFromTheOtherRule) {
            if (condition.getValues() == null) {
                continue;
            }
            if (condition instanceof FieldCondition) {
                final FieldCondition fieldCondition = (FieldCondition) condition;
                final Conditions conditions = rule.getPatterns().where(Pattern.name().is(fieldCondition.getField().getFactType())).select().fields().where(Field.name().is(fieldCondition.getField().getName())).select().conditions();
                if (conditions.where(Condition.value().any()).select().exists()) {
                    return false;
                }
            }
        }
        return true;
    }
}
Also used : FieldCondition(org.drools.workbench.services.verifier.api.client.index.FieldCondition) BRLCondition(org.drools.workbench.services.verifier.api.client.index.BRLCondition) Condition(org.drools.workbench.services.verifier.api.client.index.Condition) FieldCondition(org.drools.workbench.services.verifier.api.client.index.FieldCondition) Conditions(org.drools.workbench.services.verifier.api.client.index.Conditions)

Example 2 with Conditions

use of org.drools.workbench.services.verifier.api.client.index.Conditions in project drools-wb 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;
}
Also used : FieldCondition(org.drools.workbench.services.verifier.api.client.index.FieldCondition) Condition(org.drools.workbench.services.verifier.api.client.index.Condition) FieldCondition(org.drools.workbench.services.verifier.api.client.index.FieldCondition) Column(org.drools.workbench.services.verifier.api.client.index.Column) Values(org.drools.workbench.services.verifier.api.client.index.keys.Values) ArrayList(java.util.ArrayList) Conditions(org.drools.workbench.services.verifier.api.client.index.Conditions)

Aggregations

Condition (org.drools.workbench.services.verifier.api.client.index.Condition)2 Conditions (org.drools.workbench.services.verifier.api.client.index.Conditions)2 FieldCondition (org.drools.workbench.services.verifier.api.client.index.FieldCondition)2 ArrayList (java.util.ArrayList)1 BRLCondition (org.drools.workbench.services.verifier.api.client.index.BRLCondition)1 Column (org.drools.workbench.services.verifier.api.client.index.Column)1 Values (org.drools.workbench.services.verifier.api.client.index.keys.Values)1