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(1);
|
---|
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!=null && sequences.size()>0 && sequences.get(0).get(0) instanceof Event ) {
|
---|
39 | generator.createLogfileMultipleSessions(sequences, filename);
|
---|
40 | } else {
|
---|
41 | Console.printerrln("Loaded data not are not sequences!");
|
---|
42 | if( sequencesName.equals("sequences") ) {
|
---|
43 | Console.traceln("Illegal use of \"sequences\" parameter in the GlobalDataContainer.");
|
---|
44 | Console.traceln("The parameter should always be of type List<List<Event>>!");
|
---|
45 | }
|
---|
46 | }
|
---|
47 | }
|
---|
48 | catch(ClassCastException e) {
|
---|
49 | Console.printerrln("Sequences not found");
|
---|
50 | }
|
---|
51 |
|
---|
52 | }
|
---|
53 |
|
---|
54 | }
|
---|