Exemplo n.º 1
0
  private void actionValiderCaddy(
      HttpServletRequest request, HttpServletResponse response, ServletContext sc) {
    OracleAccess oracle = (OracleAccess) getVariableSession(request, "oracle");
    BeanCaddy beanCaddy = (BeanCaddy) getVariableSession(request, "beanCaddy");
    LinkedList<Integer> listInserer = new LinkedList<Integer>();
    for (BeanMovieCaddy beanMovieCaddy : beanCaddy.getListMovie()) {
      oracle.initCallProc("PACKAGE_RECHERCHE", "insertCommande", 3);
      boolean ok =
          oracle.doInsertCommande(
              beanMovieCaddy.getId(), beanMovieCaddy.getQuantite(), beanMovieCaddy.getPhysique());
      if (ok) {
        listInserer.add(beanMovieCaddy.getId());
      }
    }

    int taille = beanCaddy.getListMovie().size();
    for (int idInserer : listInserer) {
      int i = 0;
      while (i < taille) {
        if (beanCaddy.getListMovie().get(i).getId() == idInserer) {
          beanCaddy.getListMovie().remove(i);
          break;
        }
        i++;
      }
    }
    addVariableSession(request, "beanCaddy", beanCaddy);
    setCaddy(request, sc);
  }
Exemplo n.º 2
0
 private void actionDetails(
     HttpServletRequest request, HttpServletResponse response, ServletContext sc) {
   int idMovie = Integer.parseInt(request.getParameter("idMovie"));
   OracleAccess oracle = (OracleAccess) getVariableSession(request, "oracle");
   oracle.initCallFunc("PACKAGE_RECHERCHE", "getDetails", 1);
   BeanDetails beanDetails = oracle.doGetDetails(idMovie);
   addVariableSession(request, "beanDetails", beanDetails);
 }
Exemplo n.º 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);
  }
Exemplo n.º 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);
  }