1 | package de.ugoe.cs.eventbench.commands;
|
---|
2 |
|
---|
3 | import java.security.InvalidParameterException;
|
---|
4 | import java.util.Collection;
|
---|
5 | import java.util.List;
|
---|
6 |
|
---|
7 | import de.ugoe.cs.eventbench.CommandHelpers;
|
---|
8 | import de.ugoe.cs.eventbench.ReplayGenerator;
|
---|
9 | import de.ugoe.cs.eventbench.SequenceInstanceOf;
|
---|
10 | import de.ugoe.cs.eventbench.data.GlobalDataContainer;
|
---|
11 | import de.ugoe.cs.eventbench.data.ReplayableEvent;
|
---|
12 | import de.ugoe.cs.util.console.Command;
|
---|
13 | import de.ugoe.cs.util.console.Console;
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * <p>
|
---|
17 | * Command to create a replay file from stored sessions.
|
---|
18 | * </p>
|
---|
19 | *
|
---|
20 | * @author Steffen Herbold
|
---|
21 | * @version 1.0
|
---|
22 | */
|
---|
23 | public class CMDgenerateReplayfile implements Command {
|
---|
24 |
|
---|
25 | /*
|
---|
26 | * (non-Javadoc)
|
---|
27 | *
|
---|
28 | * @see de.ugoe.cs.util.console.Command#help()
|
---|
29 | */
|
---|
30 | @Override
|
---|
31 | public void help() {
|
---|
32 | Console.println("Usage: generateReplayfile <filename> <sequences>");
|
---|
33 | }
|
---|
34 |
|
---|
35 | /*
|
---|
36 | * (non-Javadoc)
|
---|
37 | *
|
---|
38 | * @see de.ugoe.cs.util.console.Command#run(java.util.List)
|
---|
39 | */
|
---|
40 | @SuppressWarnings("unchecked")
|
---|
41 | @Override
|
---|
42 | public void run(List<Object> parameters) {
|
---|
43 | String filename;
|
---|
44 | String sequencesName;
|
---|
45 | try {
|
---|
46 | filename = (String) parameters.get(0);
|
---|
47 | sequencesName = (String) parameters.get(1);
|
---|
48 | } catch (Exception e) {
|
---|
49 | throw new InvalidParameterException();
|
---|
50 | }
|
---|
51 |
|
---|
52 | Collection<List<ReplayableEvent<?>>> sequences = null;
|
---|
53 | Object dataObject = GlobalDataContainer.getInstance().getData(
|
---|
54 | sequencesName);
|
---|
55 | if (dataObject == null) {
|
---|
56 | CommandHelpers.objectNotFoundMessage(sequencesName);
|
---|
57 | return;
|
---|
58 | }
|
---|
59 | if (!SequenceInstanceOf.isCollectionOfSequences(dataObject)) {
|
---|
60 | CommandHelpers.objectNotType(sequencesName,
|
---|
61 | "Collection<List<Event<?>>>");
|
---|
62 | return;
|
---|
63 | }
|
---|
64 |
|
---|
65 | sequences = (Collection<List<ReplayableEvent<?>>>) dataObject;
|
---|
66 | ReplayGenerator generator = new ReplayGenerator();
|
---|
67 | generator.createLogfileMultipleSessions(sequences, filename);
|
---|
68 | }
|
---|
69 |
|
---|
70 | }
|
---|