Search in sources :

Example 1 with RuleInspector

use of org.drools.workbench.services.verifier.core.cache.inspectors.RuleInspector in project drools-wb by kiegroup.

the class RuleInspectorCache method addRule.

public RuleInspector addRule(final Rule rule) {
    this.index.getRules().add(rule);
    final RuleInspector ruleInspector = new RuleInspector(rule, checkStorage, this, configuration);
    add(ruleInspector);
    return ruleInspector;
}
Also used : RuleInspector(org.drools.workbench.services.verifier.core.cache.inspectors.RuleInspector)

Example 2 with RuleInspector

use of org.drools.workbench.services.verifier.core.cache.inspectors.RuleInspector in project drools-wb by kiegroup.

the class RuleInspectorCacheTest method assertContainsRowNumbers.

private void assertContainsRowNumbers(final Collection<RuleInspector> all, final int... numbers) {
    final ArrayList<Integer> rowNumbers = new ArrayList<>();
    for (final RuleInspector ruleInspector : all) {
        final int rowIndex = ruleInspector.getRowIndex();
        rowNumbers.add(rowIndex);
    }
    for (final int number : numbers) {
        assertTrue(rowNumbers.toString(), rowNumbers.contains(number));
    }
}
Also used : RuleInspector(org.drools.workbench.services.verifier.core.cache.inspectors.RuleInspector) ArrayList(java.util.ArrayList)

Example 3 with RuleInspector

use of org.drools.workbench.services.verifier.core.cache.inspectors.RuleInspector in project drools-wb by kiegroup.

the class PairCheckStorage method removeByOther.

private List<PairCheckBundle> removeByOther(final RuleInspector ruleInspector) {
    final MultiSet<RuleInspector, PairCheckBundle> removedMap = pairChecksByOtherRowInspector.remove(ruleInspector);
    if (removedMap != null) {
        for (final RuleInspector inspector : removedMap.keys()) {
            final Collection<PairCheckBundle> collection = removedMap.get(inspector);
            pairChecks.get(inspector).removeAll(collection);
            getByOther(inspector).remove(ruleInspector);
        }
        return removedMap.allValues();
    } else {
        return Collections.EMPTY_LIST;
    }
}
Also used : RuleInspector(org.drools.workbench.services.verifier.core.cache.inspectors.RuleInspector)

Example 4 with RuleInspector

use of org.drools.workbench.services.verifier.core.cache.inspectors.RuleInspector in project drools-wb by kiegroup.

the class CheckRunManagerTest method testOnlyTestChanges.

@Test
public void testOnlyTestChanges() throws Exception {
    // First run
    this.checkRunManager.run(null, null);
    RuleInspector newRuleInspector = mockRowInspector(3);
    ruleInspectors.add(newRuleInspector);
    this.checkRunManager.addChecks(newRuleInspector.getChecks());
    assertNoIssues(newRuleInspector);
    // Second run
    this.checkRunManager.run(null, null);
    assertHasIssues(newRuleInspector);
    assertEquals(7, ruleInspector1.getChecks().size());
    assertEquals(7, newRuleInspector.getChecks().size());
}
Also used : RuleInspector(org.drools.workbench.services.verifier.core.cache.inspectors.RuleInspector) Test(org.junit.Test)

Example 5 with RuleInspector

use of org.drools.workbench.services.verifier.core.cache.inspectors.RuleInspector in project drools-wb by kiegroup.

the class SingleRangeCheck method partition.

private Map<PartitionKey, List<RuleInspector>> partition(Collection<ObjectField> partitionFields, Collection<RuleInspector> rules, int conditionIndex) {
    List<PartitionKey> keysWithNull = new ArrayList<>();
    Map<PartitionKey, List<RuleInspector>> partitions = new HashMap<>();
    for (RuleInspector rule : rules) {
        PartitionKey key = getPartitionKey(partitionFields, rule, conditionIndex);
        partitions.computeIfAbsent(key, k -> {
            if (k.hasNulls()) {
                keysWithNull.add(k);
            }
            return new ArrayList<>();
        }).add(rule);
    }
    for (PartitionKey key : keysWithNull) {
        for (Map.Entry<PartitionKey, List<RuleInspector>> partition : partitions.entrySet()) {
            if (key.subsumes(partition.getKey())) {
                partition.getValue().addAll(partitions.get(key));
            }
        }
    }
    keysWithNull.forEach(partitions::remove);
    return partitions;
}
Also used : IntStream(java.util.stream.IntStream) Operator(org.drools.workbench.services.verifier.api.client.relations.Operator) Arrays(java.util.Arrays) SortedSet(java.util.SortedSet) CheckBase(org.drools.workbench.services.verifier.core.checks.base.CheckBase) Issue(org.drools.workbench.services.verifier.api.client.reporting.Issue) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) HashMap(java.util.HashMap) AnalyzerConfiguration(org.drools.workbench.services.verifier.api.client.configuration.AnalyzerConfiguration) ObjectField(org.drools.workbench.services.verifier.api.client.index.ObjectField) Function(java.util.function.Function) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) Severity(org.drools.workbench.services.verifier.api.client.reporting.Severity) HashSet(java.util.HashSet) RuleInspector(org.drools.workbench.services.verifier.core.cache.inspectors.RuleInspector) FieldCondition(org.drools.workbench.services.verifier.api.client.index.FieldCondition) Operator.resolve(org.drools.workbench.services.verifier.api.client.relations.Operator.resolve) Map(java.util.Map) CheckType(org.drools.workbench.services.verifier.api.client.reporting.CheckType) Collectors.toSet(java.util.stream.Collectors.toSet) Iterator(java.util.Iterator) Collection(java.util.Collection) Set(java.util.Set) ConditionInspector(org.drools.workbench.services.verifier.core.cache.inspectors.condition.ConditionInspector) Objects(java.util.Objects) Consumer(java.util.function.Consumer) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Stream(java.util.stream.Stream) Entry(java.util.Map.Entry) Comparator(java.util.Comparator) HashMap(java.util.HashMap) RuleInspector(org.drools.workbench.services.verifier.core.cache.inspectors.RuleInspector) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

RuleInspector (org.drools.workbench.services.verifier.core.cache.inspectors.RuleInspector)10 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Rule (org.drools.workbench.services.verifier.api.client.index.Rule)2 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Objects (java.util.Objects)1 Set (java.util.Set)1 SortedSet (java.util.SortedSet)1 TreeSet (java.util.TreeSet)1 Consumer (java.util.function.Consumer)1 Function (java.util.function.Function)1 Collectors.groupingBy (java.util.stream.Collectors.groupingBy)1 Collectors.toList (java.util.stream.Collectors.toList)1