Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
trismegisto-mongo-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
trismegisto-mongo-api
Commits
606a4405
Commit
606a4405
authored
Oct 26, 2022
by
Denys Tito Urbano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[CREATE] Api Academia y DAO agregados
parent
b663908b
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
130 additions
and
0 deletions
+130
-0
AcademiaApi.java
...u/sacooliveros/trismegisto/mongo/api/api/AcademiaApi.java
+40
-0
ApplicationConfig.java
...oliveros/trismegisto/mongo/api/api/ApplicationConfig.java
+2
-0
AcademiaDAO.java
...u/sacooliveros/trismegisto/mongo/api/dao/AcademiaDAO.java
+9
-0
DAO.java
...va/pe/edu/sacooliveros/trismegisto/mongo/api/dao/DAO.java
+11
-0
FactoryDAO.java
...du/sacooliveros/trismegisto/mongo/api/dao/FactoryDAO.java
+23
-0
AcademiaMongoDB.java
...ros/trismegisto/mongo/api/mongodbdao/AcademiaMongoDB.java
+16
-0
MongoDBFactoryDAO.java
...s/trismegisto/mongo/api/mongodbdao/MongoDBFactoryDAO.java
+13
-0
AcademiaService.java
...iveros/trismegisto/mongo/api/service/AcademiaService.java
+16
-0
No files found.
src/main/java/pe/edu/sacooliveros/trismegisto/mongo/api/api/AcademiaApi.java
0 → 100644
View file @
606a4405
package
pe
.
edu
.
sacooliveros
.
trismegisto
.
mongo
.
api
.
api
;
import
javax.ws.rs.BadRequestException
;
import
javax.ws.rs.POST
;
import
javax.ws.rs.Path
;
import
javax.ws.rs.Produces
;
import
javax.ws.rs.Consumes
;
import
javax.ws.rs.WebApplicationException
;
import
javax.ws.rs.core.Response
;
import
org.json.JSONObject
;
import
pe.edu.sacooliveros.trismegisto.mongo.api.service.AcademiaService
;
@Path
(
"academia"
)
@Produces
(
"application/json"
)
@Consumes
(
"application/json"
)
public
class
AcademiaApi
{
@POST
@Path
(
"aula"
)
public
Response
aulaCrear
(
String
json
)
{
JSONObject
salida
=
new
JSONObject
();
try
{
JSONObject
entrada
=
new
JSONObject
(
json
);
salida
=
new
AcademiaService
().
aulaCrear
(
entrada
);
return
Response
.
status
(
200
).
entity
(
salida
.
toString
()).
build
();
}
catch
(
Exception
ex
)
{
salida
.
put
(
"status"
,
false
)
.
put
(
"message"
,
ex
.
getMessage
())
.
put
(
"data"
,
JSONObject
.
NULL
);
throw
new
WebApplicationException
(
Response
.
status
(
500
).
entity
(
salida
.
toString
()).
build
());
}
}
}
src/main/java/pe/edu/sacooliveros/trismegisto/mongo/api/api/ApplicationConfig.java
View file @
606a4405
...
@@ -16,6 +16,8 @@ public class ApplicationConfig extends Application {
...
@@ -16,6 +16,8 @@ public class ApplicationConfig extends Application {
corsFilter
.
getAllowedOrigins
().
add
(
"*"
);
corsFilter
.
getAllowedOrigins
().
add
(
"*"
);
corsFilter
.
setAllowedMethods
(
"OPTIONS, GET, POST, DELETE, PUT, PATCH"
);
corsFilter
.
setAllowedMethods
(
"OPTIONS, GET, POST, DELETE, PUT, PATCH"
);
singletons
.
add
(
corsFilter
);
singletons
.
add
(
corsFilter
);
classes
.
add
(
AcademiaApi
.
class
);
}
}
@Override
@Override
...
...
src/main/java/pe/edu/sacooliveros/trismegisto/mongo/api/dao/AcademiaDAO.java
0 → 100644
View file @
606a4405
package
pe
.
edu
.
sacooliveros
.
trismegisto
.
mongo
.
api
.
dao
;
import
org.json.JSONObject
;
public
interface
AcademiaDAO
{
public
JSONObject
aulaCrear
(
JSONObject
entrada
)
throws
Exception
;
}
src/main/java/pe/edu/sacooliveros/trismegisto/mongo/api/dao/DAO.java
0 → 100644
View file @
606a4405
package
pe
.
edu
.
sacooliveros
.
trismegisto
.
mongo
.
api
.
dao
;
import
org.json.JSONObject
;
public
abstract
class
DAO
{
protected
static
JSONObject
query
()
throws
Exception
{
return
new
JSONObject
();
}
}
src/main/java/pe/edu/sacooliveros/trismegisto/mongo/api/dao/FactoryDAO.java
0 → 100644
View file @
606a4405
package
pe
.
edu
.
sacooliveros
.
trismegisto
.
mongo
.
api
.
dao
;
import
pe.edu.sacooliveros.trismegisto.mongo.api.mongodbdao.MongoDBFactoryDAO
;
public
abstract
class
FactoryDAO
extends
DAO
{
public
static
final
int
MONGODB
=
1
;
public
static
final
int
POSTGRESQL
=
2
;
public
static
FactoryDAO
getFactoryDAO
(
int
whichFactory
)
{
switch
(
whichFactory
)
{
case
MONGODB:
return
new
MongoDBFactoryDAO
();
/*case POSTGRESQL:
return new PostgreSqlFactoryDAO();*/
default
:
return
null
;
}
}
public
abstract
AcademiaDAO
getAcademiaDAO
();
}
src/main/java/pe/edu/sacooliveros/trismegisto/mongo/api/mongodbdao/AcademiaMongoDB.java
0 → 100644
View file @
606a4405
package
pe
.
edu
.
sacooliveros
.
trismegisto
.
mongo
.
api
.
mongodbdao
;
import
org.json.JSONObject
;
import
pe.edu.sacooliveros.trismegisto.mongo.api.dao.AcademiaDAO
;
public
class
AcademiaMongoDB
implements
AcademiaDAO
{
@Override
public
JSONObject
aulaCrear
(
JSONObject
entrada
)
throws
Exception
{
return
new
JSONObject
()
.
put
(
"status"
,
true
)
.
put
(
"message"
,
"Éxito"
)
.
put
(
"data"
,
entrada
);
}
}
src/main/java/pe/edu/sacooliveros/trismegisto/mongo/api/mongodbdao/MongoDBFactoryDAO.java
0 → 100644
View file @
606a4405
package
pe
.
edu
.
sacooliveros
.
trismegisto
.
mongo
.
api
.
mongodbdao
;
import
pe.edu.sacooliveros.trismegisto.mongo.api.dao.AcademiaDAO
;
import
pe.edu.sacooliveros.trismegisto.mongo.api.dao.FactoryDAO
;
public
class
MongoDBFactoryDAO
extends
FactoryDAO
{
@Override
public
AcademiaDAO
getAcademiaDAO
()
{
return
new
AcademiaMongoDB
();
}
}
src/main/java/pe/edu/sacooliveros/trismegisto/mongo/api/service/AcademiaService.java
0 → 100644
View file @
606a4405
package
pe
.
edu
.
sacooliveros
.
trismegisto
.
mongo
.
api
.
service
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
pe.edu.sacooliveros.trismegisto.mongo.api.dao.AcademiaDAO
;
import
pe.edu.sacooliveros.trismegisto.mongo.api.dao.FactoryDAO
;
public
class
AcademiaService
{
AcademiaDAO
dao
=
FactoryDAO
.
getFactoryDAO
(
FactoryDAO
.
MONGODB
).
getAcademiaDAO
();
public
JSONObject
aulaCrear
(
JSONObject
entrada
)
throws
JSONException
,
Exception
{
return
dao
.
aulaCrear
(
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