source: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDgenerateReplayfile.java @ 394

Last change on this file since 394 was 241, checked in by sherbold, 13 years ago
  • some changes to command parameter orders
  • removed command printRandomSesssion
  • renamed command loadSessionsFromClickstream do loadWebSequences
File size: 1.9 KB
Line 
1package de.ugoe.cs.eventbench.commands;
2
3import java.security.InvalidParameterException;
4import java.util.Collection;
5import java.util.List;
6
7import de.ugoe.cs.eventbench.CommandHelpers;
8import de.ugoe.cs.eventbench.ReplayGenerator;
9import de.ugoe.cs.eventbench.SequenceInstanceOf;
10import de.ugoe.cs.eventbench.data.GlobalDataContainer;
11import de.ugoe.cs.eventbench.data.ReplayableEvent;
12import de.ugoe.cs.util.console.Command;
13import 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 */
23public 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}
Note: See TracBrowser for help on using the repository browser.