[51] | 1 | package de.ugoe.cs.eventbench.web.commands;
|
---|
| 2 |
|
---|
[54] | 3 | import java.io.FileNotFoundException;
|
---|
| 4 | import java.io.IOException;
|
---|
[51] | 5 | import java.security.InvalidParameterException;
|
---|
[54] | 6 | import java.text.ParseException;
|
---|
[51] | 7 | import java.util.List;
|
---|
| 8 |
|
---|
[54] | 9 | import de.ugoe.cs.eventbench.data.GlobalDataContainer;
|
---|
| 10 | import de.ugoe.cs.eventbench.web.WeblogParser;
|
---|
[51] | 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) {
|
---|
[53] | 18 | if( parameters.size() < 1 ) {
|
---|
[51] | 19 | throw new InvalidParameterException();
|
---|
| 20 | }
|
---|
| 21 | String source = (String) parameters.get(0);
|
---|
[68] | 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 | }
|
---|
[51] | 28 |
|
---|
[68] | 29 | WeblogParser parser = new WeblogParser();;
|
---|
| 30 | if( timeout!=-1 ) {
|
---|
| 31 | parser.setTimeout(timeout);
|
---|
| 32 | parser.setMinLength(minLength);
|
---|
| 33 | }
|
---|
[54] | 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());
|
---|
[51] | 43 | }
|
---|
| 44 |
|
---|
[84] | 45 | if( GlobalDataContainer.getInstance().addData("sequences", parser.getSequences()) ) {
|
---|
| 46 | Console.traceln("Old data \"" + "sequences" + "\" overwritten");
|
---|
| 47 | }
|
---|
[51] | 48 | }
|
---|
[53] | 49 |
|
---|
[51] | 50 | @Override
|
---|
| 51 | public void help() {
|
---|
[68] | 52 | Console.println("Usage: loadSessionsFromClickstream <filename> {<timeout> <minSessionLength>}");
|
---|
[51] | 53 | }
|
---|
| 54 |
|
---|
| 55 | }
|
---|