[ADD] REGISTRAR ENCUESTA PSICOLOGICA

parent ddb781fe
...@@ -614,4 +614,38 @@ public class ExcelApi { ...@@ -614,4 +614,38 @@ public class ExcelApi {
return Response.status(200).entity(salida.toString()).build(); return Response.status(200).entity(salida.toString()).build();
} }
@POST
@Path("polidocencia/registrar")
@Produces("application/json")
@Consumes("application/json")
public Response registrarEncuestaPsicologica(String json) {
JSONObject salida = new JSONObject();
try {
JSONObject entrada = new JSONObject(json);
salida = new ExcelServices().registrarEncuestaPsicologica(entrada);
} catch (JSONException ex) {
salida
.put("status", false)
.put("message", ex.getMessage());
throw new WebApplicationException(Response.status(400).entity(salida.toString()).build());
} catch (PSQLException ex) {
try {
assert ex.getServerErrorMessage() != null;
salida = new JSONObject(ex.getServerErrorMessage().getMessage());
} catch (JSONException ex2) {
salida
.put("status", false)
.put("message", ex.getMessage());
}
throw new WebApplicationException(Response.status(400).entity(salida.toString()).build());
} catch (Exception ex) {
salida
.put("status", false)
.put("message", ex.getMessage());
throw new WebApplicationException(Response.status(500).entity(salida.toString()).build());
}
return Response.status(200).entity(salida.toString()).build();
}
} }
\ No newline at end of file
package pe.so.api.formulario.dao; package pe.so.api.formulario.dao;
import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
public interface ExcelDAO{ public interface ExcelDAO{
...@@ -54,6 +55,7 @@ public interface ExcelDAO{ ...@@ -54,6 +55,7 @@ public interface ExcelDAO{
JSONObject procedure (JSONObject entrada) throws Exception; JSONObject procedure (JSONObject entrada) throws Exception;
public JSONObject informeVacacionalActualizar(JSONObject entrada) throws Exception; JSONObject informeVacacionalActualizar(JSONObject entrada) throws Exception;
JSONObject registrarEncuestaPsicologica(JSONArray entrada) throws Exception;
} }
\ No newline at end of file
...@@ -756,7 +756,7 @@ public class PostgreSqlExcel implements ExcelDAO { ...@@ -756,7 +756,7 @@ public class PostgreSqlExcel implements ExcelDAO {
errores.put(new JSONObject().put("status",false).put("message",e.getMessage()).put("fila",obj.getInt("fila"))); errores.put(new JSONObject().put("status",false).put("message",e.getMessage()).put("fila",obj.getInt("fila")));
} }
} }
if(errores.length() > 0){ if(!errores.isEmpty()){
return new JSONObject().put("status", false).put("message","se encontrarón errores").put("errors", errores); return new JSONObject().put("status", false).put("message","se encontrarón errores").put("errors", errores);
}else{ }else{
return new JSONObject().put("status",true).put("message","ok"); return new JSONObject().put("status",true).put("message","ok");
...@@ -778,4 +778,11 @@ public class PostgreSqlExcel implements ExcelDAO { ...@@ -778,4 +778,11 @@ public class PostgreSqlExcel implements ExcelDAO {
return new JSONObject(data.getString("json")); return new JSONObject(data.getString("json"));
} }
@Override
public JSONObject registrarEncuestaPsicologica(JSONArray entrada) throws Exception {
String sql = "SELECT * FROM matricula.func_registrar_encuesta_psicologica_excel (?::jsonb);";
JSONObject data = PostgreSqlFactoryDAO.queryPSSingle("siiaa", sql, entrada);
return new JSONObject(data.getString("json"));
}
} }
\ No newline at end of file
...@@ -675,4 +675,10 @@ public class ExcelServices { ...@@ -675,4 +675,10 @@ public class ExcelServices {
return dao.informeVacacionalActualizar(entrada.put("params", params)); return dao.informeVacacionalActualizar(entrada.put("params", params));
} }
public JSONObject registrarEncuestaPsicologica(JSONObject entrada) throws Exception {
JSONArray params=new JSONArray();
params.put(entrada.getJSONObject("json"));
return dao.registrarEncuestaPsicologica(params);
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment