Commit c343daa3 by Denys Tito Urbano

[CREATE] Endpoint de actualizar informe vacacional

parent bb31baa7
......@@ -12,6 +12,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.json.JSONException;
import org.postgresql.util.PSQLException;
@Provider
@Path("excel")
......@@ -578,4 +579,39 @@ public class ExcelApi {
}
}
@POST
@Path("vacacional/informe")
@Produces("application/json")
@Consumes("application/json")
public Response informeVacacionalActualizar(String json) {
JSONObject salida = new JSONObject();
try {
JSONObject entrada = new JSONObject(json);
salida = new ExcelServices().informeVacacionalActualizar(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 {
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
......@@ -54,4 +54,6 @@ public interface ExcelDAO{
JSONObject procedure (JSONObject entrada) throws Exception;
public JSONObject informeVacacionalActualizar(JSONObject entrada) throws Exception;
}
\ No newline at end of file
......@@ -766,4 +766,12 @@ public class PostgreSqlExcel implements ExcelDAO {
JSONObject json = new JSONObject(response.getString("json"));
return json;
}
@Override
public JSONObject informeVacacionalActualizar(JSONObject body) throws Exception {
String sql = "SELECT * FROM matricula.func_informe_vacacional_actualizar ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? );";
JSONObject data = PostgreSqlFactoryDAO.queryPSSingle("siiaa", sql, body.getJSONArray("params"));
return new JSONObject(data.getString("json"));
}
}
\ No newline at end of file
......@@ -562,5 +562,117 @@ public class ExcelServices {
public JSONObject procedure (JSONObject json) throws Exception{
return dao.procedure(json);
}
public JSONObject informeVacacionalActualizar(JSONObject entrada) throws JSONException, Exception {
JSONArray params = new JSONArray();
params.put(1, entrada.getString("tipo_operacion"));
if (!entrada.isNull("informe_id")) {
params.put(2, entrada.getInt("informe_id"));
}
if (!entrada.isNull("persona_id")) {
params.put(3, entrada.getInt("persona_id"));
}
if (!entrada.isNull("parentesco_id")) {
params.put(4, entrada.getInt("parentesco_id"));
}
if (!entrada.isNull("contacto_telefono")) {
params.put(5, entrada.getString("contacto_telefono"));
}
if (!entrada.isNull("contacto_correo")) {
params.put(6, entrada.getString("contacto_correo"));
}
if (!entrada.isNull("ubigeo_id")) {
params.put(7, entrada.getInt("ubigeo_id"));
}
if (!entrada.isNull("ubigeo_nombre")) {
params.put(8, entrada.getString("ubigeo_nombre"));
}
if (!entrada.isNull("medio_difusion_id")) {
params.put(9, entrada.getInt("medio_difusion_id"));
}
if (!entrada.isNull("medio_atencion_id")) {
params.put(10, entrada.getInt("medio_atencion_id"));
}
if (!entrada.isNull("apertura_id")) {
params.put(11, entrada.getInt("apertura_id"));
}
if (!entrada.isNull("origen_id")) {
params.put(12, entrada.getInt("origen_id"));
}
if (!entrada.isNull("fecha_registro")) {
params.put(13, entrada.getString("fecha_registro"));
}
if (!entrada.isNull("estado_id")) {
params.put(14, entrada.getInt("estado_id"));
}
if (!entrada.isNull("colegio_procedencia_nombre")) {
params.put(15, entrada.getString("colegio_procedencia_nombre"));
}
if (!entrada.isNull("drive_origen")) {
params.put(16, entrada.getString("drive_origen"));
}
if (!entrada.isNull("drive_fila")) {
params.put(17, entrada.getInt("drive_fila"));
}
if (!entrada.isNull("informe_observacion")) {
params.put(18, entrada.getString("informe_observacion"));
}
if (!entrada.isNull("tipo_documento_id")) {
params.put(19, entrada.getInt("tipo_documento_id"));
}
if (!entrada.isNull("numero_documento_identidad")) {
params.put(20, entrada.getString("numero_documento_identidad"));
}
if (!entrada.isNull("nombres")) {
params.put(21, entrada.getString("nombres"));
}
if (!entrada.isNull("apellido_paterno")) {
params.put(22, entrada.getString("apellido_paterno"));
}
if (!entrada.isNull("apellido_materno")) {
params.put(23, entrada.getString("apellido_materno"));
}
if (!entrada.isNull("sede_id")) {
params.put(24, entrada.getInt("sede_id"));
}
if (!entrada.isNull("sede_nombre")) {
params.put(25, entrada.getString("sede_nombre"));
}
if (!entrada.isNull("grado_nombre")) {
params.put(26, entrada.getString("grado_nombre"));
}
if (!entrada.isNull("matricula_id")) {
params.put(27, entrada.getInt("matricula_id"));
}
return dao.informeVacacionalActualizar(entrada.put("params", 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