package it.cdq;
import it.cdq.model.db.Trip;
import it.cdq.selenium.StartHub;
import it.cdq.selenium.hub.StartHubProgramaticallyJson;
import it.cdq.service.CodoquService;
import java.util.List;
import org.apache.log4j.Logger;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class MainService {
protected static Logger logger = Logger.getLogger(MainService.class);
private static CodoquService codoquService;
protected static StartHub hub;
private static void init() {
ApplicationContext context = new ClassPathXmlApplicationContext(
"/context.xml");
codoquService = context.getBean(CodoquService.QUALIFIER,
CodoquService.class);
}
public static void main(String[] args) {
System.setProperty("codoqu.dateFrom", "25/09/2014");
System.setProperty("codoqu.dateTo", "30/09/2014");
init();
// startAllDbVersion();
startAll();
}
public static void startAll() {
startHub();
codoquService.launchThread();
stopHub();
}
public static void startAllDbVersion() {
startHub();
List<Trip> list = codoquService.generatesUpcomingTripsList();
codoquService.persistOnlyNewTripList(list);
codoquService.launchThreadDbVersion();
stopHub();
}
public static void printAll() {
codoquService.printAll();
}
public static void startHub() {
logger.info("startHubProgramaticallyJson");
try {
hub = new StartHubProgramaticallyJson();
hub.startHub();
} catch (Exception e) {
logger.error("Exception " + e);
}
}
public static void stopHub() {
logger.info("stopHubProgramaticallyJson");
try {
hub.startHub();
} catch (Exception e) {
logger.error("Exception " + e);
}
}
}