source: trunk/autoquest-plugin-genericevents/src/main/java/de/ugoe/cs/autoquest/plugin/genericevents/commands/CMDparseGenericEvents.java @ 2165

Last change on this file since 2165 was 2165, checked in by pharms, 7 years ago
  • changes for first VR oriented usability evaluation
  • Property svn:mime-type set to text/plain
File size: 3.4 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.genericevents.commands;
16
17import java.util.Collection;
18import java.util.HashSet;
19import java.util.List;
20import java.util.Set;
21
22import de.ugoe.cs.autoquest.CommandHelpers;
23import de.ugoe.cs.autoquest.eventcore.Event;
24import de.ugoe.cs.autoquest.eventcore.IHierarchicalEventTargetModel;
25import de.ugoe.cs.autoquest.plugin.genericevents.GenericEventLogParser;
26import de.ugoe.cs.util.console.Command;
27import de.ugoe.cs.util.console.Console;
28import de.ugoe.cs.util.console.GlobalDataContainer;
29
30/**
31 * <p>
32 * Command to parse a file with sessions generated by the generic event monitor.
33 * </p>
34 *
35 * @author Patrick Harms
36 * @version 1.0
37 */
38public class CMDparseGenericEvents implements Command {
39
40    /*
41     * (non-Javadoc)
42     *
43     * @see de.ugoe.cs.util.console.Command#run(java.util.List)
44     */
45    @Override
46    public void run(List<Object> parameters) {
47        String filename = null;
48        String sequencesName = null;
49
50        Set<String> ignoredEvents = new HashSet<>();
51       
52        try {
53            for (int i = 0; i < parameters.size(); i++) {
54                String param = (String) parameters.get(i);
55                if (filename == null) {
56                    filename = param;
57                }
58                else if (sequencesName == null) {
59                    sequencesName = param;
60                }
61                else {
62                    ignoredEvents.add(param);
63                }
64            }
65        }
66        catch (Exception e) {
67            throw new IllegalArgumentException("illegal parameters provided: " + e);
68        }
69
70        if (sequencesName == null) {
71            sequencesName = "sequences";
72        }
73
74        GenericEventLogParser parser = new GenericEventLogParser(ignoredEvents);
75
76        try {
77            parser.parseFile(filename);
78        }
79        catch (Exception e) {
80            Console.printerrln("Could not parse " + filename + ": " + e.getMessage());
81            return;
82        }
83
84        Collection<List<Event>> sequences = parser.getSequences();
85
86        IHierarchicalEventTargetModel<?> targets = parser.getHierarchicalEventTargetModel();
87
88        if (GlobalDataContainer.getInstance().addData(sequencesName, sequences)) {
89            CommandHelpers.dataOverwritten(sequencesName);
90        }
91
92        if (GlobalDataContainer.getInstance().addData(sequencesName + "_targets", targets)) {
93            CommandHelpers.dataOverwritten(sequencesName + "_targets");
94        }
95    }
96
97    /*
98     * (non-Javadoc)
99     *
100     * @see de.ugoe.cs.util.console.Command#help()
101     */
102    @Override
103    public String help() {
104        return "parseGenericEvents <filename> [<sequencesName>] [<ignoredEventType>*] [<ignoredEventType.ignoredEventTargetId>*]";
105    }
106
107}
Note: See TracBrowser for help on using the repository browser.