List of usage examples for org.json.simple JSONObject clone
@HotSpotIntrinsicCandidate protected native Object clone() throws CloneNotSupportedException;
From source file:modelo.ProcesoVertimientosManagers.ProgramarMonitoreo.java
public JSONArray getMonitoreo(int codigo) throws SQLException { //Ejecutamos la consulta y obtenemos el ResultSet SeleccionarMonitoreos select = new SeleccionarMonitoreos(); ResultSet rset = select.getMonitoreo(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("fechaMonitoreo", rset.getString("FECHA_MONITOREO")); jsonObject.put("horaInicial", rset.getString("HORA_INICIAL")); jsonObject.put("horaFinal", rset.getString("HORA_FINAL")); jsonObject.put("consultor", rset.getString("FK_CONSULTOR")); jsonObject.put("laboratorio", rset.getString("FK_LABORATORIO")); jsonObject.put("observacion", rset.getString("MOTIVO_REPROGRAMACION")); jsonObject.put("tecnicoSup", rset.getString("FK_TECNICO_SUPERVISION")); jsonObject.put("observacionSup", rset.getString("OBSERVACION_SUPERVISION")); jsonObject.put("estuvoSup", rset.getString("ESTUVO_MONITOREO")); jsonObject.put("duracion", rset.getString("DURACION_MONITOREO")); //Guardamos el JSONObject en el JSONArray y lo enviamos a la vista. jsonArray.add(jsonObject.clone()); }//from ww w .ja va 2 s . com jsonArreglo.add(jsonArray); select.desconectar(); return jsonArreglo; }
From source file:modelo.ProcesoVertimientosManagers.Visitas.java
public JSONArray getVisitasPendientes(String filaInicio, String filaFin, String codigoProceso, String contrato, String nit, String razonSocial, String comuna, String direccion) throws SQLException { JSONArray jsonArray = new JSONArray(); JSONArray jsonArreglo = new JSONArray(); JSONObject jsonObject = new JSONObject(); ResultSet rset;// w ww . j a va 2 s .c o m SeleccionarVisitas select = new SeleccionarVisitas(filaInicio, filaFin, codigoProceso, contrato, nit, razonSocial, comuna, direccion); rset = select.getVisitasPendientes(); while (rset.next()) { jsonObject.put("codigoProceso", rset.getString("CODPROCESO")); jsonObject.put("contrato", rset.getString("CONTRATO")); jsonObject.put("nit", rset.getString("NIT")); jsonObject.put("razon_social", rset.getString("RAZON_SOCIAL")); jsonObject.put("comuna", rset.getString("COMUNA")); jsonObject.put("direccion", rset.getString("DIRECCION")); jsonArray.add(jsonObject.clone()); } jsonArreglo.add(jsonArray); //Se cierra el ResultSet select.desconectar(); return jsonArreglo; }
From source file:modelo.ProcesoVertimientosManagers.InformacionGeneral.java
public JSONArray getInformacionGeneral(int codigoProceso) throws SQLException { JSONArray jsonArreglo = new JSONArray(); JSONArray jsonArray = new JSONArray(); JSONObject jsonObject = new JSONObject(); ResultSet rset;/* w w w. jav a 2 s .com*/ SeleccionarInformacionGeneral select = new SeleccionarInformacionGeneral(); rset = select.getInformacionGeneral(codigoProceso); while (rset.next()) { jsonObject.put("codigoProceso", rset.getString("COD_PROCESO")); jsonObject.put("informo", rset.getString("INFORMA_MONITOREO")); jsonObject.put("tipoInforme", rset.getString("FK_TIPO_INFORME")); jsonObject.put("requiereVisita", rset.getString("REQUIERE_VISITA")); jsonObject.put("personaContacto", rset.getString("CONTACTO")); jsonObject.put("asunto", rset.getString("ASUNTO")); jsonObject.put("tipoContacto", rset.getString("FK_TIPO_CONTACTO")); jsonObject.put("razonSocial", rset.getString("RAZON_SOCIAL")); jsonObject.put("nit", rset.getString("NIT")); jsonObject.put("contrato", rset.getString("CONTRATO")); jsonObject.put("codigoAsesoria", rset.getString("COD_ASESORIA")); jsonObject.put("fechaAsesoria", rset.getString("FECHA_ASESORIA")); jsonObject.put("estadoProceso", rset.getString("ESTADO_PROCESO")); jsonObject.put("codigoCliente", rset.getString("COD_CLI")); jsonArray.add(jsonObject.clone()); } jsonArreglo.add(jsonArray); //Se cierra el ResultSet select.desconectar(); return jsonArreglo; }
From source file:modelo.ProcesoVertimientosManagers.Visitas.java
public JSONArray getVisitasPorProceso(String codigoProceso) throws SQLException { JSONArray jsonArray = new JSONArray(); JSONArray jsonArreglo = new JSONArray(); JSONObject jsonObject = new JSONObject(); ResultSet rset;//from www .ja v a2s .com SeleccionarVisitas select = new SeleccionarVisitas(); rset = select.getVisita(codigoProceso); while (rset.next()) { jsonObject.put("codigo", rset.getString("CODIGO")); jsonObject.put("nombre", rset.getString("NOMBRES")); jsonObject.put("apellidos", rset.getString("APELLIDOS")); jsonObject.put("fecha_visita", rset.getString("FECHA_VISITA")); jsonObject.put("motivo", rset.getString("MOVITO")); jsonObject.put("tipovisita", rset.getString("TIPOVISITA")); jsonObject.put("estado", rset.getString("ESTADO")); jsonObject.put("total", rset.getString("total_rows")); jsonObject.put("resultado", rset.getString("Resultado")); jsonArray.add(jsonObject.clone()); } jsonArreglo.add(jsonArray); //Se cierra el ResultSet select.desconectar(); return jsonArreglo; }
From source file:modelo.ProcesoVertimientosManagers.ProgramarMonitoreo.java
/** * * @param filaInicio//from w ww .j a va2 s .c om * @param filaFin * @param fechaInicial * @param fechaFinal * @param codigoProceso * @param contrato * @param nit * @param comuna * @param razonSocial * @param direccion * @param estado * @param codigoMonitoreo * @return * @throws java.lang.Exception */ public JSONArray getMonitoreosAdmon(String filaInicio, String filaFin, String fechaInicial, String fechaFinal, String codigoProceso, String contrato, String nit, String razonSocial, String comuna, String direccion, String estado, String codigoMonitoreo) throws Exception { //Creamos los JSONArray para guardar los objetos JSON JSONArray jsonArray = new JSONArray(); JSONArray jsonArreglo = new JSONArray(); //Ejecutamos la consulta y obtenemos el ResultSet SeleccionarMonitoreos select = new SeleccionarMonitoreos(); ResultSet rset = select.getMonitoreosAdmon(filaInicio, filaFin, fechaInicial, fechaFinal, codigoProceso, contrato, nit, razonSocial, comuna, direccion, estado, codigoMonitoreo); //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("procesoVertimiento", rset.getString("FK_PROCESO_VERTIMIENTO")); jsonObject.put("fechaMonitoreo", rset.getString("FECHA_MONITOREO")); jsonObject.put("horaInicial", rset.getString("HORA_INICIAL")); jsonObject.put("horaFinal", rset.getString("HORA_FINAL")); jsonObject.put("consultor", rset.getString("CONSULTOR")); jsonObject.put("laboratorio", rset.getString("LABORATORIO")); jsonObject.put("tecnicoSup", rset.getString("TECNICO")); jsonObject.put("observSup", rset.getString("OBSERVACION_SUPERVISION")); jsonObject.put("razonSocial", rset.getString("RAZON_SOCIAL")); jsonObject.put("nit", rset.getString("NIT")); jsonObject.put("estado", rset.getString("ESTADO")); jsonObject.put("estadoSup", rset.getString("ESTADOBQ")); jsonObject.put("contrato", rset.getString("FK_CONTRATO")); jsonObject.put("estuvo", rset.getString("ESTUVO_MONITOREO")); //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.ProcesoVertimientosManagers.Visitas.java
public JSONArray getVisitasPorProceso(String filaInicio, String filaFin, String tipoVisita, String fechaInicial, String fechaFinal, String codigoProceso, String estadoVisita, String contrato, String nit, String razonSocial, String motivoVisita) throws SQLException { JSONArray jsonArray = new JSONArray(); JSONArray jsonArreglo = new JSONArray(); JSONObject jsonObject = new JSONObject(); ResultSet rset;/*from ww w . j a va 2 s . co m*/ SeleccionarVisitas select = new SeleccionarVisitas(filaInicio, filaFin, tipoVisita, fechaInicial, fechaFinal, codigoProceso, estadoVisita, contrato, nit, razonSocial, motivoVisita); rset = select.getVisitas(); while (rset.next()) { jsonObject.put("codigo", rset.getString("CODIGO")); jsonObject.put("nombre", rset.getString("NOMBRES")); jsonObject.put("apellidos", rset.getString("APELLIDOS")); jsonObject.put("fecha_visita", rset.getString("FECHA_VISITA")); jsonObject.put("motivo", rset.getString("MOVITO")); jsonObject.put("tipovisita", rset.getString("TIPOVISITA")); jsonObject.put("estado", rset.getString("ESTADO")); jsonObject.put("total", rset.getString("total_rows")); jsonObject.put("resultado", rset.getString("Resultado")); jsonObject.put("contrato", rset.getString("CONTRATO")); jsonObject.put("razon_social", rset.getString("RAZON_SOCIAL")); jsonObject.put("codigoProceso", rset.getString("CODPROCESO")); jsonObject.put("tecnicoVisito", rset.getString("TECNICO_VISITO")); jsonArray.add(jsonObject.clone()); } jsonArreglo.add(jsonArray); //Se cierra el ResultSet select.desconectar(); return jsonArreglo; }
From source file:org.jasig.ssp.reference.SelfHelpGuideIT.java
@Test @ApiAuthentication(mode = "auth") public void testSelfHelpGuideReferenceSupportedMethodsPositive() { final JSONObject testPostPutPositive = (JSONObject) SELF_HELP_GUIDE_SSC.clone(); testPostPutPositive.put("name", "testPostPositive"); int checkResultCount = -2; //get all (store results to check at the end) Response checkItemCount = expect().statusCode(200).log().ifError().contentType("application/json").when() .get(SELF_HELP_GUIDE_PATH);/*from w w w . j av a 2 s . co m*/ String result = checkItemCount.getBody().jsonPath().getJsonObject("results").toString(); if (StringUtils.isNotBlank(result)) { checkResultCount = Integer.parseInt(result); } else { LOGGER.error("Get all method failed at beginning of Positive Test! No results returned."); fail("GET all failed."); } //get /id expect().statusCode(200).log().ifError().contentType("application/json").when() .get(SELF_HELP_GUIDE_PATH + "/" + SELF_HELP_GUIDE_QSGC.get("id").toString()); testPostPutPositive.remove("id"); final JSONObject testPostPutPositiveFull = (JSONObject) testPostPutPositive.clone(); testPostPutPositiveFull.put("threshold", 0); testPostPutPositiveFull.put("introductoryText", "testIntroText"); testPostPutPositiveFull.put("summaryText", "testSumText"); testPostPutPositiveFull.put("summaryTextEarlyAlert", "testEarlyAlertText"); testPostPutPositiveFull.put("summaryTextThreshold", "testThresholdText"); testPostPutPositiveFull.put("authenticationRequired", false); testPostPutPositiveFull.put("active", true); //TODO Note: Uses SelfHelpGuideAdminController for post as SelfHelpGuide reference post was not working,(DB Error returned) //post Response postResponse = expect().statusCode(200).log().ifError().given().contentType("application/json") .body(testPostPutPositiveFull).when().post("selfHelpGuides/search"); final String postContentUUID = postResponse.getBody().jsonPath().getJsonObject("id").toString(); //get more complete data from post using get (MSSQL version is not reliable without this extra get) postResponse = expect().statusCode(200).log().ifError().contentType("application/json").when() .get(SELF_HELP_GUIDE_PATH + "/" + postContentUUID); final Map parsedPostResponse = postResponse.getBody().jsonPath().getJsonObject(""); testPostPutPositive.put("id", postContentUUID); testPostPutPositive.put("createdBy", getCurrentLoginCreatedModifiedBy()); testPostPutPositive.put("modifiedBy", getCurrentLoginCreatedModifiedBy()); testPostPutPositive.put("createdDate", parsedPostResponse.get("createdDate")); testPostPutPositive.put("modifiedDate", parsedPostResponse.get("modifiedDate")); //verify post worked expect().statusCode(200).log().ifError().contentType("application/json") .body("", equalTo(testPostPutPositive)).when().get(SELF_HELP_GUIDE_PATH + "/" + postContentUUID); testPostPutPositive.remove("id"); testPostPutPositive.put("name", ("testReferencePut" + testPassDeConflictNumber)); //put expect().statusCode(200).log().ifError().given().contentType("application/json").body(testPostPutPositive) .when().put(SELF_HELP_GUIDE_PATH + "/" + postContentUUID); //get more complete data from put using get final Response putResponse = expect().statusCode(200).log().ifError().contentType("application/json").when() .get(SELF_HELP_GUIDE_PATH + "/" + postContentUUID); testPostPutPositive.put("id", postContentUUID); testPostPutPositive.put("modifiedDate", putResponse.getBody().jsonPath().getJsonObject("modifiedDate")); //verify put worked expect().statusCode(200).log().ifError().contentType("application/json") .body("", equalTo(testPostPutPositive)).when().get(SELF_HELP_GUIDE_PATH + "/" + postContentUUID); //delete expect().statusCode(200).log().ifError().when().delete(SELF_HELP_GUIDE_PATH + "/" + postContentUUID); testPostPutPositive.put("objectStatus", "INACTIVE"); //get verify delete worked final Response deleteCheckResponse = expect().statusCode(200).log().ifError() .contentType("application/json").when().get(SELF_HELP_GUIDE_PATH + "/" + postContentUUID); testPostPutPositive.put("modifiedDate", deleteCheckResponse.getBody().jsonPath().getJsonObject("modifiedDate")); //verify delete is still intact but inactive expect().statusCode(200).log().ifError().contentType("application/json") .body("", equalTo(testPostPutPositive)).when().get(SELF_HELP_GUIDE_PATH + "/" + postContentUUID); //get (verify result # matches expected active) expect().statusCode(200).log().ifError().contentType("application/json") .body("results", equalTo(checkResultCount)).given().queryParam("status", "ACTIVE").when() .get(SELF_HELP_GUIDE_PATH); //get (verify result # matches expected inactive) expect().statusCode(200).log().ifError().contentType("application/json").body("results", equalTo(1)).given() .queryParam("status", "INACTIVE").when().get(SELF_HELP_GUIDE_PATH); }
From source file:org.wso2.identity.integration.test.oauth2.dcrm.api.OAuthDCRMTestCase.java
@Test(alwaysRun = true, groups = "wso2.is", priority = 1, description = "Check whether created service providers " + "are cleaned up when OAuth app creation fails.") public void testRollbackOnInvalidRequest() throws IOException { // Basic Request JSONArray grantTypes = new JSONArray(); grantTypes.add(OAuthDCRMConstants.GRANT_TYPE_AUTHORIZATION_CODE); JSONObject requestBody = new JSONObject(); requestBody.put(OAuthDCRMConstants.CLIENT_NAME, DUMMY_DCR_APP); requestBody.put(OAuthDCRMConstants.GRANT_TYPES, grantTypes); //////////////////////// BAD REQUEST WITH EMPTY REDIRECT URI /////////////////////////// HttpPost badRequestWithoutRedirectUris = new HttpPost(getPath()); setRequestHeaders(badRequestWithoutRedirectUris); // We keep the redirect uris empty to make this a bad request. JSONObject badRequestBody = (JSONObject) requestBody.clone(); badRequestBody.put(OAuthDCRMConstants.REDIRECT_URIS, new JSONArray()); badRequestWithoutRedirectUris.setEntity(new StringEntity(badRequestBody.toJSONString())); HttpResponse failedResponse = client.execute(badRequestWithoutRedirectUris); assertEquals(failedResponse.getStatusLine().getStatusCode(), 400, "Since this was a BAD request should have " + "received an error response with 400 status code."); EntityUtils.consume(failedResponse.getEntity()); ///////////////// VALID REQUEST WITH THE SAME CLIENT_NAME /////////////////////////// HttpPost validRequest = new HttpPost(getPath()); setRequestHeaders(validRequest);// www .j a v a 2 s. c o m JSONArray redirectURIs = new JSONArray(); redirectURIs.add(OAuthDCRMConstants.REDIRECT_URI); // Add a valid Redirect URI JSONObject validJSONBody = (JSONObject) requestBody.clone(); validJSONBody.put(OAuthDCRMConstants.REDIRECT_URIS, redirectURIs); validRequest.setEntity(new StringEntity(validJSONBody.toJSONString())); HttpResponse successResponse = client.execute(validRequest); assertEquals(successResponse.getStatusLine().getStatusCode(), 201, "Service Provider should have been created " + "with the same client name: " + DUMMY_DCR_APP + " attempted in the previous failed request."); BufferedReader rd = new BufferedReader(new InputStreamReader(successResponse.getEntity().getContent())); Object responseObj = JSONValue.parse(rd); EntityUtils.consume(successResponse.getEntity()); client_id = ((JSONObject) responseObj).get("client_id").toString(); assertNotNull(client_id, "client_id cannot be null"); }
From source file:org.wwscc.storage.AttrBase.java
public AttrBase(JSONObject o) { attr = (JSONObject) o.clone(); }