Esempio n. 1
0
  /** Método que se encarga de cargar los datos en pantalla */
  private void deleteRow(
      HttpServletRequest request, HttpServletResponse response, HttpSession session)
      throws ServletException, IOException {

    int contRegistros = Integer.parseInt(request.getParameter("contadorreg"));

    QuerySearchAvanced querySearchAvanced = new QuerySearchAvanced();
    FieldSearchAvanced[] fieldSearchAvanced = new FieldSearchAvanced[contRegistros];
    int[] idoperator = new int[contRegistros];
    String[] valueWhere = new String[contRegistros];
    String[] nexo = new String[contRegistros];

    Map nameCampos = (Map) session.getAttribute("camposconsulta");

    int ind_auxiliar = 0;

    for (int i = 0; i <= contRegistros; i++) {

      if (request.getParameter("oSelectCampo_" + i) != null) {

        fieldSearchAvanced[ind_auxiliar] =
            (FieldSearchAvanced) nameCampos.get(request.getParameter("oSelectCampo_" + i));

        try {
          idoperator[ind_auxiliar] = Integer.parseInt(request.getParameter("oSelectOperador_" + i));
        } catch (NumberFormatException e) {
          // idoperator[i] = 0;
        }

        valueWhere[ind_auxiliar] = request.getParameter("where_" + i);
        nexo[ind_auxiliar] = request.getParameter("nexo_" + i);

        ind_auxiliar++;
      }
    }

    querySearchAvanced.setFieldSearchAvanced(fieldSearchAvanced);
    querySearchAvanced.setIdOperator(idoperator);
    querySearchAvanced.setValueWhere(valueWhere);
    querySearchAvanced.setNexo(nexo);

    session.setAttribute("contRegistros", new Integer(contRegistros));
    session.setAttribute("valoresConsulta", querySearchAvanced);

    request.getRequestDispatcher("/frmqueryadvan.jsp").forward(request, response);
  }
Esempio n. 2
0
  private QuerySearchAvanced saveSearchConditions(HttpSession session, HttpServletRequest request) {

    String listOrder = RequestUtils.parseRequestParameterAsStringWithEmpty(request, "99999");

    if (StringUtils.isEmpty(listOrder)) {
      listOrder = XML_FLD_UPPER_TEXT + 1;
    }

    int contRegistros = Integer.parseInt(request.getParameter("contadorreg"));

    QuerySearchAvanced querySearchAvanced = new QuerySearchAvanced();
    FieldSearchAvanced[] fieldSearchAvanced = new FieldSearchAvanced[contRegistros];
    int[] idoperator = new int[contRegistros];
    String[] valueWhere = new String[contRegistros];
    String[] nexo = new String[contRegistros];
    boolean[] hasInvalidValue = new boolean[contRegistros];

    Map nameCampos = (Map) session.getAttribute("camposconsulta");

    for (int i = 0; i < contRegistros; i++) {
      FieldSearchAvanced field =
          (FieldSearchAvanced) nameCampos.get(request.getParameter("oSelectCampo_" + i));

      if (field != null) {

        field.setRowId(i);
        fieldSearchAvanced[i] = field;

        try {
          idoperator[i] = Integer.parseInt(request.getParameter("oSelectOperador_" + i));
        } catch (NumberFormatException e) {
          // idoperator[i] = 0;
        }

        valueWhere[i] = request.getParameter("where_" + i);

        hasInvalidValue[i] = false;
      }
      nexo[i] = request.getParameter("nexo_" + i);
    }

    querySearchAvanced.setFieldSearchAvanced(fieldSearchAvanced);
    querySearchAvanced.setIdOperator(idoperator);
    querySearchAvanced.setValueWhere(valueWhere);
    querySearchAvanced.setNexo(nexo);
    querySearchAvanced.setHasInvalidValue(hasInvalidValue);
    querySearchAvanced.setOrder(listOrder);

    session.setAttribute("contRegistros", new Integer(contRegistros));
    session.setAttribute("valoresConsulta", querySearchAvanced);

    return querySearchAvanced;
  }
Esempio n. 3
0
  private void doSearch(
      HttpServletRequest request,
      HttpServletResponse response,
      HttpSession session,
      UseCaseConf useCaseConf,
      PrintWriter writer)
      throws ValidationException, SessionException, BookException, AttributesException,
          SecurityException, ParseException, FileNotFoundException,
          TransformerConfigurationException, TransformerException, Exception {

    QuerySearchAvanced querySearchAvanced = saveSearchConditions(session, request);

    Document xmlDocument = null;
    List badCtrls = null;
    Integer bookID = (Integer) session.getAttribute(Keys.J_BOOK);

    Map rowMap = RowQuerySearchAdvanced.transformToMap(querySearchAvanced);

    // Validar los campos de búsqueda según el formato de cada uno
    badCtrls = bookUseCase.validateAdvancedQueryParams(useCaseConf, bookID, rowMap);

    // Si todos los campos están correctamente rellenados
    if (badCtrls.isEmpty()) {

      xmlDocument = doSearch(useCaseConf, bookID, rowMap, querySearchAvanced.getOrder());

      if (xmlDocument != null) {
        // Almacenamos el xml con los resultados en sesión
        session.setAttribute("queryResults", xmlDocument);

        String script =
            "<script language=javascript>top.g_TreeFunc=true;top.Main.Workspace.EnabledTool();"
                + "window.open(top.g_URL + \"/vldSearchOperator.jsp?method=showResults&SessionPId="
                + session.getId()
                + "\", \"TableData\",\"location=no\",true);</script>";

        response.getWriter().write(script);

      } else {

        writer.write(
            "<HTML><HEAD><script type=text/javascript language=javascript src=\"./scripts/tbltext.js\"></script>");

        ResponseUtils.generateJavaScriptLog(
            writer,
            RBUtil.getInstance(useCaseConf.getLocale())
                .getProperty(Keys.I18N_EXCEPTION_BOOK_HAS_NO_FOLDERS));
        writer.write(ACTIVATE_SEVERAL_ADVSEARCH);

        writer.write("</HEAD><BODY tabIndex=-1></BODY></HTML>");
      }
    } else {
      FieldSearchAvanced[] fieldList = querySearchAvanced.getFieldSearchAvanced();
      boolean[] invalidValues = querySearchAvanced.getHasInvalidValue();
      for (int i = 0; i < fieldList.length; i++) {
        FieldSearchAvanced field = fieldList[i];
        if (field != null) {
          if (badCtrls.contains(new Integer(field.getRowId()))) {
            invalidValues[i] = true;
          } else {
            invalidValues[i] = false;
          }
        }
      }
      // Actualizamos el valor en sesión de los campos de búsqueda para que aparezcan los no
      // validados
      session.setAttribute("valoresConsulta", querySearchAvanced);

      writer.write(
          "<HTML><HEAD><script type=text/javascript language=javascript src=\"./scripts/tbltext.js\"></script>");

      ResponseUtils.generateJavaScriptLog(
          writer,
          RBUtil.getInstance(useCaseConf.getLocale())
              .getProperty(Keys.I18N_ISICRESSRV_QRY_ABORT_CAUSE_INVALID_TEXT));

      writer.write(ACTIVATE_SEVERAL_ADVSEARCH);

      writer.write("</HEAD><BODY tabIndex=-1></BODY></HTML>");
    }
  }