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:mml.handler.json.Dialect.java

/**
 * Is one dialect the same as another?/*ww  w.  j a  v  a  2 s.  c  o  m*/
 * @param dialect1 the first dialect file
 * @param dialect2 the second dialect file
 * @return true if they are equal else false
 */
public static boolean compare(JSONObject dialect1, JSONObject dialect2) {
    JSONObject d1 = (JSONObject) dialect1.clone();
    JSONObject d2 = (JSONObject) dialect2.clone();
    // ignore generated ids
    d1.remove("_id");
    d2.remove("_id");
    return compareObjects(d1, d2);
}

From source file:modelo.UsuariosManagers.Roles.java

public JSONArray getRoles(String usuario, String rol, String codigo) throws SQLException {

    SeleccionarRoles select = new SeleccionarRoles();

    ResultSet rset = select.getRoles(codigo, usuario);

    //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("PK_CODIGO"));
        jsonObject.put("descripcion", rset.getString("VAR_ROL"));
        //Guardamos el JSONObject en el JSONArray y lo enviamos a la vista.
        jsonArray.add(jsonObject.clone());
    }//from   w w  w  .  ja  v  a  2s.  c o m

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

}

From source file:modelo.ParametrizacionManagers.TipoVisita.java

public JSONArray getTiposVisitas() throws SQLException {
    //Ejecutamos la consulta y obtenemos el ResultSet
    SeleccionarTipoVisita select = new SeleccionarTipoVisita();
    ResultSet rset = select.getTiposVisitas();

    //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("descripcion", rset.getString("DESCRIPCION"));

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

    }//from  w  w w  . j a  va 2s .  com

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

From source file:modelo.ParametrizacionManagers.TiemposBackup.java

/**
 * /* w ww .java2 s .c  o  m*/
 * Obtiene la informacion de las unidades de medida y
 * guarda todo en un JSONArray para entregarselo a la vista.
 * 
 * @return JSONArray
 * @throws SQLException 
 */
public JSONArray getTiemposBackup() throws SQLException {

    //Ejecutamos la consulta y obtenemos el ResultSet
    SeleccionarTiemposBackup select = new SeleccionarTiemposBackup();
    ResultSet rset = select.getTiemposBackup();

    //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("tiempo", rset.getString("DIAS_BACKUP"));

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

    }

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

}

From source file:modelo.ParametrizacionManagers.TiemposBackup.java

/**
  * /*from w  w  w .j  a v  a  2  s.  c  o  m*/
  * Obtiene la informacion de una unidad de medida y
  * guarda todo en un JSONArray para entregarselo a la vista.
  * 
  * @return JSONArray
  * @throws SQLException 
  */
public JSONArray getTiempoBackup(int codigo) throws SQLException {

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

    //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.
    while (rset.next()) {
        JSONObject jsonObject = new JSONObject();
        //Armamos el objeto JSON con la informacion del registro
        jsonObject.put("codigo", rset.getString("CODIGO"));
        jsonObject.put("tiempo", rset.getString("DIAS_BACKUP"));

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

    }

    select.desconectar();
    return jsonArray;

}

From source file:modelo.ParametrizacionManagers.TiposContactos.java

/**
* 
* Obtiene la informacion del tipo de contacto mediante un codigo y
* guarda todo en un JSONArray para entregarselo a la vista.
* 
* @return JSONArray/*from   ww  w .j  a  va  2 s . com*/
* @throws SQLException 
*/

public JSONArray getTipoContacto(int codigo) throws Exception {

    //Ejecutamos la consulta y obtenemos el ResultSet
    SeleccionarTiposContactos seleccionar = new SeleccionarTiposContactos();
    ResultSet rst = seleccionar.getTipoContacto(codigo);

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

    while (rst.next()) {
        //Creamos el objecto JSON
        jsonObject.put("descripcion", rst.getString("DESCRIPCION"));
        jsonObject.put("codigo", rst.getString("CODIGO"));

        //Creamos el Array JSON
        jsonArray.add(jsonObject.clone());

    }
    seleccionar.desconectar();
    return jsonArray;

}

From source file:modelo.ParametrizacionManagers.MotivosVisitas.java

/**
* 
* Obtiene la informacion del tipo de contacto mediante un codigo y
* guarda todo en un JSONArray para entregarselo a la vista.
* 
* @return JSONArray/*  www  . j  av  a2s . co  m*/
* @throws SQLException 
*/

public JSONArray getMotivoVisita(int codigo) throws Exception {

    //Ejecutamos la consulta y obtenemos el ResultSet
    SeleccionarMotivosVisitas seleccionar = new SeleccionarMotivosVisitas();
    ResultSet rst = seleccionar.getMotivoVisita(codigo);

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

    while (rst.next()) {
        //Creamos el objecto JSON
        jsonObject.put("descripcion", rst.getString("DESCRIPCION"));
        jsonObject.put("codigo", rst.getString("CODIGO"));

        //Creamos el Array JSON
        jsonArray.add(jsonObject.clone());

    }

    seleccionar.desconectar();
    return jsonArray;

}

From source file:modelo.ParametrizacionManagers.AcreditacionParametros.java

/**
 * /* w w w.  j  a  va2 s.  com*/
 * Llama al Delegate para obtener un cliente especifico
 * 
 * @param codigo
 * @return
 * @throws Exception 
 */
public JSONArray getAcreditacionPorLab(String lab) throws Exception {

    //Ejecutamos la consulta y obtenemos el ResultSet
    SeleccionarAcreditacionParametros select = new SeleccionarAcreditacionParametros();
    ResultSet rset = select.getAcreditacionPorLab(lab);

    //Creamos los JSONArray para guardar los objetos JSON
    JSONArray jsonArray = new JSONArray();
    JSONArray salida = 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("codigoParam", rset.getString("CODIGO_PARAM"));
        /*jsonObject.put("parametro", rset.getString("PARAMETRO"));*/

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

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

    salida.add(jsonArray);
    return salida;

}

From source file:modelo.ParametrizacionManagers.TiposInformeVertimientos.java

/**
* 
* Obtiene la informacion del tipo de Informe mediante un codigo y
* guarda todo en un JSONArray para entregarselo a la vista.
* 
* @return JSONArray/*from  w  w w.j a  v a  2  s . c o  m*/
* @throws SQLException 
*/

public JSONArray getTipoInforme(int codigo) throws Exception {

    //Ejecutamos la consulta y obtenemos el ResultSet
    SeleccionarTiposInformesVertimiento seleccionar = new SeleccionarTiposInformesVertimiento();
    ResultSet rst = seleccionar.getTipoInforme(codigo);

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

    while (rst.next()) {
        //Creamos el objecto JSON
        jsonObject.put("descripcion", rst.getString("DESCRIPCION"));
        jsonObject.put("codigo", rst.getString("CODIGO"));

        //Creamos el Array JSON
        jsonArray.add(jsonObject.clone());

    }
    seleccionar.desconectar();
    return jsonArray;

}

From source file:modelo.ParametrizacionManagers.TiposInformeVertimientos.java

/**
* 
* Obtiene la informacion del tipo de Informe de caracterizacin  y Proceso Seco
* guarda todo en un JSONArray para entregarselo a la vista.
* 
* @return JSONArray//from  w w w .java  2s.c om
* @throws SQLException 
*/

public JSONArray getTipoInformesPrincial() throws Exception {

    //Ejecutamos la consulta y obtenemos el ResultSet
    SeleccionarTiposInformesVertimiento seleccionar = new SeleccionarTiposInformesVertimiento();
    ResultSet rst = seleccionar.getTipoInformesPrincipal();

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

    while (rst.next()) {
        //Creamos el objecto JSON
        jsonObject.put("descripcion", rst.getString("DESCRIPCION"));
        jsonObject.put("codigo", rst.getString("CODIGO"));

        //Creamos el Array JSON
        jsonArray.add(jsonObject.clone());

    }
    jsonArreglo.add(jsonArray);

    seleccionar.desconectar();
    return jsonArreglo;

}