[927] | 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 |
|
---|
[922] | 15 | package de.ugoe.cs.autoquest.plugin.jfc.commands;
|
---|
[573] | 16 |
|
---|
| 17 | import java.util.Collection;
|
---|
| 18 | import java.util.List;
|
---|
| 19 |
|
---|
[922] | 20 | import de.ugoe.cs.autoquest.CommandHelpers;
|
---|
| 21 | import de.ugoe.cs.autoquest.eventcore.Event;
|
---|
| 22 | import de.ugoe.cs.autoquest.eventcore.guimodel.GUIModel;
|
---|
[1037] | 23 | import de.ugoe.cs.autoquest.plugin.jfc.JFCSimplifiedLogParser;
|
---|
[573] | 24 | import de.ugoe.cs.util.console.Command;
|
---|
[1179] | 25 | import de.ugoe.cs.util.console.Console;
|
---|
[667] | 26 | import de.ugoe.cs.util.console.GlobalDataContainer;
|
---|
[573] | 27 |
|
---|
| 28 | /**
|
---|
| 29 | * <p>
|
---|
[1179] | 30 | * Command to parse an XML file with sessions monitored by EventBench's JFCMonitor.
|
---|
[573] | 31 | * </p>
|
---|
| 32 | *
|
---|
| 33 | * @author Steffen Herbold
|
---|
| 34 | * @version 1.0
|
---|
| 35 | */
|
---|
| 36 | public class CMDparseJFC implements Command {
|
---|
| 37 |
|
---|
[1179] | 38 | /*
|
---|
| 39 | * (non-Javadoc)
|
---|
| 40 | *
|
---|
| 41 | * @see de.ugoe.cs.util.console.Command#run(java.util.List)
|
---|
| 42 | */
|
---|
| 43 | @Override
|
---|
| 44 | public void run(List<Object> parameters) {
|
---|
| 45 | String filename;
|
---|
| 46 | String sequencesName = "sequences";
|
---|
[573] | 47 |
|
---|
[1179] | 48 | try {
|
---|
| 49 | filename = (String) parameters.get(0);
|
---|
| 50 | if (parameters.size() >= 2) {
|
---|
| 51 | sequencesName = (String) parameters.get(1);
|
---|
| 52 | }
|
---|
| 53 | }
|
---|
| 54 | catch (Exception e) {
|
---|
| 55 | throw new IllegalArgumentException();
|
---|
| 56 | }
|
---|
[573] | 57 |
|
---|
[1179] | 58 | JFCSimplifiedLogParser parser = new JFCSimplifiedLogParser();
|
---|
[573] | 59 |
|
---|
[1179] | 60 | try {
|
---|
| 61 | parser.parseFile(filename);
|
---|
| 62 | }
|
---|
| 63 | catch (Exception e) {
|
---|
| 64 | Console.printerrln("Could not parse " + filename + ": " + e.getMessage());
|
---|
| 65 | return;
|
---|
| 66 | }
|
---|
[680] | 67 |
|
---|
[1179] | 68 | Collection<List<Event>> sequences = parser.getSequences();
|
---|
[573] | 69 |
|
---|
[1179] | 70 | GUIModel targets = parser.getGuiModel();
|
---|
[573] | 71 |
|
---|
[1179] | 72 | if (GlobalDataContainer.getInstance().addData(sequencesName, sequences)) {
|
---|
| 73 | CommandHelpers.dataOverwritten(sequencesName);
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 | if (GlobalDataContainer.getInstance().addData(sequencesName + "_targets", targets)) {
|
---|
| 77 | CommandHelpers.dataOverwritten(sequencesName + "_targets");
|
---|
| 78 | }
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | /*
|
---|
| 82 | * (non-Javadoc)
|
---|
| 83 | *
|
---|
| 84 | * @see de.ugoe.cs.util.console.Command#help()
|
---|
| 85 | */
|
---|
| 86 | @Override
|
---|
| 87 | public String help() {
|
---|
| 88 | return "parseJFC <filename> {<sequencesName>}";
|
---|
| 89 | }
|
---|
| 90 |
|
---|
[573] | 91 | }
|
---|