Search in sources :

Example 1 with AbstractCompositeConstraint

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);
        }
    }
}
Also used : Declaration(org.drools.core.rule.Declaration) AbstractCompositeConstraint(org.drools.core.rule.AbstractCompositeConstraint) IntervalProviderConstraint(org.drools.core.rule.IntervalProviderConstraint) Interval(org.drools.core.time.Interval)

Aggregations

AbstractCompositeConstraint (org.drools.core.rule.AbstractCompositeConstraint)1 Declaration (org.drools.core.rule.Declaration)1 IntervalProviderConstraint (org.drools.core.rule.IntervalProviderConstraint)1 Interval (org.drools.core.time.Interval)1