Example usage for org.json.simple JSONObject clone

List of usage examples for org.json.simple JSONObject clone

Introduction

In this page you can find the example usage for org.json.simple JSONObject clone.

Prototype

@HotSpotIntrinsicCandidate
protected native Object clone() throws CloneNotSupportedException;

Source Link

Document

Creates and returns a copy of this object.

Usage

From source file:modelo.PDFManagers.PDFManager.java

public JSONArray contarParam(String codigoProceso) throws Exception {

    //Ejecutamos la consulta y obtenemos el ResultSet
    SeleccionarPDF select = new SeleccionarPDF();
    ResultSet rset = select.contarParam(codigoProceso);

    //Creamos los JSONArray para guardar los objetos JSON
    JSONArray jsonArray = new JSONArray();

    //Recorremos el ResultSet, armamos el objeto JSON con la info y guardamos
    //en el JSONArray.
    JSONObject jsonObject = new JSONObject();
    while (rset.next()) {

        //Armamos el objeto JSON con la informacion del registro

        jsonObject.put("cantidad", rset.getString("CANTIDAD"));

        //Guardamos el JSONObject en el JSONArray y lo enviamos a la vista.

    }/* www .ja va 2  s  .com*/

    jsonArray.add(jsonObject.clone());

    //Se cierra el ResultSet
    select.desconectar();

    return jsonArray;

}

From source file:modelo.ProcesoVertimientosManagers.ManejoLodos.java

public JSONArray getArchivosLodos(int codigo) throws Exception {

    //Ejecutamos la consulta y obtenemos el ResultSet
    SeleccionarLodos select = new SeleccionarLodos();
    ResultSet rset = select.getArchivosLodos(codigo);

    //Creamos los JSONArray para guardar los objetos JSON
    JSONArray jsonArray = new JSONArray();
    JSONArray jsonArreglo = new JSONArray();

    //Recorremos el ResultSet, armamos el objeto JSON con la info y guardamos
    //en el JSONArray.
    while (rset.next()) {

        //Armamos el objeto JSON con la informacion del registro
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("codigo", rset.getString("CODIGO"));
        String nombreArchivo = (rset.getString("NOMBRE_ARCHIVO")).replace("\\", "");
        jsonObject.put("nombreArchivo", nombreArchivo);

        //Guardamos el JSONObject en el JSONArray y lo enviamos a la vista.
        jsonArray.add(jsonObject.clone());

    }//from w w  w.  j a v  a  2 s  .  c  o m

    jsonArreglo.add(jsonArray);
    select.desconectar();

    return jsonArreglo;

}

From source file:modelo.ProcesoVertimientosManagers.InformeProcesoSeco.java

public JSONArray getArchivosCargados(int codigoProceso, Integer codigo) throws SQLException {

        ResultSet rset;//from  w w  w  .  j av a 2s  .  co m

        JSONObject jsonObject = new JSONObject();
        JSONArray jsonArray = new JSONArray();
        JSONArray jsonArreglo = new JSONArray();
        SeleccionarArchivosInformesCargados select = new SeleccionarArchivosInformesCargados();

        rset = select.getArchivosCargados(codigoProceso, codigo);

        while (rset.next()) {

            jsonObject.put("codigo", rset.getString("CODIGO"));
            jsonObject.put("nombreArchivo", rset.getString("NOMBRE_ARCHIVO"));

            jsonArray.add(jsonObject.clone());

        }

        jsonArreglo.add(jsonArray);

        //Se cierra el ResultSet
        select.desconectar();

        return jsonArreglo;

    }

From source file:modelo.ProcesoVertimientosManagers.VerificacionInfoCaracterizacion.java

public JSONArray getDevolucionCaracterizacion(String codigoPoceso) throws SQLException {

    JSONArray jsonArray = new JSONArray();
    JSONObject jsonObject = new JSONObject();

    SeleccionarVerificacionInfoCaracterizacion select = new SeleccionarVerificacionInfoCaracterizacion();
    ResultSet rset = select.getDevolucionCaracterizacion(codigoPoceso);

    while (rset.next()) {
        jsonObject.put("tipoDevolCaracterizacion", rset.getString(("TIPO_DEVOLUCION")));
        jsonObject.put("fechaEntDevolCaracterizacion", rset.getString(("FECHA_ENTREGA")));
        jsonObject.put("observacionDevolCaracterizacion", rset.getString(("OBSERVACION")));
        jsonObject.put("fechaDevolCaracterizacion", rset.getString(("FECHA_DEVOLUCION")));
    }//  w w w .  j  a v  a2s  .co m

    jsonArray.add(jsonObject.clone());
    return jsonArray;
}

From source file:modelo.ProcesoVertimientosManagers.ManejoLodos.java

public JSONArray getLodos(String codigo) throws Exception {

    //Ejecutamos la consulta y obtenemos el ResultSet
    SeleccionarEntidadesLodos select = new SeleccionarEntidadesLodos();
    ResultSet rset = select.getLodos(codigo);
    //Creamos los JSONArray para guardar los objetos JSON
    JSONArray jsonArray = new JSONArray();
    JSONArray jsonArreglo = new JSONArray();

    //Recorremos el ResultSet, armamos el objeto JSON con la info y guardamos
    //en el JSONArray.
    while (rset.next()) {

        //Armamos el objeto JSON con la informacion del registro
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("codigo", rset.getString("CODIGO"));
        jsonObject.put("nombreEmpresa", rset.getString("NOMBRE_EMPRESA"));
        jsonObject.put("recolecta", rset.getString("RECOLECTA"));
        jsonObject.put("transporte", rset.getString("TRANSPORTE"));
        jsonObject.put("dispone", rset.getString("DISPONE"));

        //Guardamos el JSONObject en el JSONArray y lo enviamos a la vista.
        jsonArray.add(jsonObject.clone());

    }// www  .  j  av a 2s .  c o  m

    jsonArreglo.add(jsonArray);
    select.desconectar();

    return jsonArreglo;

}

From source file:modelo.ProcesoVertimientosManagers.VerificacionInfoCaracterizacion.java

public JSONArray getVerificacionInfoCaracterizacion(Integer codigoProceso, Integer tipoInforme)
        throws SQLException {

    ResultSet rset = null;//from   ww w.  j a v  a  2 s. com
    JSONArray jsonArray = new JSONArray();
    JSONObject jsonObject = new JSONObject();
    JSONArray jsonArrayPreguntas = new JSONArray();

    //Se crea el objeto
    SeleccionarVerificacionInfoCaracterizacion select = new SeleccionarVerificacionInfoCaracterizacion(
            codigoProceso, tipoInforme);

    //Seleccionamos los "Hijos" y  "Nietos" del requisito "Padre"
    rset = select.getVerificaciones();

    while (rset.next()) {

        jsonObject.put("codigo", rset.getString("CODIGO"));
        jsonObject.put("reguisito", rset.getString("DESCRIPCION"));
        jsonObject.put("fk_informe", rset.getString("FK_TIPO_INFORME"));
        jsonObject.put("checkeado", rset.getString("TIENE"));

        jsonArray.add(jsonObject.clone());

    }

    jsonArrayPreguntas.add(jsonArray.clone());

    //Se cierra el ResultSet
    rset.close();
    select.desconectar();

    return jsonArrayPreguntas;
}

From source file:control.ProcesoVertimientosServlets.RegistrarSuperviciones.java

/**
 * Handles the HTTP <code>POST</code> method.
 *
 * @param request servlet request/*from ww  w  .j av a 2s  .c  om*/
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    JSONArray resp = new JSONArray();

    try {
        //Obtenemos la cadena con la informacion y la convertimos en un
        //JSONArray
        String monitoreos = request.getParameter("monitoreos");
        int tecnico = Integer.parseInt(request.getParameter("tecnico"));
        int resul;
        int codProceso;
        JSONObject jsonObject = new JSONObject();
        JSONArray jsonArray = new JSONArray();

        Object obj = JSONValue.parse(monitoreos);
        JSONArray monitoreosArray = new JSONArray();
        monitoreosArray = (JSONArray) obj;

        //Recorremos el JSONArray y obtenemos la informacion.
        for (int i = 0; i < monitoreosArray.size(); i++) {
            codProceso = Integer.parseInt(monitoreosArray.get(i).toString());

            ProgramarMonitoreo manager = new ProgramarMonitoreo();
            resul = manager.registrarSupervision(codProceso, tecnico);

            jsonObject.put("monitoreo", codProceso);
            jsonObject.put("resultado", resul);

            jsonArray.add(jsonObject.clone());

        }
        resp.add(jsonArray);
        //Armamos la respuesta JSON y la enviamos
        response.setContentType("application/json");

        for (Object jsonObjectResp : resp) {

            response.getWriter().write(jsonObjectResp.toString());

        }
    } catch (Exception ex) {

    }
}

From source file:modelo.ProcesoVertimientosManagers.ProcesoVertimientos.java

public JSONArray getProcesoVertimientos() throws Exception {

    SeleccionarProcesoVertimientos select = new SeleccionarProcesoVertimientos();
    ResultSet rset = select.ejecutar();

    //Creamos los JSONArray para guardar los objetos JSON
    JSONArray jsonArray = new JSONArray();
    JSONArray jsonArreglo = new JSONArray();
    //Recorremos el ResultSet, armamos el objeto JSON con la info y guardamos
    //en el JSONArray.
    while (rset.next()) {

        //Armamos el objeto JSON con la informacion del registro
        JSONObject jsonObject = new JSONObject();

        jsonObject.put("codigoProceso", rset.getString("CODIGO"));
        jsonObject.put("nit", rset.getString("NIT"));
        jsonObject.put("razonSocial", rset.getString("RAZON_SOCIAL"));
        jsonObject.put("actividadEconomica", rset.getString("CIIU"));
        jsonObject.put("contrato", rset.getString("FK_CONTRATO"));
        jsonObject.put("tipoInforme", rset.getString("TIPOINFORME"));
        jsonObject.put("fechaProceso", rset.getString("FECHA_PROCESO"));
        jsonObject.put("estado", rset.getString("ESTADOP"));

        //Guardamos el JSONObject en el JSONArray y lo enviamos a la vista.
        jsonArray.add(jsonObject.clone());

    }/*from ww w .j  av  a2 s  .  c  o m*/

    jsonArreglo.add(jsonArray);

    //Se cierra el ResultSet
    select.desconectar();

    return jsonArreglo;

}

From source file:modelo.ParametrizacionManagers.Consultores.java

public JSONArray getConsultor(int codigo) {

    SeleccionarConsultores seleccionar = new SeleccionarConsultores();
    ResultSet rset = seleccionar.getConsultor(codigo);

    JSONArray jsonArray = new JSONArray();
    JSONObject jsonObject = new JSONObject();

    try {/*ww w  . j  av a2s  . c om*/
        while (rset.next()) {

            jsonObject.put("codigo", rset.getString("CODIGO"));
            jsonObject.put("nombre", rset.getString("NOMBRES"));
            jsonObject.put("apellidos", rset.getString("APELLIDOS"));
            jsonObject.put("direccion", rset.getString("DIRECCION"));
            jsonObject.put("telefono1", rset.getString("TELEFONO1"));
            jsonObject.put("telefono2", rset.getString("TELEFONO2"));
            jsonObject.put("correo", rset.getString("EMAIL"));
            jsonObject.put("identificacion", rset.getString("IDENTIFICACION"));
            jsonObject.put("descripcion", rset.getString("NOMBRES") + ' ' + rset.getString("APELLIDOS"));

            jsonArray.add(jsonObject.clone());

        }

        seleccionar.desconectar();

    } catch (SQLException ex) {
        // Logger.getLogger(Laboratorios.class.getName()).log(Level.SEVERE, null, ex);
    }

    return jsonArray;
}

From source file:modelo.AutenticacionManager.PermisosAcceso.java

public JSONArray SeleccionarPermisos(String rol) throws SQLException {

    JSONArray permisos = new JSONArray();
    JSONArray ArrayPantallas = new JSONArray();
    JSONObject modulos = new JSONObject();
    JSONObject pantallas = new JSONObject();
    Boolean flag = true;/*from  w w w  .j  a va2 s  .  c  o  m*/
    String modulo = "";
    String codigo_modulo = "";
    SeleccionarPermisos select = new SeleccionarPermisos();

    ResultSet result = select.getModulos();

    while (result.next()) {

        modulo = result.getString("VAR_MODULO");
        codigo_modulo = result.getString("PK_CODIGO");
        modulos.put("modulo", modulo);

        ResultSet rstPantallas = select.getPantallas(rol, codigo_modulo);

        while (rstPantallas.next()) {

            pantallas.put("codigo", rstPantallas.getString("PK_CODIGO"));
            pantallas.put("jsp", rstPantallas.getString("VAR_PANTALLA"));
            pantallas.put("pantalla", rstPantallas.getString("VAR_DESCRIPCION"));
            pantallas.put("existe", rstPantallas.getString("EXISTE"));

            ArrayPantallas.add(pantallas.clone());
            pantallas.clear();
        }

        modulos.put("pantallas", ArrayPantallas.clone());
        ArrayPantallas.clear();
        permisos.add(modulos.clone());
    }

    select.desconectar();
    return permisos;
}