Search in sources :

Example 1 with Condition

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

Example 2 with Condition

use of org.drools.workbench.services.verifier.api.client.index.Condition 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 3 with Condition

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

the class RuleBuilder method resolveColumns.

private void resolveColumns() throws BuildException {
    int columnIndex = 0;
    for (final BaseColumn baseColumn : model.getExpandedColumns()) {
        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++;
    }
}
Also used : Condition(org.drools.workbench.services.verifier.api.client.index.Condition) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Action(org.drools.workbench.services.verifier.api.client.index.Action) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)

Example 4 with Condition

use of org.drools.workbench.services.verifier.api.client.index.Condition 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)

Example 5 with Condition

use of org.drools.workbench.services.verifier.api.client.index.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);
        }
    }
}
Also used : Condition(org.drools.workbench.services.verifier.api.client.index.Condition) Action(org.drools.workbench.services.verifier.api.client.index.Action) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) BRLConditionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn)

Aggregations

Condition (org.drools.workbench.services.verifier.api.client.index.Condition)6 Action (org.drools.workbench.services.verifier.api.client.index.Action)3 FieldCondition (org.drools.workbench.services.verifier.api.client.index.FieldCondition)3 ArrayList (java.util.ArrayList)2 ActionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionCol52)2 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)2 Column (org.drools.workbench.services.verifier.api.client.index.Column)2 Conditions (org.drools.workbench.services.verifier.api.client.index.Conditions)2 Field (org.drools.workbench.services.verifier.api.client.index.Field)2 BRLConditionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn)1 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)1 BRLCondition (org.drools.workbench.services.verifier.api.client.index.BRLCondition)1 Fields (org.drools.workbench.services.verifier.api.client.index.Fields)1 Values (org.drools.workbench.services.verifier.api.client.index.keys.Values)1