Rikkola commented on code in PR #6909: URL: https://github.com/apache/incubator-kie/pull/6909#discussion_r3913253864
########## drools-base/src/main/java/org/drools/base/reteoo/sequencing/Sequence.java: ########## @@ -0,0 +1,332 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.drools.base.reteoo.sequencing; + +import org.drools.base.base.ValueResolver; +import org.drools.base.reteoo.DynamicFilter; +import org.drools.base.reteoo.sequencing.signalprocessors.LogicGate; +import org.drools.base.reteoo.sequencing.steps.LogicCircuitStep; +import org.drools.base.reteoo.sequencing.steps.Step; +import org.drools.base.reteoo.sequencing.steps.Step.StepFactory; +import org.drools.base.rule.Declaration; +import org.drools.base.rule.Pattern; +import org.drools.base.rule.RuleConditionElement; +import org.drools.base.reteoo.SignalAdapter; +import org.drools.base.util.CircularArrayList; +import org.kie.api.runtime.rule.FactHandle; + +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +public class Sequence implements RuleConditionElement { + private final int sequenceIndex; + + private Pattern[] filters; + + private Step[] steps; + + private LogicGate[] gates; + + private SequenceController controller; + + public Sequence(int sequenceIndex, StepFactory... stepFactories) { + this.steps = new Step[stepFactories.length]; + this.sequenceIndex = sequenceIndex; + this.controller = DefaultController.getInstance(); + + for ( int i = 0; i < steps.length; i++ ) { + steps[i] = stepFactories[i].createStep(this); + } + populateLogicGates(); + } + + public Pattern[] getFilters() { + return filters; + } + + public void setFilters(Pattern[] filters) { + this.filters = filters; + } + + public void populateLogicGates() { + List<LogicGate> list = new ArrayList<>(); + for (Step step : getSteps()) { + if (step instanceof LogicCircuitStep) { + LogicGate[] circuitGates = ((LogicCircuitStep) step).getCircuit().getGates(); + for (int i = 0; i < circuitGates.length; i++) { + list.add(circuitGates[i]); + } + } + } + gates = list.toArray(new LogicGate[0]); + } + + public int getSequenceIndex() { + return sequenceIndex; + } + + public Step[] getSteps() { + return steps; + } + + public void setSteps(Step[] steps) { + this.steps = steps; + } + + public LogicGate[] getGates() { + return gates; + } + + @Override + public Map<String, Declaration> getInnerDeclarations() { + return Map.of(); + } + + @Override + public Map<String, Declaration> getOuterDeclarations() { + return Map.of(); + } + + @Override + public Declaration resolveDeclaration(String identifier) { + return null; + } + + @Override + public RuleConditionElement clone() { + Sequence clone = new Sequence(sequenceIndex); + clone.steps = this.steps; + clone.gates = this.gates; + clone.filters = this.filters; + clone.controller = this.controller; + return clone; + } + + @Override + public List<? extends RuleConditionElement> getNestedElements() { + return List.of(); + } + + @Override + public boolean isPatternScopeDelimiter() { + return false; + } + + @Override + public void writeExternal(ObjectOutput out) throws IOException { + throw new UnsupportedOperationException("Sequence does not support serialization"); Review Comment: Known issue for now at least. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
