use of org.drools.core.rule.AbstractCompositeConstraint in project drools by kiegroup.
the class BuildUtils method gatherTemporalRelationships.
private void gatherTemporalRelationships(List<?> constraints, Map<Declaration, Interval> temporal) {
for (Object obj : constraints) {
if (obj instanceof IntervalProviderConstraint) {
IntervalProviderConstraint constr = (IntervalProviderConstraint) obj;
if (constr.isTemporal()) {
// if a constraint already exists, calculate the intersection
Declaration[] decs = constr.getRequiredDeclarations();
// only calculate relationships to other event patterns
if (decs.length > 0 && decs[0].isPatternDeclaration() && decs[0].getPattern().getObjectType().isEvent()) {
Declaration target = decs[0];
Interval interval = temporal.get(target);
if (interval == null) {
interval = constr.getInterval();
temporal.put(target, interval);
} else {
interval.intersect(constr.getInterval());
}
}
}
} else if (obj instanceof AbstractCompositeConstraint) {
gatherTemporalRelationships(Arrays.asList(((AbstractCompositeConstraint) obj).getBetaConstraints()), temporal);
}
}
}
Aggregations