1 | package de.ugoe.cs.eventbench.web.commands;
|
---|
2 |
|
---|
3 | import java.io.FileNotFoundException;
|
---|
4 | import java.io.IOException;
|
---|
5 | import java.security.InvalidParameterException;
|
---|
6 | import java.text.ParseException;
|
---|
7 | import java.util.List;
|
---|
8 |
|
---|
9 | import de.ugoe.cs.eventbench.data.GlobalDataContainer;
|
---|
10 | import de.ugoe.cs.eventbench.web.WeblogParser;
|
---|
11 | import de.ugoe.cs.util.console.Command;
|
---|
12 | import de.ugoe.cs.util.console.Console;
|
---|
13 |
|
---|
14 | public class CMDloadSessionsFromClickstream implements Command {
|
---|
15 |
|
---|
16 | @Override
|
---|
17 | public void run(List<Object> parameters) {
|
---|
18 | if( parameters.size() < 1 ) {
|
---|
19 | throw new InvalidParameterException();
|
---|
20 | }
|
---|
21 | String source = (String) parameters.get(0);
|
---|
22 | int timeout = -1;
|
---|
23 | int minLength = -1;
|
---|
24 | if( parameters.size() ==3 ) {
|
---|
25 | timeout = Integer.parseInt((String) parameters.get(1));
|
---|
26 | minLength = Integer.parseInt((String) parameters.get(2));
|
---|
27 | }
|
---|
28 |
|
---|
29 | WeblogParser parser = new WeblogParser();;
|
---|
30 | if( timeout!=-1 ) {
|
---|
31 | parser.setTimeout(timeout);
|
---|
32 | parser.setMinLength(minLength);
|
---|
33 | }
|
---|
34 | try {
|
---|
35 | parser.parseFile(source);
|
---|
36 | } catch (FileNotFoundException e) {
|
---|
37 | Console.println(e.getMessage());
|
---|
38 | } catch (IOException e) {
|
---|
39 | Console.println(e.getMessage());
|
---|
40 | } catch (ParseException e) {
|
---|
41 | Console.println("Invalid format of date stamps.");
|
---|
42 | Console.println(e.getMessage());
|
---|
43 | }
|
---|
44 |
|
---|
45 | if( GlobalDataContainer.getInstance().addData("sequences", parser.getSequences()) ) {
|
---|
46 | Console.traceln("Old data \"" + "sequences" + "\" overwritten");
|
---|
47 | }
|
---|
48 | }
|
---|
49 |
|
---|
50 | @Override
|
---|
51 | public void help() {
|
---|
52 | Console.println("Usage: loadSessionsFromClickstream <filename> {<timeout> <minSessionLength>}");
|
---|
53 | }
|
---|
54 |
|
---|
55 | }
|
---|