01: package org.drools.ruleflow.instance.impl;
02:
03: /*
04: * Copyright 2005 JBoss Inc
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: import java.util.Iterator;
20:
21: import org.drools.common.RuleFlowGroupNode;
22: import org.drools.ruleflow.core.MilestoneNode;
23: import org.drools.ruleflow.instance.RuleFlowNodeInstance;
24: import org.drools.spi.Activation;
25: import org.drools.spi.RuleFlowGroup;
26:
27: /**
28: * Runtime counterpart of a milestone node.
29: *
30: * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris Verlaenen</a>
31: */
32: public class MilestoneNodeInstanceImpl extends RuleFlowNodeInstanceImpl {
33:
34: protected MilestoneNode getMilestoneNode() {
35: return (MilestoneNode) getNode();
36: }
37:
38: public void trigger(final RuleFlowNodeInstance from) {
39: RuleFlowGroup systemRuleFlowGroup = getProcessInstance()
40: .getAgenda().getRuleFlowGroup("DROOLS_SYSTEM");
41: String rule = "RuleFlow-"
42: + getProcessInstance().getProcess().getId() + "-"
43: + getNode().getId();
44: for (Iterator activations = systemRuleFlowGroup.iterator(); activations
45: .hasNext();) {
46: Activation activation = ((RuleFlowGroupNode) activations
47: .next()).getActivation();
48: if (rule.equals(activation.getRule().getName())) {
49: triggerCompleted();
50: break;
51: }
52: }
53: }
54:
55: public void triggerCompleted() {
56: getProcessInstance().getNodeInstance(
57: getMilestoneNode().getTo().getTo()).trigger(this);
58: getProcessInstance().removeNodeInstance(this);
59: }
60:
61: }
|