// Copyright 2012 Georg-August-Universität Göttingen, Germany // // Licensed 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 de.ugoe.cs.autoquest.tasktrees.temporalrelation; import java.util.List; import de.ugoe.cs.autoquest.eventcore.IEventTarget; import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeBuilder; import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNodeFactory; /** * This rule subdivides long sequences into subsequences of tasks on the same event target. * Event targets are compared using the equals method. A more complex GUI model is ignored. * * @version $Revision: $ $Date: 18.03.2012$ * @author 2012, last modified by $Author: patrick$ */ class SequenceOnSameTargetDetectionRule implements TemporalRelationshipRule { /** *
* the task tree node factory to be used for creating substructures for the temporal * relationships identified during rule *
*/ private ITaskTreeNodeFactory taskTreeNodeFactory; /** ** the task tree builder to be used for creating substructures for the temporal relationships * identified during rule application *
*/ private ITaskTreeBuilder taskTreeBuilder; /** ** instantiates the rule with a task tree node factory and builder to be used during rule * application. *
* * @param taskTreeNodeFactory the task tree node factory to be used for creating substructures * for the temporal relationships identified during rule * application * @param taskTreeBuilder the task tree builder to be used for creating substructures for * the temporal relationships identified during rule application */ SequenceOnSameTargetDetectionRule(ITaskTreeNodeFactory taskTreeNodeFactory, ITaskTreeBuilder taskTreeBuilder) { this.taskTreeNodeFactory = taskTreeNodeFactory; this.taskTreeBuilder = taskTreeBuilder; } /* (non-Javadoc) * @see java.lang.Object#toString() */ @Override public String toString() { return "SequenceOnSameTargetDetectionRule"; } /* * (non-Javadoc) * * @see de.ugoe.cs.tasktree.temporalrelation.TemporalRelationshipRule#apply(TaskTreeNode, * boolean) */ @Override public RuleApplicationResult apply(ITaskTreeNode parent, boolean finalize) { if (!(parent instanceof ISequence)) { return null; } RuleApplicationResult result = new RuleApplicationResult(); IEventTarget currentEventTarget = null; int startingIndex = -1; int index = 0; List