Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
formulario-api
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Denys Tito Urbano
formulario-api
Commits
b6abace7
Commit
b6abace7
authored
May 16, 2023
by
Denys Tito Urbano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ADD] ENDPOINT LISTAR EXAMEN Y ACTUALIZAR EXAMEN
parent
69fd7cb4
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
243 additions
and
3 deletions
+243
-3
ExcelApi.java
src/main/java/pe/so/api/formulario/api/ExcelApi.java
+77
-0
ExcelDAO.java
src/main/java/pe/so/api/formulario/dao/ExcelDAO.java
+7
-0
FactoryDAO.java
src/main/java/pe/so/api/formulario/dao/FactoryDAO.java
+1
-1
CorsFilter.java
src/main/java/pe/so/api/formulario/filters/CorsFilter.java
+10
-2
PostgreSqlExcel.java
...ava/pe/so/api/formulario/postgresdao/PostgreSqlExcel.java
+21
-0
PostgreSqlFactoryDAO.java
...e/so/api/formulario/postgresdao/PostgreSqlFactoryDAO.java
+14
-0
PostgreSqlTabla.java
...ava/pe/so/api/formulario/postgresdao/PostgreSqlTabla.java
+3
-0
ExcelServices.java
...ain/java/pe/so/api/formulario/services/ExcelServices.java
+110
-0
No files found.
src/main/java/pe/so/api/formulario/api/ExcelApi.java
View file @
b6abace7
...
...
@@ -11,6 +11,7 @@ import pe.so.api.formulario.utilities.Commons;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
org.json.JSONException
;
@Provider
@Path
(
"excel"
)
...
...
@@ -225,4 +226,80 @@ public class ExcelApi {
return
Response
.
status
(
200
).
entity
(
MSJ_RESPUESTA
.
toString
()).
build
();
}
@POST
@Path
(
"/examen"
)
public
Response
actualizar_examen_alumno
(
String
json
)
throws
Exception
{
JSONObject
salida
=
new
JSONObject
();
try
{
JSONObject
entrada
=
new
JSONObject
(
json
);
salida
=
new
ExcelServices
().
actualizar_examen_alumno
(
entrada
);
return
Response
.
status
(
200
).
entity
(
salida
.
toString
()).
build
();
}
catch
(
JSONException
ex
)
{
salida
.
put
(
"status"
,
false
);
salida
.
put
(
"message"
,
ex
.
getMessage
());
throw
new
WebApplicationException
(
Response
.
status
(
400
).
entity
(
salida
.
toString
()).
build
());
}
catch
(
BadRequestException
ex
)
{
salida
=
new
JSONObject
(
ex
.
getMessage
());
throw
new
WebApplicationException
(
Response
.
status
(
500
).
entity
(
salida
.
toString
()).
build
());
}
catch
(
Exception
ex
)
{
salida
.
put
(
"status"
,
false
);
salida
.
put
(
"message"
,
ex
.
getMessage
());
throw
new
WebApplicationException
(
Response
.
status
(
500
).
entity
(
salida
.
toString
()).
build
());
}
}
@POST
@Path
(
"/listar_examen"
)
public
Response
listar_examen
(
String
json
)
{
JSONObject
salida
=
new
JSONObject
();
try
{
JSONObject
entrada
=
new
JSONObject
(
json
);
salida
=
new
ExcelServices
().
listar_examen
(
entrada
);
return
Response
.
status
(
200
).
entity
(
salida
.
toString
()).
build
();
}
catch
(
JSONException
ex
)
{
salida
.
put
(
"status"
,
false
);
salida
.
put
(
"message"
,
ex
.
getMessage
());
throw
new
WebApplicationException
(
Response
.
status
(
400
).
entity
(
salida
.
toString
()).
build
());
}
catch
(
BadRequestException
ex
)
{
salida
=
new
JSONObject
(
ex
.
getMessage
());
throw
new
WebApplicationException
(
Response
.
status
(
500
).
entity
(
salida
.
toString
()).
build
());
}
catch
(
Exception
ex
)
{
salida
.
put
(
"status"
,
false
);
salida
.
put
(
"message"
,
ex
.
getMessage
());
throw
new
WebApplicationException
(
Response
.
status
(
500
).
entity
(
salida
.
toString
()).
build
());
}
}
@POST
@Path
(
"/actualizar_examen"
)
public
Response
actualizar_examen
(
String
json
)
throws
Exception
{
JSONObject
salida
=
new
JSONObject
();
try
{
JSONObject
entrada
=
new
JSONObject
(
json
);
salida
=
new
ExcelServices
().
actualizar_examen
(
entrada
);
return
Response
.
status
(
200
).
entity
(
salida
.
toString
()).
build
();
}
catch
(
JSONException
ex
)
{
salida
.
put
(
"status"
,
false
);
salida
.
put
(
"message"
,
ex
.
getMessage
());
throw
new
WebApplicationException
(
Response
.
status
(
400
).
entity
(
salida
.
toString
()).
build
());
}
catch
(
BadRequestException
ex
)
{
salida
=
new
JSONObject
(
ex
.
getMessage
());
throw
new
WebApplicationException
(
Response
.
status
(
500
).
entity
(
salida
.
toString
()).
build
());
}
catch
(
Exception
ex
)
{
salida
.
put
(
"status"
,
false
);
salida
.
put
(
"message"
,
ex
.
getMessage
());
throw
new
WebApplicationException
(
Response
.
status
(
500
).
entity
(
salida
.
toString
()).
build
());
}
}
}
src/main/java/pe/so/api/formulario/dao/ExcelDAO.java
View file @
b6abace7
...
...
@@ -27,4 +27,11 @@ public interface ExcelDAO{
JSONObject
execute_matricula_online2
(
JSONObject
json
)
throws
Exception
;
JSONObject
execute_reporte_pagos
(
JSONObject
entrada
)
throws
Exception
;
JSONObject
actualizar_examen_alumno
(
JSONObject
json
)
throws
Exception
;
JSONObject
listar_examen
(
JSONObject
entrada
)
throws
Exception
;
JSONObject
actualizar_examen
(
JSONObject
entrada
)
throws
Exception
;
}
src/main/java/pe/so/api/formulario/dao/FactoryDAO.java
View file @
b6abace7
...
...
@@ -3,7 +3,7 @@ package pe.so.api.formulario.dao;
import
pe.so.api.formulario.mongodbdao.MongoDBFactoryDAO
;
import
pe.so.api.formulario.postgresdao.PostgreSqlFactoryDAO
;
public
abstract
class
FactoryDAO
{
public
abstract
class
FactoryDAO
extends
DAO
{
public
static
final
int
MONGODB
=
1
;
public
static
final
int
POSTGRESQL
=
2
;
...
...
src/main/java/pe/so/api/formulario/filters/CorsFilter.java
View file @
b6abace7
...
...
@@ -25,7 +25,8 @@ public class CorsFilter implements Filter{
public
void
doFilter
(
ServletRequest
servletRequest
,
ServletResponse
servletResponse
,
FilterChain
filterChain
)
throws
IOException
,
ServletException
{
String
[]
ExcelIds
={
"1ItAa2YGBj60AVghmsCfMJZYooDRQGN2gyPWpgtvGHxA"
,
"1puh5xCtsGwwFaqKSgPcRt5II23MtZ2C9u0C_ussVYyc"
};
"1puh5xCtsGwwFaqKSgPcRt5II23MtZ2C9u0C_ussVYyc"
,
"1ft51jmdtqqMpj51y2EisvwUFlNc8b3IZhOKff2DUScA"
};
HttpServletResponse
response
=(
HttpServletResponse
)
servletResponse
;
HttpServletRequest
request
=(
HttpServletRequest
)
servletRequest
;
...
...
@@ -63,6 +64,7 @@ public class CorsFilter implements Filter{
AtomicReference
<
Boolean
>
existe
=
new
AtomicReference
<>(
false
);
JSONArray
data
=
new
PostgreSqlTabla
().
tablaIds
(
new
JSONObject
().
put
(
"tabla"
,
"ac_encuesta_plc"
)).
getJSONArray
(
"data"
);
JSONArray
data2
=
new
PostgreSqlTabla
().
tablaIds
(
new
JSONObject
().
put
(
"tabla"
,
"ac_balotario"
)).
getJSONArray
(
"data"
);
JSONArray
data3
=
new
PostgreSqlTabla
().
tablaIds
(
new
JSONObject
().
put
(
"tabla"
,
"ac_examen"
)).
getJSONArray
(
"data"
);
data
.
forEach
(
obj
->
{
JSONObject
o
=(
JSONObject
)
obj
;
...
...
@@ -76,7 +78,13 @@ public class CorsFilter implements Filter{
existe
.
set
(
true
);
}
});
data3
.
forEach
(
obj
->
{
JSONObject
o
=(
JSONObject
)
obj
;
if
(
o
.
getString
(
"id"
).
equals
(
id
)){
existe
.
set
(
true
);
}
});
return
existe
.
get
();
}
...
...
src/main/java/pe/so/api/formulario/postgresdao/PostgreSqlExcel.java
View file @
b6abace7
...
...
@@ -653,4 +653,25 @@ public class PostgreSqlExcel implements ExcelDAO {
return
respuesta
;
}
@Override
public
JSONObject
actualizar_examen_alumno
(
JSONObject
entrada
)
throws
Exception
{
String
sql
=
"SELECT * FROM academico.func_examen_procesar_alumno( ?, ?, ?, ?, ?, ?, ?, ? );"
;
JSONObject
data
=
PostgreSqlFactoryDAO
.
queryPSSingle
(
"siiaa"
,
sql
,
entrada
.
getJSONArray
(
"params"
));
return
new
JSONObject
(
data
.
getString
(
"json"
));
}
@Override
public
JSONObject
listar_examen
(
JSONObject
entrada
)
throws
Exception
{
String
sql
=
"SELECT * FROM academico.func_examen_listar ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? );"
;
JSONObject
salida
=
PostgreSqlFactoryDAO
.
queryPSSingle
(
"siiaa"
,
sql
,
entrada
.
getJSONArray
(
"params"
));
return
new
JSONObject
(
salida
.
getString
(
"json"
));
}
@Override
public
JSONObject
actualizar_examen
(
JSONObject
entrada
)
throws
Exception
{
String
sql
=
"SELECT * FROM academico.func_examen_actualizar ( ?, ?, ?, ?, ?, ?, ?, ? :: JSON );"
;
JSONObject
data
=
PostgreSqlFactoryDAO
.
queryPSSingle
(
"siiaa"
,
sql
,
entrada
.
getJSONArray
(
"params"
));
return
new
JSONObject
(
data
.
getString
(
"json"
));
}
}
src/main/java/pe/so/api/formulario/postgresdao/PostgreSqlFactoryDAO.java
View file @
b6abace7
...
...
@@ -9,6 +9,7 @@ import pe.so.api.formulario.utilities.OsUtils;
import
java.sql.Connection
;
import
java.sql.SQLException
;
import
java.sql.DriverManager
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
...
...
@@ -49,6 +50,19 @@ public class PostgreSqlFactoryDAO extends FactoryDAO{
}
return
conexion
;
}
//Store procedure
public
static
JSONArray
queryProcedure
(
String
base
,
String
sql
,
JSONArray
...
parametros
)
throws
Exception
{
return
queryProcedure
(
obtenerConexion
(
base
),
sql
,
false
,
parametros
);
}
public
static
JSONObject
queryPSSingle
(
String
base
,
String
sql
,
JSONArray
...
parametros
)
throws
Exception
{
return
queryPSSingle
(
obtenerConexion
(
base
),
sql
,
false
,
parametros
);
}
public
static
JSONObject
queryJSONObject
(
String
base
,
String
sql
,
JSONObject
data
)
throws
Exception
{
return
queryJSONObject
(
obtenerConexion
(
base
),
sql
,
data
);
}
@Override
public
ExcelDAO
getExcelDAO
(){
...
...
src/main/java/pe/so/api/formulario/postgresdao/PostgreSqlTabla.java
View file @
b6abace7
...
...
@@ -24,6 +24,9 @@ public class PostgreSqlTabla implements TablasDAO{
}
else
if
(
json
.
getString
(
"tabla"
).
equals
(
"ac_balotario"
)){
columnas
=
new
String
[]{
"formulario_titulo"
,
"formulario_respuesta_url"
};
}
else
if
(
json
.
getString
(
"tabla"
).
equals
(
"ac_examen"
)){
columnas
=
new
String
[]{
"formulario_titulo"
,
"formulario_url_respuesta"
};
}
try
{
...
...
src/main/java/pe/so/api/formulario/services/ExcelServices.java
View file @
b6abace7
...
...
@@ -5,6 +5,7 @@ import pe.so.api.formulario.dao.ExcelDAO;
import
pe.so.api.formulario.dao.FactoryDAO
;
import
java.util.Objects
;
import
org.json.JSONArray
;
public
class
ExcelServices
{
...
...
@@ -56,4 +57,113 @@ public class ExcelServices{
public
JSONObject
execute_reporte_pagos
(
JSONObject
entrada
)
throws
Exception
{
return
dao
.
execute_reporte_pagos
(
entrada
);
}
public
JSONObject
actualizar_examen_alumno
(
JSONObject
entrada
)
throws
Exception
{
JSONArray
params
=
new
JSONArray
();
params
.
put
(
0
,
entrada
.
getString
(
"drive_respuesta"
));
params
.
put
(
1
,
entrada
.
getString
(
"fecha_registro"
));
params
.
put
(
2
,
entrada
.
getInt
(
"fila_drive"
));
params
.
put
(
3
,
entrada
.
getString
(
"correo_alumno"
));
params
.
put
(
4
,
entrada
.
getString
(
"nota"
));
params
.
put
(
5
,
entrada
.
getString
(
"apellidos"
));
params
.
put
(
6
,
entrada
.
getString
(
"nombres"
));
params
.
put
(
7
,
entrada
.
getString
(
"sede"
));
entrada
.
put
(
"params"
,
params
);
return
dao
.
actualizar_examen_alumno
(
entrada
);
}
public
JSONObject
listar_examen
(
JSONObject
entrada
)
throws
Exception
{
JSONArray
params
=
new
JSONArray
();
if
(!
entrada
.
isNull
(
"usuario_perfil_id"
))
{
params
.
put
(
0
,
entrada
.
getInt
(
"usuario_perfil_id"
));
}
params
.
put
(
1
,
entrada
.
getString
(
"tipo_operacion"
));
if
(!
entrada
.
isNull
(
"capitulo_id"
))
{
params
.
put
(
2
,
entrada
.
getInt
(
"capitulo_id"
));
}
if
(!
entrada
.
isNull
(
"grado_turno_id"
))
{
params
.
put
(
3
,
entrada
.
getString
(
"grado_turno_id"
));
}
if
(!
entrada
.
isNull
(
"curso_id"
))
{
params
.
put
(
4
,
entrada
.
getInt
(
"curso_id"
));
}
if
(!
entrada
.
isNull
(
"dia"
))
{
params
.
put
(
5
,
entrada
.
getInt
(
"dia"
));
}
if
(!
entrada
.
isNull
(
"estado_id"
))
{
params
.
put
(
6
,
entrada
.
getInt
(
"estado_id"
));
}
if
(!
entrada
.
isNull
(
"enlazado"
))
{
params
.
put
(
7
,
entrada
.
getBoolean
(
"enlazado"
));
}
if
(!
entrada
.
isNull
(
"sede_id"
))
{
params
.
put
(
8
,
entrada
.
getInt
(
"sede_id"
));
}
if
(!
entrada
.
isNull
(
"aula_id"
))
{
params
.
put
(
9
,
entrada
.
getInt
(
"aula_id"
));
}
entrada
.
put
(
"params"
,
params
);
return
dao
.
listar_examen
(
entrada
);
}
public
JSONObject
actualizar_examen
(
JSONObject
entrada
)
throws
Exception
{
JSONArray
params
=
new
JSONArray
();
if
(!
entrada
.
isNull
(
"usuario_perfil_id"
))
{
params
.
put
(
0
,
entrada
.
getInt
(
"usuario_perfil_id"
));
}
params
.
put
(
1
,
entrada
.
getString
(
"tipo_operacion"
));
if
(!
entrada
.
isNull
(
"examen_id"
))
{
params
.
put
(
2
,
entrada
.
getInt
(
"examen_id"
));
}
if
(!
entrada
.
isNull
(
"capitulo_id"
))
{
params
.
put
(
3
,
entrada
.
getInt
(
"capitulo_id"
));
}
if
(!
entrada
.
isNull
(
"url_publicado"
))
{
params
.
put
(
4
,
entrada
.
getString
(
"url_publicado"
));
}
if
(!
entrada
.
isNull
(
"url_edicion"
))
{
params
.
put
(
5
,
entrada
.
getString
(
"url_edicion"
));
}
if
(!
entrada
.
isNull
(
"url_respuesta"
))
{
params
.
put
(
6
,
entrada
.
getString
(
"url_respuesta"
));
}
if
(!
entrada
.
isNull
(
"lista_examen"
))
{
params
.
put
(
7
,
entrada
.
getJSONArray
(
"lista_examen"
));
}
entrada
.
put
(
"params"
,
params
);
return
dao
.
actualizar_examen
(
entrada
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment