source: trunk/autoquest-plugin-jfc/src/main/java/de/ugoe/cs/autoquest/plugin/jfc/commands/CMDparseOldJFC.java @ 1179

Last change on this file since 1179 was 1179, checked in by pharms, 11 years ago
  • corrected error handling during parsing
  • Property svn:mime-type set to text/plain
File size: 2.8 KB
Line 
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
15package de.ugoe.cs.autoquest.plugin.jfc.commands;
16
17import java.util.Collection;
18import java.util.List;
19
20import de.ugoe.cs.autoquest.CommandHelpers;
21import de.ugoe.cs.autoquest.eventcore.Event;
22import de.ugoe.cs.autoquest.eventcore.guimodel.GUIModel;
23import de.ugoe.cs.autoquest.plugin.jfc.JFCLogParser;
24import de.ugoe.cs.util.console.Command;
25import de.ugoe.cs.util.console.Console;
26import de.ugoe.cs.util.console.GlobalDataContainer;
27
28/**
29 * <p>
30 * Command to parse an old XML file with sessions monitored by EventBench's JFCMonitor. For new log
31 * files parseJFC must be used instead.
32 * </p>
33 *
34 * @author Steffen Herbold
35 * @version 1.0
36 */
37public class CMDparseOldJFC implements Command {
38
39    /*
40     * (non-Javadoc)
41     *
42     * @see de.ugoe.cs.util.console.Command#run(java.util.List)
43     */
44    @Override
45    public void run(List<Object> parameters) {
46        String filename;
47        String sequencesName = "sequences";
48
49        try {
50            filename = (String) parameters.get(0);
51            if (parameters.size() >= 2) {
52                sequencesName = (String) parameters.get(1);
53            }
54        }
55        catch (Exception e) {
56            throw new IllegalArgumentException();
57        }
58
59        JFCLogParser parser = new JFCLogParser();
60
61        try {
62            parser.parseFile(filename);
63        }
64        catch (Exception e) {
65            Console.printerrln("Could not parse " + filename + ": " + e.getMessage());
66            return;
67        }
68
69        Collection<List<Event>> sequences = parser.getSequences();
70
71        GUIModel targets = parser.getGuiModel();
72
73        if (GlobalDataContainer.getInstance().addData(sequencesName, sequences)) {
74            CommandHelpers.dataOverwritten(sequencesName);
75        }
76
77        if (GlobalDataContainer.getInstance().addData(sequencesName + "_targets", targets)) {
78            CommandHelpers.dataOverwritten(sequencesName + "_targets");
79        }
80    }
81
82    /*
83     * (non-Javadoc)
84     *
85     * @see de.ugoe.cs.util.console.Command#help()
86     */
87    @Override
88    public String help() {
89        return "parseOldJFC <filename> {<sequencesName>}";
90    }
91
92}
Note: See TracBrowser for help on using the repository browser.