[1150] | 1 | // Copyright 2012 Georg-August-Universität Göttingen, Germany
|
---|
| 2 | //
|
---|
| 3 | // Licensed under the Apache License, Version 2.0 (the "License");
|
---|
| 4 | // you may not use this file except in compliance with the License.
|
---|
| 5 | // You may obtain a copy of the License at
|
---|
| 6 | //
|
---|
| 7 | // http://www.apache.org/licenses/LICENSE-2.0
|
---|
| 8 | //
|
---|
| 9 | // Unless required by applicable law or agreed to in writing, software
|
---|
| 10 | // distributed under the License is distributed on an "AS IS" BASIS,
|
---|
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
| 12 | // See the License for the specific language governing permissions and
|
---|
| 13 | // limitations under the License.
|
---|
| 14 |
|
---|
| 15 | package de.ugoe.cs.autoquest.usability.rules.patterns.visitors;
|
---|
| 16 |
|
---|
[1152] | 17 | import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask;
|
---|
[1150] | 18 | import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration;
|
---|
[1213] | 19 | import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptional;
|
---|
[1150] | 20 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence;
|
---|
[1152] | 21 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask;
|
---|
[1204] | 22 | import de.ugoe.cs.autoquest.usability.rules.patterns.InteractionPattern;
|
---|
| 23 | import de.ugoe.cs.autoquest.usability.rules.patterns.InteractionPatternVisitor;
|
---|
[1217] | 24 | import de.ugoe.cs.autoquest.usability.taskmodel.filter.types.TaskTypeFilter;
|
---|
[1150] | 25 |
|
---|
| 26 | /**
|
---|
| 27 | * <p>
|
---|
| 28 | * TODO comment
|
---|
| 29 | * </p>
|
---|
| 30 | *
|
---|
| 31 | * @author Alexander Deicke
|
---|
| 32 | */
|
---|
[1204] | 33 | public class ContainsInteractionPatternVisitor extends InteractionPatternVisitor {
|
---|
[1150] | 34 |
|
---|
| 35 | /**
|
---|
| 36 | * <p>
|
---|
| 37 | * TODO: comment
|
---|
| 38 | * </p>
|
---|
[1217] | 39 | *
|
---|
[1150] | 40 | * @param containsPattern
|
---|
| 41 | */
|
---|
[1217] | 42 | public ContainsInteractionPatternVisitor(InteractionPattern containsPattern,
|
---|
| 43 | TaskTypeFilter taskType)
|
---|
| 44 | {
|
---|
[1150] | 45 | this.containedPattern = containsPattern;
|
---|
[1204] | 46 | this.taskType = taskType;
|
---|
[1150] | 47 | }
|
---|
| 48 |
|
---|
[1217] | 49 | /*
|
---|
| 50 | * (non-Javadoc)
|
---|
| 51 | *
|
---|
| 52 | * @see
|
---|
| 53 | * de.ugoe.cs.autoquest.tasktrees.treeifc.NodeVisitor#visit(de.ugoe.cs.autoquest.tasktrees.treeifc
|
---|
| 54 | * .IIteration)
|
---|
[1150] | 55 | */
|
---|
| 56 | public void visit(IIteration iteration) {
|
---|
[1152] | 57 | checkTaskAndReturnIfPatternIsPresent(iteration.getMarkedTask());
|
---|
[1150] | 58 | }
|
---|
| 59 |
|
---|
[1217] | 60 | /*
|
---|
| 61 | * (non-Javadoc)
|
---|
| 62 | *
|
---|
| 63 | * @see
|
---|
| 64 | * de.ugoe.cs.autoquest.tasktrees.treeifc.TaskVisitor#visit(de.ugoe.cs.autoquest.tasktrees.treeifc
|
---|
| 65 | * .IOptional)
|
---|
[1213] | 66 | */
|
---|
| 67 | public void visit(IOptional optional) {
|
---|
| 68 | checkTaskAndReturnIfPatternIsPresent(optional.getMarkedTask());
|
---|
| 69 | }
|
---|
| 70 |
|
---|
[1217] | 71 | /*
|
---|
| 72 | * (non-Javadoc)
|
---|
| 73 | *
|
---|
| 74 | * @see
|
---|
| 75 | * de.ugoe.cs.autoquest.tasktrees.treeifc.NodeVisitor#visit(de.ugoe.cs.autoquest.tasktrees.treeifc
|
---|
| 76 | * .ISequence)
|
---|
[1150] | 77 | */
|
---|
| 78 | public void visit(ISequence sequence) {
|
---|
| 79 | checkAllChildrenAndReturnIfPatternIsPresent(sequence);
|
---|
| 80 | }
|
---|
[1217] | 81 |
|
---|
[1152] | 82 | private void checkAllChildrenAndReturnIfPatternIsPresent(ISequence sequence) {
|
---|
| 83 | for (ITask child : sequence.getChildren()) {
|
---|
[1217] | 84 | if (checkTaskAndReturnIfPatternIsPresent(child)) {
|
---|
[1161] | 85 | this.present = true;
|
---|
[1150] | 86 | break;
|
---|
| 87 | }
|
---|
| 88 | }
|
---|
| 89 | }
|
---|
[1217] | 90 |
|
---|
[1152] | 91 | private boolean checkTaskAndReturnIfPatternIsPresent(ITask task) {
|
---|
[1217] | 92 | if (isEvent(task))
|
---|
| 93 | return false;
|
---|
[1161] | 94 | return this.containedPattern.containedIn(task);
|
---|
[1150] | 95 | }
|
---|
[1217] | 96 |
|
---|
[1152] | 97 | private boolean isEvent(ITask task) {
|
---|
| 98 | return task instanceof IEventTask;
|
---|
| 99 | }
|
---|
[1150] | 100 |
|
---|
| 101 | }
|
---|