Ejemplo n.º 1
0
 private static String getListQuery(
     Long id_usuario,
     Long id_tipo,
     Long nivel,
     Date fec_from,
     Date fec_to,
     boolean count,
     String sort,
     String dir) {
   StringBuilder sql = new StringBuilder();
   if (count) sql.append("SELECT COUNT(*) ");
   else {
     sql.append("SELECT L.ID_USUARIO, L.FECHA, L.NIVEL, L.ID_TIPO, U.NOMBRE, ");
     if (Constants.DB_TYPE == Constants.DB_TYPE_ORACLE) {
       sql.append(
           "REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(LL.TEXTO, '$1', L.TEXTO1), '$2', L.TEXTO2), '$3', L.TEXTO3), '$4', L.TEXTO4), '$5', L.TEXTO5) AS DESCRIPCION, ");
     } else {
       sql.append(
           "REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(LL.TEXTO, '$1', IFNULL(L.TEXTO1, '')), ");
       sql.append(
           "'$2', IFNULL(L.TEXTO2, '')), '$3', IFNULL(L.TEXTO3, '')), '$4', IFNULL(L.TEXTO4, '')), '$5', IFNULL(L.TEXTO5, '')) AS DESCRIPCION, ");
     }
     sql.append("L.TEXTO1, L.TEXTO2, L.TEXTO3, L.TEXTO4, L.TEXTO5, L.SESION_ID ");
   }
   sql.append(
       "FROM APPBS_USUARIOS_LOG L JOIN APPBS_USUARIOS_LOG_LEGEND LL ON LL.ID_TIPO = L.ID_TIPO ");
   sql.append("JOIN APPBS_USUARIOS U ON L.ID_USUARIO = U.ID_USUARIO ");
   sql.append("WHERE L.ID_APLICACION = '").append(Constants.APP_NAME).append("'");
   if (!Converter.isEmpty(id_usuario)) sql.append(" AND L.ID_USUARIO = ").append(id_usuario);
   if (!Converter.isEmpty(id_tipo)) sql.append(" AND L.ID_TIPO = ").append(id_tipo);
   if (!Converter.isEmpty(nivel)) sql.append(" AND L.NIVEL = ").append(nivel);
   if (!Converter.isEmpty(fec_from))
     sql.append(" AND L.FECHA >= ").append(Converter.getSQLDate(fec_from, true));
   if (!Converter.isEmpty(fec_to))
     sql.append(" AND L.FECHA <= ").append(Converter.getSQLDate(fec_to, true));
   if (!count) sql.append(" ORDER BY ").append(sort).append(" ").append(dir);
   return sql.toString();
 }
Ejemplo n.º 2
0
 /**
  * Obtiene una cadena con los valores que representan la licencia
  *
  * @param sep Separador de Items
  * @param lineSep Separador de lineas
  * @return Cadena con el contenido de la licencia
  */
 public String getLicencia(String sep, String lineSep) {
   StringBuilder text = new StringBuilder();
   text.append(id_licencia)
       .append(sep)
       .append(id_aplicacion)
       .append(sep)
       .append(id_distribuidor)
       .append(sep)
       .append(id_cliente)
       .append(sep);
   text.append(Converter.formatDate(fecha_inicio, "dd/MM/yyyy"))
       .append(sep)
       .append(Converter.formatDate(fecha_final, "dd/MM/yyyy"))
       .append(sep);
   text.append(Converter.formatDate(fecha_actualizacion, "dd/MM/yyyy")).append(sep);
   text.append(trial_tiempo)
       .append(sep)
       .append(trial_terminado ? "S" : "N")
       .append(sep)
       .append(activa ? "S" : "N")
       .append(sep);
   text.append(dias_invalida)
       .append(sep)
       .append(Converter.isEmpty(param_1) ? "" : param_1)
       .append(sep)
       .append(Converter.isEmpty(param_2) ? "" : param_2)
       .append(sep);
   text.append(Converter.isEmpty(param_3) ? "" : param_3)
       .append(sep)
       .append(Converter.isEmpty(param_4) ? "" : param_4)
       .append(sep);
   text.append(Converter.isEmpty(param_5) ? "" : param_5).append(lineSep);
   if (!Converter.isEmpty(items)) {
     for (APPEX_LICENCIA_ITEMS licencia_item : items) {
       if (licencia_item.getActivo()) {
         text.append(licencia_item.getId_item())
             .append(sep)
             .append(licencia_item.getTipo())
             .append(sep);
         if ("I".equals(licencia_item.getTipo())) text.append(licencia_item.getInt_valor());
         else if ("S".equals(licencia_item.getTipo())) text.append(licencia_item.getStr_valor());
         else if ("D".equals(licencia_item.getTipo()))
           text.append(Converter.formatDate(licencia_item.getDate_valor(), "dd/MM/yyyy"));
         text.append(sep)
             .append(licencia_item.getImp_tipo())
             .append(sep)
             .append(Converter.formatFloat(licencia_item.getImporte(), 2))
             .append(lineSep);
       }
     }
   }
   return text.toString();
 }