use of org.drools.workbench.services.verifier.api.client.index.ObjectField 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));
}
use of org.drools.workbench.services.verifier.api.client.index.ObjectField in project drools-wb by kiegroup.
the class FieldInspectorUpdateTest method setUp.
@Before
public void setUp() throws Exception {
configurationMock = new AnalyzerConfigurationMock();
final Field field = spy(new Field(objectField, "org.Person", "String", "name", configurationMock));
fieldCondition = makeCondition(field);
fieldAction = makeAction(field);
new FieldInspector(field, ruleInspectorUpdater, new AnalyzerConfigurationMock());
}
use of org.drools.workbench.services.verifier.api.client.index.ObjectField in project drools-wb by kiegroup.
the class Utils method resolveObjectField.
public static ObjectField resolveObjectField(final ObjectType objectType, final String fieldType, final String factField, final AnalyzerConfiguration configuration) {
final ObjectField first = objectType.getFields().where(Field.name().is(factField)).select().first();
if (first == null) {
final ObjectField objectField = new ObjectField(objectType.getType(), fieldType, factField, configuration);
objectType.getFields().add(objectField);
return objectField;
} else {
return first;
}
}
use of org.drools.workbench.services.verifier.api.client.index.ObjectField 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;
}
use of org.drools.workbench.services.verifier.api.client.index.ObjectField in project drools-wb by kiegroup.
the class SingleRangeCheck method checkRanges.
private void checkRanges(Collection<ObjectField> rangeFields, Map<PartitionKey, List<RuleInspector>> partitions, int conditionIndex) {
for (Map.Entry<PartitionKey, List<RuleInspector>> partition : partitions.entrySet()) {
List<List<? extends Range<?>>> dimensions = new ArrayList<>();
for (ObjectField field : rangeFields) {
if ("Integer".equals(field.getFieldType())) {
checkMonodimensionalRange(partition, dimensions, field, conditionIndex, IntegerRange::new, Integer.MIN_VALUE, Integer.MAX_VALUE);
} else {
checkMonodimensionalRange(partition, dimensions, field, conditionIndex, NumericRange::new, Double.MIN_VALUE, Double.MAX_VALUE);
}
}
checkBidimensionalRanges(partition, dimensions);
}
}
Aggregations