1 | package de.ugoe.cs.eventbench.commands;
|
---|
2 |
|
---|
3 | import java.security.InvalidParameterException;
|
---|
4 | import java.util.List;
|
---|
5 |
|
---|
6 | import de.ugoe.cs.eventbench.ReplayGenerator;
|
---|
7 | import de.ugoe.cs.eventbench.data.Event;
|
---|
8 | import de.ugoe.cs.eventbench.data.GlobalDataContainer;
|
---|
9 | import de.ugoe.cs.eventbench.data.ReplayableEvent;
|
---|
10 | import de.ugoe.cs.util.console.Command;
|
---|
11 | import de.ugoe.cs.util.console.Console;
|
---|
12 |
|
---|
13 | public class CMDgenerateReplayfile implements Command {
|
---|
14 |
|
---|
15 | @Override
|
---|
16 | public void help() {
|
---|
17 | Console.println("Usage: generateReplayfile <filename>");
|
---|
18 | }
|
---|
19 |
|
---|
20 | @SuppressWarnings("unchecked")
|
---|
21 | @Override
|
---|
22 | public void run(List<Object> parameters) {
|
---|
23 | if( parameters.size() < 1 ) {
|
---|
24 | throw new InvalidParameterException();
|
---|
25 | }
|
---|
26 | String filename = (String) parameters.get(0);
|
---|
27 |
|
---|
28 | List<List<ReplayableEvent<?>>> sequences = null;
|
---|
29 | Object dataObject = GlobalDataContainer.getInstance().getData("sequences");
|
---|
30 |
|
---|
31 | try {
|
---|
32 | sequences = (List<List<ReplayableEvent<?>>>) dataObject;
|
---|
33 | ReplayGenerator generator = new ReplayGenerator();
|
---|
34 | if( sequences.size()>0 ) {
|
---|
35 | if( sequences.get(0).get(0) instanceof Event ) {
|
---|
36 | generator.createLogfileMultipleSessions(sequences, filename);
|
---|
37 | } else {
|
---|
38 | Console.traceln("Illegal use of \"sequences\" parameter in the GlobalDataContainer.");
|
---|
39 | Console.traceln("The parameter should always be of type List<List<Event>>!");
|
---|
40 | }
|
---|
41 | }
|
---|
42 | }
|
---|
43 | catch(ClassCastException e) {
|
---|
44 | Console.printerrln("Sequences need to be loaded first using parseXML");
|
---|
45 | }
|
---|
46 |
|
---|
47 | }
|
---|
48 |
|
---|
49 | }
|
---|