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> {<sequences>}");
|
---|
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 | String sequencesName = "sequences";
|
---|
28 | if( parameters.size()==2 ) {
|
---|
29 | sequencesName = (String) parameters.get(0);
|
---|
30 | }
|
---|
31 |
|
---|
32 | List<List<ReplayableEvent<?>>> sequences = null;
|
---|
33 | Object dataObject = GlobalDataContainer.getInstance().getData(sequencesName);
|
---|
34 |
|
---|
35 | try {
|
---|
36 | sequences = (List<List<ReplayableEvent<?>>>) dataObject;
|
---|
37 | ReplayGenerator generator = new ReplayGenerator();
|
---|
38 | if( sequences.size()>0 ) {
|
---|
39 | if( sequences.get(0).get(0) instanceof Event ) {
|
---|
40 | generator.createLogfileMultipleSessions(sequences, filename);
|
---|
41 | } else {
|
---|
42 | Console.printerrln("Loaded data not are not sequences!");
|
---|
43 | if( sequencesName.equals("sequences") ) {
|
---|
44 | Console.traceln("Illegal use of \"sequences\" parameter in the GlobalDataContainer.");
|
---|
45 | Console.traceln("The parameter should always be of type List<List<Event>>!");
|
---|
46 | }
|
---|
47 | }
|
---|
48 | }
|
---|
49 | }
|
---|
50 | catch(ClassCastException e) {
|
---|
51 | Console.printerrln("Sequences not found");
|
---|
52 | }
|
---|
53 |
|
---|
54 | }
|
---|
55 |
|
---|
56 | }
|
---|