[2035] | 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.plugin.jfc.commands; |
---|
| 16 | |
---|
| 17 | import java.util.Collection; |
---|
| 18 | import java.util.List; |
---|
| 19 | |
---|
| 20 | import de.ugoe.cs.autoquest.CommandHelpers; |
---|
| 21 | import de.ugoe.cs.autoquest.SequenceInstanceOf; |
---|
| 22 | import de.ugoe.cs.util.console.Command; |
---|
| 23 | import de.ugoe.cs.autoquest.eventcore.Event; |
---|
| 24 | import de.ugoe.cs.autoquest.plugin.jfc.JFCJacaretoReplayGenerator; |
---|
| 25 | import de.ugoe.cs.util.console.GlobalDataContainer; |
---|
| 26 | |
---|
| 27 | /** |
---|
| 28 | * <p> |
---|
| 29 | * Command to create a Jacareto xml replay file from stored sessions. |
---|
| 30 | * </p> |
---|
| 31 | * |
---|
| 32 | * @author Daniel May |
---|
| 33 | * @version 1.0 |
---|
| 34 | */ |
---|
| 35 | public class CMDgenerateJacaretoReplay implements Command { |
---|
| 36 | |
---|
| 37 | @Override |
---|
| 38 | public String help() { |
---|
| 39 | return "generateJacaretoReplay <filename> <sequences> <class> <basepath> <classpathext> {<menufile>}"; |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | /* |
---|
| 43 | * (non-Javadoc) |
---|
| 44 | * |
---|
| 45 | * @see de.ugoe.cs.util.console.Command#run(java.util.List) |
---|
| 46 | */ |
---|
| 47 | @SuppressWarnings("unchecked") |
---|
| 48 | @Override |
---|
| 49 | public void run(List<Object> parameters) { |
---|
| 50 | String filename; |
---|
| 51 | String sequencesName; |
---|
| 52 | String classpath; |
---|
| 53 | String basepath; |
---|
| 54 | String classpathext; |
---|
| 55 | String menu = ""; |
---|
| 56 | try { |
---|
| 57 | filename = (String) parameters.get(0); |
---|
| 58 | sequencesName = (String) parameters.get(1); |
---|
| 59 | classpath = (String) parameters.get(2); |
---|
| 60 | basepath = (String) parameters.get(3); |
---|
| 61 | classpathext = (String) parameters.get(4); |
---|
| 62 | } |
---|
| 63 | catch (Exception e) { |
---|
| 64 | throw new IllegalArgumentException(); |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | if (parameters.size() > 5) { |
---|
| 68 | menu = (String) parameters.get(5); |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | Collection<List<Event>> sequences = null; |
---|
| 72 | Object dataObject = GlobalDataContainer.getInstance().getData(sequencesName); |
---|
| 73 | if (dataObject == null) { |
---|
| 74 | CommandHelpers.objectNotFoundMessage(sequencesName); |
---|
| 75 | return; |
---|
| 76 | } |
---|
| 77 | if (!SequenceInstanceOf.isCollectionOfSequences(dataObject)) { |
---|
| 78 | CommandHelpers.objectNotType(sequencesName, "Collection<List<Event<?>>>"); |
---|
| 79 | return; |
---|
| 80 | } |
---|
| 81 | |
---|
| 82 | sequences = (Collection<List<Event>>) dataObject; |
---|
| 83 | |
---|
| 84 | int index = 1; |
---|
| 85 | for (List<Event> sequence : sequences) { |
---|
| 86 | JFCJacaretoReplayGenerator generator = |
---|
| 87 | new JFCJacaretoReplayGenerator(sequence, filename + "_" + index, classpath, |
---|
| 88 | basepath, classpathext, menu); |
---|
| 89 | generator.writeJacaretoXML(); |
---|
| 90 | index++; |
---|
| 91 | } |
---|
| 92 | } |
---|
| 93 | } |
---|