1 | package de.ugoe.cs.eventbench.windows.commands;
|
---|
2 |
|
---|
3 | import java.security.InvalidParameterException;
|
---|
4 | import java.util.Collection;
|
---|
5 | import java.util.List;
|
---|
6 | import java.util.SortedSet;
|
---|
7 |
|
---|
8 | import de.ugoe.cs.eventbench.CommandHelpers;
|
---|
9 | import de.ugoe.cs.eventbench.data.GlobalDataContainer;
|
---|
10 | import de.ugoe.cs.eventbench.windows.LogParser;
|
---|
11 | import de.ugoe.cs.eventbench.windows.data.WindowTree;
|
---|
12 | import de.ugoe.cs.eventbench.windows.data.WindowsEvent;
|
---|
13 | import de.ugoe.cs.util.console.Command;
|
---|
14 | import de.ugoe.cs.util.console.Console;
|
---|
15 |
|
---|
16 | /**
|
---|
17 | * <p>
|
---|
18 | * Command to parse an XML file with sessions monitored by EventBench's
|
---|
19 | * MFCUsageMonitor.
|
---|
20 | * </p>
|
---|
21 | *
|
---|
22 | * @author Steffen Herbold
|
---|
23 | * @version 1.0
|
---|
24 | */
|
---|
25 | public class CMDparseXML implements Command {
|
---|
26 |
|
---|
27 | /*
|
---|
28 | * (non-Javadoc)
|
---|
29 | *
|
---|
30 | * @see de.ugoe.cs.util.console.Command#help()
|
---|
31 | */
|
---|
32 | @Override
|
---|
33 | public void help() {
|
---|
34 | Console.println("Usage: parseXML <filename> {<sequencesName>} {<countMessageOccurences>}");
|
---|
35 | }
|
---|
36 |
|
---|
37 | /*
|
---|
38 | * (non-Javadoc)
|
---|
39 | *
|
---|
40 | * @see de.ugoe.cs.util.console.Command#run(java.util.List)
|
---|
41 | */
|
---|
42 | @Override
|
---|
43 | public void run(List<Object> parameters) {
|
---|
44 | String filename;
|
---|
45 | String sequencesName = "sequences";
|
---|
46 | boolean countMessageOccurences = false;
|
---|
47 |
|
---|
48 | try {
|
---|
49 | filename = (String) parameters.get(0);
|
---|
50 | if (parameters.size() >= 2) {
|
---|
51 | sequencesName = (String) parameters.get(1);
|
---|
52 | }
|
---|
53 | if (parameters.size() >= 3) {
|
---|
54 | countMessageOccurences = Boolean
|
---|
55 | .parseBoolean((String) parameters.get(2));
|
---|
56 | }
|
---|
57 | } catch (Exception e) {
|
---|
58 | throw new InvalidParameterException();
|
---|
59 | }
|
---|
60 |
|
---|
61 | LogParser parser = new LogParser(countMessageOccurences);
|
---|
62 | parser.parseFile(filename);
|
---|
63 |
|
---|
64 | Collection<List<WindowsEvent>> sequences = parser.getSequences();
|
---|
65 | SortedSet<String> targets = WindowTree.getInstance().getTargets();
|
---|
66 |
|
---|
67 | if (GlobalDataContainer.getInstance().addData(sequencesName, sequences)) {
|
---|
68 | CommandHelpers.dataOverwritten(sequencesName);
|
---|
69 | }
|
---|
70 | if (GlobalDataContainer.getInstance().addData(
|
---|
71 | sequencesName + "_targets", targets)) {
|
---|
72 | CommandHelpers.dataOverwritten(sequencesName + "_targets");
|
---|
73 | }
|
---|
74 | }
|
---|
75 |
|
---|
76 | }
|
---|