示例#1
0
 private void actionCommander(
     HttpServletRequest request, HttpServletResponse response, ServletContext sc) {
   int idMovie = Integer.parseInt(request.getParameter("idMovie"));
   int quantite = Integer.parseInt(request.getParameter("quantite"));
   BeanCaddy beanCaddy = (BeanCaddy) getVariableSession(request, "beanCaddy");
   boolean found = false;
   if (beanCaddy == null) {
     beanCaddy = new BeanCaddy();
   } else {
     for (BeanMovieCaddy beanMovieCaddy : beanCaddy.getListMovie()) {
       if (beanMovieCaddy.getId() == idMovie) {
         beanMovieCaddy.addQuantite(quantite);
         found = true;
         break;
       }
     }
   }
   if (found == false) {
     BeanResultat beanResultat = (BeanResultat) getVariableSession(request, "beanResultat");
     BeanMovieCaddy beanMovieToAdd = null;
     for (BeanMovie beanMovie : beanResultat.getListMovie()) {
       if (beanMovie.getId() == idMovie) {
         beanMovieToAdd = new BeanMovieCaddy(beanMovie);
         beanMovieToAdd.setQuantite(quantite);
         break;
       }
     }
     beanCaddy.add(beanMovieToAdd);
   }
   addVariableSession(request, "beanCaddy", beanCaddy);
   setCaddy(request, sc);
 }
示例#2
0
 private void actionTrier(
     HttpServletRequest request, HttpServletResponse response, ServletContext sc) {
   String type = request.getParameter("type");
   BeanResultat beanResultat = (BeanResultat) getVariableSession(request, "beanResultat");
   if (type.equals("popularite")) {
     beanResultat.triByPopularite();
   } else if (type.equals("frequence")) {
     beanResultat.triByFrequence();
   } else if (type.equals("perenite")) {
     beanResultat.triByPerenite();
   }
   addVariableSession(request, "beanResultat", beanResultat);
 }
示例#3
0
  private void actionGetPage(
      HttpServletRequest request, HttpServletResponse response, ServletContext sc) {
    int numpage = Integer.parseInt(request.getParameter("numPage"));
    BeanResultat beanResultat = (BeanResultat) getVariableSession(request, "beanResultat");

    int min = numpage * beanResultat.getNbResultByPage() + 1;
    int max = min + beanResultat.getNbResultByPage() - 1;

    String requeteLimite = getRequeteLimite(min, max, beanResultat.getRequete());
    System.out.println("RequeteLimite: " + requeteLimite);

    OracleAccess oracle = (OracleAccess) getVariableSession(request, "oracle");
    oracle.initCallFunc("PACKAGE_RECHERCHE", "doSearch", 1);
    BeanResultat beanResultat2 = oracle.doGetListMovies(requeteLimite);
    beanResultat.setListMovie(beanResultat2.getListMovie());

    addVariableSession(request, "beanResultat", beanResultat);
  }
示例#4
0
  private void actionRechercher(
      HttpServletRequest request, HttpServletResponse response, ServletContext sc) {
    OracleAccess oracle = (OracleAccess) getVariableSession(request, "oracle");

    int nbByPage = Integer.parseInt(request.getParameter("nbPage"));
    String rech_copieNonPresente = request.getParameter("rech_copieNonPresente");
    String requete = null;
    String rech_popularite = request.getParameter("rech_popularite");
    String ticketMin = request.getParameter("ticketMin");
    String ticketMax = request.getParameter("ticketMax");

    String rech_frequence = request.getParameter("rech_frequence");
    String seanceMin = request.getParameter("seanceMin");
    String seanceMax = request.getParameter("seanceMax");

    String rech_dureeProg = request.getParameter("rech_dureeProg");
    String semaineMin = request.getParameter("semaineMin");
    String semaineMax = request.getParameter("semaineMax");

    String rech_copieDispos = request.getParameter("rech_copieDispos");
    String copieMin = request.getParameter("copieMin");
    String copieMax = request.getParameter("copieMax");

    if (rech_popularite != null) {
      if (requete == null) {
        requete =
            "select mo.idMovie from movies mo where(select sum(ct.nbre) from commanderTicket ct, projection p where ct.dateHeureProjection = p.dateHeureProjection AND ct.numeroSalle = p.numeroSalle and p.idCopie in (select idCopie from copies where idMovie = mo.idMovie))between "
                + ticketMin
                + " and "
                + ticketMax;
      } else {
        requete +=
            " and idMovie in(select mo.idMovie from movies mo where(select sum(ct.nbre) from commanderTicket ct, projection p where ct.dateHeureProjection = p.dateHeureProjection AND ct.numeroSalle = p.numeroSalle and p.idCopie in (select idCopie from copies where idMovie = mo.idMovie))between "
                + ticketMin
                + " and "
                + ticketMax
                + ")";
      }
    }

    if (rech_frequence != null) {
      if (requete == null) {
        requete =
            "select idMovie from movies mo where (select round((decode(max(dateHeureProjection), min(dateHeureProjection), 1, max(dateHeureProjection) - min(dateHeureProjection))) / ((to_number(to_char(max(dateHeureProjection), 'WW')) - to_number(to_char(min(dateHeureProjection), 'WW')) + 52 * (to_number(to_char(max(dateHeureProjection), 'YYYY')) - to_number(to_char(min(dateHeureProjection), 'YYYY'))))+1)) frequenceByWeek from dual, projection p where p.idCopie in(select idCopie from copies where idMovie = mo.idMovie)) between "
                + seanceMin
                + " and "
                + seanceMax;
      } else {
        requete +=
            " and idMovie in(select idMovie from Movies mo where(select round((decode(max(dateHeureProjection), min(dateHeureProjection), 1, max(dateHeureProjection) - min(dateHeureProjection))) / ((to_number(to_char(max(dateHeureProjection), 'WW')) - to_number(to_char(min(dateHeureProjection), 'WW')) + 52 * (to_number(to_char(max(dateHeureProjection), 'YYYY')) - to_number(to_char(min(dateHeureProjection), 'YYYY'))))+1)) frequenceByWeek from dual, projection p where p.idCopie in(select idCopie from copies where idMovie = mo.idMovie)) between "
                + seanceMin
                + " and "
                + seanceMax
                + ")";
      }
    }

    if (rech_dureeProg != null) {
      if (requete == null) {
        requete =
            "select idMovie from movies mo where (select ((to_number(to_char(max(p.dateHeureProjection), 'WW')) - to_number(to_char(min(p.dateHeureProjection), 'WW')) + 52 * (to_number(to_char(max(p.dateHeureProjection), 'YYYY')) - to_number(to_char(min(p.dateHeureProjection), 'YYYY'))))+1) diff_week from projection p where p.idCopie in (select idCopie from copies where idMovie = mo.idMovie)) between "
                + semaineMin
                + " and "
                + semaineMax;
      } else {
        requete +=
            " and idMovie in(select idMovie from movies mo where (select ((to_number(to_char(max(p.dateHeureProjection), 'WW')) - to_number(to_char(min(p.dateHeureProjection), 'WW')) + 52 * (to_number(to_char(max(p.dateHeureProjection), 'YYYY')) - to_number(to_char(min(p.dateHeureProjection), 'YYYY'))))+1) diff_week from projection p where p.idCopie in (select idCopie from copies where idMovie = mo.idMovie)) between "
                + semaineMin
                + " and "
                + semaineMax
                + ")";
      }
    }

    if (rech_copieDispos != null) {
      if (requete == null) {
        requete =
            "select idMovie from movies mo where(select count(*) from copies c where idMovie = mo.idMovie and idCopie not in(select idCopie from projection)) between "
                + copieMin
                + " and "
                + copieMax;
      } else {
        requete +=
            " and idMovie in(select idMovie from movies mo where(select count(*) from copies c where idMovie = mo.idMovie and idCopie not in(select idCopie from projection)) between "
                + copieMin
                + " and "
                + copieMax
                + ")";
      }
    }

    if (rech_copieNonPresente != null) {
      if (requete == null) {
        requete =
            "select distinct idMovie from COPIES_CB where idMovie not in(select distinct idMovie from copies)";
      } else {
        requete +=
            " and idMovie in(select distinct idMovie from COPIES_CB where idMovie not in(select distinct idMovie from copies))";
      }
    }

    oracle.initCallFunc("PACKAGE_RECHERCHE", "doSearch", 1);

    String requeteCount = "select count(*) from(";
    requeteCount += requete + ")";

    String requeteLimitee = getRequeteLimite(0, nbByPage, requete);
    BeanResultat beanResultat = oracle.doGetListMovies(requeteLimitee);
    if (beanResultat != null) {
      oracle.initCallFunc("PACKAGE_RECHERCHE", "getCount", 1);
      int numResultat = oracle.doGetCount(requeteCount);
      beanResultat.setNumResultat(numResultat);
      beanResultat.setRequete(requete);
      beanResultat.setNbResultByPage(nbByPage);
    }
    addVariableSession(request, "beanResultat", beanResultat);
  }
示例#5
0
 private void traitementAction(
     HttpServletRequest request, HttpServletResponse response, ServletContext sc, String action) {
   if (action == null) {
     this.rediriger(request, response, sc, "/Accueil.jsp");
   } else if (action.equals("Recherche")) {
     this.rediriger(request, response, sc, "/Recherche.jsp");
   } else if (action.equals("Rechercher")) {
     actionRechercher(request, response, sc);
     this.rediriger(request, response, sc, "/Results.jsp");
   } else if (action.equals("resultat")) {
     this.rediriger(request, response, sc, "/Results.jsp");
   } else if (action.equals("getImage")) {
     int idMovie = Integer.parseInt(request.getParameter("idMovie"));
     BeanResultat beanResultat = (BeanResultat) getVariableSession(request, "beanResultat");
     LinkedList<BeanMovie> listMovie = beanResultat.getListMovie();
     for (BeanMovie beanMovie : listMovie) {
       if (beanMovie.getId() == idMovie) {
         Blob imageBlob = beanMovie.getAffiche();
         response.setContentType("image/jpeg");
         byte[] bytes;
         try {
           bytes = imageBlob.getBytes(1, (int) imageBlob.length());
           bytes = resize(bytes, 138, 97);
           response.setContentLength(bytes.length);
           response.getOutputStream().write(bytes);
           response.getOutputStream().flush();
           response.getOutputStream().close();
         } catch (Exception ex) {
           Logger.getLogger(ServletControle.class.getName()).log(Level.SEVERE, null, ex);
         }
       }
     }
   } else if (action.equals("getImageCaddy")) {
     int idMovie = Integer.parseInt(request.getParameter("idMovie"));
     BeanCaddy beanCaddy = (BeanCaddy) getVariableSession(request, "beanCaddy");
     LinkedList<BeanMovieCaddy> listMovie = beanCaddy.getListMovie();
     for (BeanMovieCaddy beanMovie : listMovie) {
       if (beanMovie.getId() == idMovie) {
         Blob imageBlob = beanMovie.getAffiche();
         response.setContentType("image/jpeg");
         byte[] bytes;
         try {
           bytes = imageBlob.getBytes(1, (int) imageBlob.length());
           bytes = resize(bytes, 138, 97);
           response.setContentLength(bytes.length);
           response.getOutputStream().write(bytes);
           response.getOutputStream().flush();
           response.getOutputStream().close();
         } catch (Exception ex) {
           Logger.getLogger(ServletControle.class.getName()).log(Level.SEVERE, null, ex);
         }
       }
     }
   } else if (action.equals("details")) {
     actionDetails(request, response, sc);
     this.rediriger(request, response, sc, "/Details.jsp");
   } else if (action.equals("getPage")) {
     actionGetPage(request, response, sc);
     this.rediriger(request, response, sc, "/Results.jsp");
   } else if (action.equals("getPageCaddy")) {
     this.rediriger(
         request, response, sc, "/Caddy.jsp?numPage=" + request.getParameter("numPage"));
   } else if (action.equals("trier")) {
     actionTrier(request, response, sc);
     this.rediriger(request, response, sc, "/Results.jsp");
   } else if (action.equals("commander")) {
     actionCommander(request, response, sc);
     rediriger(request, response, sc, "/Caddy.jsp?numPage=0");
   } else if (action.equals("deconnecter")) {
     actionDeconnecter(request, response, sc);
     rediriger(request, response, sc, "/index.jsp");
   } else if (action.equals("caddy")) {
     rediriger(request, response, sc, "/Caddy.jsp?numPage=0");
   } else if (action.equals("actionCaddy")) {
     traiterActionCaddy(request, response, sc);
     rediriger(request, response, sc, "/Caddy.jsp?numPage=0");
   } else if (action.equals("error")) {
     rediriger(request, response, sc, "/error.jsp");
   } else if (action.equals("validerCaddy")) {
     actionValiderCaddy(request, response, sc);
     rediriger(request, response, sc, "/Caddy.jsp?numPage=0");
   } else {
     this.rediriger(request, response, sc, "/Accueil.jsp");
   }
 }