Search in sources :

Example 1 with Field

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

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

the class FieldInspectorRelationsTest method testSubsumpt02.

@Test
public void testSubsumpt02() throws Exception {
    final FieldInspector x = new FieldInspector(new Field(mock(ObjectField.class), "org.Address", "String", "name", configurationMock), mock(RuleInspectorUpdater.class), mock(AnalyzerConfiguration.class));
    assertFalse(x.subsumes(b));
    assertFalse(b.subsumes(x));
}
Also used : Field(org.drools.workbench.services.verifier.api.client.index.Field) ObjectField(org.drools.workbench.services.verifier.api.client.index.ObjectField) AnalyzerConfiguration(org.drools.workbench.services.verifier.api.client.configuration.AnalyzerConfiguration) Test(org.junit.Test)

Example 3 with Field

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

the class ActionBuilder method addAction.

private Action addAction(final ActionCol52 actionCol, final DTCellValue52 visibleCellValue) throws BuildException {
    final Field field = resolveField(actionCol);
    final Action action = buildAction(field, visibleCellValue);
    field.getActions().add(action);
    return action;
}
Also used : Field(org.drools.workbench.services.verifier.api.client.index.Field) BRLAction(org.drools.workbench.services.verifier.api.client.index.BRLAction) FieldAction(org.drools.workbench.services.verifier.api.client.index.FieldAction) RetractAction(org.drools.workbench.services.verifier.api.client.index.RetractAction) Action(org.drools.workbench.services.verifier.api.client.index.Action)

Example 4 with Field

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

the class ConditionsInspectorTest method testSubsume003.

@Test
public void testSubsume003() throws Exception {
    final Field nameField = new Field(new ObjectField("Person", "String", "name", configurationMock), "Person", "String", "name", configurationMock);
    final Field lastNameField = new Field(new ObjectField("Person", "String", "lastName", configurationMock), "Person", "String", "lastName", configurationMock);
    final ConditionsInspectorMultiMap a = getConditions(new ComparableConditionInspector<String>(new FieldCondition(nameField, mock(Column.class), "==", new Values<>("Toni"), configurationMock), configurationMock));
    final ConditionsInspectorMultiMap b = getConditions(new ComparableConditionInspector<Integer>(new FieldCondition(field, mock(Column.class), "==", new Values<>(12), configurationMock), configurationMock), new ComparableConditionInspector<String>(new FieldCondition(nameField, mock(Column.class), "==", new Values<>("Toni"), configurationMock), configurationMock), new ComparableConditionInspector<String>(new FieldCondition(lastNameField, mock(Column.class), "==", new Values<>("Rikkola"), configurationMock), configurationMock));
    assertFalse(a.subsumes(b));
    assertTrue(b.subsumes(a));
}
Also used : ObjectField(org.drools.workbench.services.verifier.api.client.index.ObjectField) Field(org.drools.workbench.services.verifier.api.client.index.Field) FieldCondition(org.drools.workbench.services.verifier.api.client.index.FieldCondition) ConditionsInspectorMultiMap(org.drools.workbench.services.verifier.core.cache.inspectors.condition.ConditionsInspectorMultiMap) Column(org.drools.workbench.services.verifier.api.client.index.Column) ObjectField(org.drools.workbench.services.verifier.api.client.index.ObjectField) Test(org.junit.Test)

Example 5 with Field

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

the class ConditionsInspectorTest method testSubsume002.

@Test
public void testSubsume002() throws Exception {
    final ConditionsInspectorMultiMap a = getConditions(new ComparableConditionInspector<Integer>(new FieldCondition(field, mock(Column.class), "==", new Values<>(1), configurationMock), configurationMock));
    final ConditionsInspectorMultiMap b = getConditions(new ComparableConditionInspector<Integer>(new FieldCondition(field, mock(Column.class), "==", new Values<>(1), configurationMock), configurationMock), new ComparableConditionInspector<Integer>(new FieldCondition(new Field(mock(ObjectField.class), "Person", "Integer", "balance", configurationMock), mock(Column.class), "==", new Values<>(111111111), configurationMock), configurationMock));
    assertFalse(a.subsumes(b));
    assertTrue(b.subsumes(a));
}
Also used : FieldCondition(org.drools.workbench.services.verifier.api.client.index.FieldCondition) ObjectField(org.drools.workbench.services.verifier.api.client.index.ObjectField) Field(org.drools.workbench.services.verifier.api.client.index.Field) ConditionsInspectorMultiMap(org.drools.workbench.services.verifier.core.cache.inspectors.condition.ConditionsInspectorMultiMap) Column(org.drools.workbench.services.verifier.api.client.index.Column) Test(org.junit.Test)

Aggregations

Field (org.drools.workbench.services.verifier.api.client.index.Field)25 ObjectField (org.drools.workbench.services.verifier.api.client.index.ObjectField)21 Test (org.junit.Test)18 AnalyzerConfigurationMock (org.drools.workbench.services.verifier.core.checks.AnalyzerConfigurationMock)17 Column (org.drools.workbench.services.verifier.api.client.index.Column)3 FieldCondition (org.drools.workbench.services.verifier.api.client.index.FieldCondition)3 Before (org.junit.Before)3 Date (java.util.Date)2 AnalyzerConfiguration (org.drools.workbench.services.verifier.api.client.configuration.AnalyzerConfiguration)2 Action (org.drools.workbench.services.verifier.api.client.index.Action)2 Condition (org.drools.workbench.services.verifier.api.client.index.Condition)2 FieldAction (org.drools.workbench.services.verifier.api.client.index.FieldAction)2 ConditionsInspectorMultiMap (org.drools.workbench.services.verifier.core.cache.inspectors.condition.ConditionsInspectorMultiMap)2 ArrayList (java.util.ArrayList)1 BRLAction (org.drools.workbench.services.verifier.api.client.index.BRLAction)1 Fields (org.drools.workbench.services.verifier.api.client.index.Fields)1 RetractAction (org.drools.workbench.services.verifier.api.client.index.RetractAction)1 Values (org.drools.workbench.services.verifier.api.client.index.keys.Values)1