01: /*
02: * Copyright 2006 JBoss Inc
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.drools.reteoo.builder;
18:
19: import java.util.Collections;
20:
21: import org.drools.common.BetaConstraints;
22: import org.drools.reteoo.FromNode;
23: import org.drools.reteoo.TupleSource;
24: import org.drools.rule.From;
25: import org.drools.rule.RuleConditionElement;
26: import org.drools.spi.AlphaNodeFieldConstraint;
27:
28: /**
29: * @author etirelli
30: *
31: */
32: public class FromBuilder implements ReteooComponentBuilder {
33:
34: /* (non-Javadoc)
35: * @see org.drools.reteoo.builder.ReteooComponentBuilder#build(org.drools.reteoo.builder.BuildContext, org.drools.reteoo.builder.BuildUtils, org.drools.rule.RuleConditionElement)
36: */
37: public void build(final BuildContext context,
38: final BuildUtils utils, final RuleConditionElement rce) {
39: final From from = (From) rce;
40:
41: BetaConstraints betaConstraints = utils
42: .createBetaNodeConstraint(context, context
43: .getBetaconstraints(), true);
44:
45: context
46: .setTupleSource((TupleSource) utils
47: .attachNode(
48: context,
49: new FromNode(
50: context.getNextId(),
51: from.getDataProvider(),
52: context.getTupleSource(),
53: (AlphaNodeFieldConstraint[]) context
54: .getAlphaConstraints()
55: .toArray(
56: new AlphaNodeFieldConstraint[context
57: .getAlphaConstraints()
58: .size()]),
59: betaConstraints)));
60: context.setAlphaConstraints(null);
61: context.setBetaconstraints(null);
62: }
63:
64: /**
65: * @inheritDoc
66: */
67: public boolean requiresLeftActivation(final BuildUtils utils,
68: final RuleConditionElement rce) {
69: return true;
70: }
71:
72: }
|