public static void setTour(HttpSession session, int tour) { if (SessionManager.isOnTour(session) && tour == 0) { System.out.println("*** Info, closing site tour"); session.setAttribute("onTour", false); session.removeAttribute("tourStep"); session.removeAttribute("tourQuery"); } else if (!SessionManager.isOnTour(session) && tour > 0) { session.setAttribute("onTour", true); session.setAttribute("tourStep", 0); } if (SessionManager.isOnTour(session) && tour != (int) session.getAttribute("tourStep")) { session.setAttribute("tourStep", tour); } }
public static Query getQuery(HttpSession session, String queryId, int from) { if (from == 0 && SessionManager.isOnTour(session)) { // tour return (Query) session.getAttribute("tourQuery"); } else if (from <= 4) { // search @SuppressWarnings("unchecked") List<Query> queries = (List<Query>) session.getAttribute("queries"); if (queries != null) { for (int i = 0; i < queries.size(); i++) { Query query = queries.get(i); if (query.getId().equals(queryId)) return query; } } } else if (from == 5) { // explore/statistics Query statsQuery = (Query) session.getAttribute("statsQuery"); if (statsQuery != null && statsQuery.getId().equals(queryId)) return statsQuery; else session.removeAttribute("statsQuery"); } else if (from == 6) { // explore/ngrams Query ngramsQuery = (Query) session.getAttribute("ngramsQuery"); if (ngramsQuery != null && ngramsQuery.getId().equals(queryId)) return ngramsQuery; else session.removeAttribute("ngramsQuery"); } return null; }
public static int getTourStep(HttpSession session) { if (SessionManager.isOnTour(session) && session.getAttribute("tourStep") != null) return (int) session.getAttribute("tourStep"); return 0; }