Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
ejercicio2-framework-back
Project
Project
Details
Activity
Releases
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
Josue
ejercicio2-framework-back
Commits
22163f10
Commit
22163f10
authored
Dec 15, 2021
by
Roberto Loayza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Lista de Agentes y eliminación de goal y actions
parent
1b9ba02e
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
42 additions
and
20 deletions
+42
-20
AgentController.java
...n/java/com/bytesw/bytebot/controller/AgentController.java
+13
-0
GoalController.java
...in/java/com/bytesw/bytebot/controller/GoalController.java
+2
-14
GoalForActionController.java
...om/bytesw/bytebot/controller/GoalForActionController.java
+0
-1
AgentRepository.java
...n/java/com/bytesw/bytebot/repository/AgentRepository.java
+1
-0
AgentService.java
src/main/java/com/bytesw/bytebot/service/AgentService.java
+22
-0
GoalForActionService.java
...java/com/bytesw/bytebot/service/GoalForActionService.java
+0
-1
GoalService.java
src/main/java/com/bytesw/bytebot/service/GoalService.java
+4
-4
No files found.
src/main/java/com/bytesw/bytebot/controller/AgentController.java
View file @
22163f10
...
...
@@ -190,4 +190,17 @@ public class AgentController {
}
}
@GetMapping
(
value
=
"/"
)
@PreAuthorize
(
"hasPermission(this, 'view')"
)
public
ResponseEntity
<
String
>
getAgentAll
()
{
HttpStatus
hs
=
HttpStatus
.
OK
;
try
{
return
new
ResponseEntity
<>(
gsonBuilder
.
create
().
toJson
(
agentService
.
getAgentAll
()),
hs
);
}
catch
(
Exception
e
)
{
String
info
=
"Error detectado al obtener informacion"
;
hs
=
HttpStatus
.
INTERNAL_SERVER_ERROR
;
return
new
ResponseEntity
<>(
gsonBuilder
.
create
().
toJson
(
info
),
hs
);
}
}
}
src/main/java/com/bytesw/bytebot/controller/GoalController.java
View file @
22163f10
...
...
@@ -7,7 +7,6 @@ import com.bytesw.xdf.controller.XDFController;
import
com.google.gson.GsonBuilder
;
import
io.swagger.annotations.ApiParam
;
import
lombok.extern.log4j.Log4j2
;
import
org.apache.commons.lang.exception.ExceptionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
...
...
@@ -38,19 +37,7 @@ public class GoalController extends XDFController<GoalBean, Long> {
return
new
ResponseEntity
(
gson
.
toJson
(
info
),
HttpStatus
.
OK
);
}
@DeleteMapping
(
value
=
"/goalForAction/{id}"
)
@PreAuthorize
(
"hasPermission(this, 'view')"
)
public
ResponseEntity
<
String
>
GoalForAction
(
@ApiParam
(
value
=
"id"
,
required
=
true
)
@PathVariable
(
"id"
)
Long
id
)
{
String
info
=
""
;
try
{
goalService
.
deleteGoalForAction
(
id
);
info
=
id
.
toString
();
return
new
ResponseEntity
(
gson
.
toJson
(
info
),
HttpStatus
.
OK
);
}
catch
(
Exception
e
)
{
info
=
e
.
getMessage
();
}
return
new
ResponseEntity
(
gson
.
toJson
(
info
),
HttpStatus
.
INTERNAL_SERVER_ERROR
);
}
@PutMapping
(
value
=
"/goalForAction/{id}"
)
@PreAuthorize
(
"hasPermission(this, 'edit')"
)
...
...
@@ -92,4 +79,5 @@ public class GoalController extends XDFController<GoalBean, Long> {
return
new
ResponseEntity
<>(
gsonBuilder
.
create
().
toJson
(
info
),
hs
);
}
}
}
src/main/java/com/bytesw/bytebot/controller/GoalForActionController.java
View file @
22163f10
...
...
@@ -16,5 +16,4 @@ public class GoalForActionController extends XDFController<GoalForActionsBean, L
public
GoalForActionController
(
GoalForActionService
service
)
{
super
(
service
);
}
}
src/main/java/com/bytesw/bytebot/repository/AgentRepository.java
View file @
22163f10
...
...
@@ -21,4 +21,5 @@ import java.util.List;
public
interface
AgentRepository
extends
CrudRepository
<
Agent
,
Long
>,
JpaSpecificationExecutor
<
Agent
>
{
List
<
Agent
>
findByStatus
(
AgentStatusEnum
status
);
}
src/main/java/com/bytesw/bytebot/service/AgentService.java
View file @
22163f10
...
...
@@ -6,6 +6,7 @@ import com.bytesw.bytebot.jdbc.AgentJDBCRepository;
import
com.bytesw.bytebot.model.enums.*
;
import
com.bytesw.bytebot.repository.*
;
import
com.bytesw.xdf.config.AppContextManager
;
import
com.bytesw.xdf.exception.NotFoundException
;
import
com.bytesw.xdf.sql.beans.Pagination
;
import
lombok.extern.log4j.Log4j2
;
import
org.apache.camel.ProducerTemplate
;
...
...
@@ -507,4 +508,25 @@ public class AgentService extends CustomPaginationService<Agent> {
}
}
public
List
<
Map
>
getAgentAll
()
{
List
<
Agent
>
lista
=
(
List
<
Agent
>)
agentRepository
.
findAll
();
if
(
lista
.
size
()
<=
0
)
{
throw
new
NotFoundException
(
"Error al listar agentes."
);
}
List
<
Map
>
result
=
new
ArrayList
<>();
for
(
Agent
agent:
lista
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"id"
,
agent
.
getId
());
map
.
put
(
"name"
,
agent
.
getName
());
map
.
put
(
"description"
,
agent
.
getDescription
());
map
.
put
(
"version"
,
agent
.
getVersion
());
map
.
put
(
"status"
,
agent
.
getStatus
().
getName
());
map
.
put
(
"period"
,
agent
.
getPeriod
());
map
.
put
(
"timezone"
,
agent
.
getTimezone
());
result
.
add
(
map
);
}
return
result
;
}
}
src/main/java/com/bytesw/bytebot/service/GoalForActionService.java
View file @
22163f10
package
com
.
bytesw
.
bytebot
.
service
;
import
com.bytesw.bytebot.etl.beans.ActionBean
;
import
com.bytesw.bytebot.etl.beans.GoalForActionsBean
;
import
com.bytesw.bytebot.etl.dao.ActionRepository
;
import
com.bytesw.bytebot.etl.model.Action
;
...
...
src/main/java/com/bytesw/bytebot/service/GoalService.java
View file @
22163f10
package
com
.
bytesw
.
bytebot
.
service
;
import
com.bytesw.bytebot.etl.beans.GoalBean
;
import
com.bytesw.bytebot.etl.model.Goal
;
import
com.bytesw.bytebot.etl.model.GoalForActions
;
import
com.bytesw.bytebot.repository.*
;
import
com.bytesw.xdf.exception.AlreadyExistsException
;
import
com.bytesw.xdf.exception.NotFoundException
;
...
...
@@ -84,12 +84,11 @@ public class GoalService extends XDFService<Goal, GoalBean, Long> {
}
@Transactional
(
propagation
=
Propagation
.
REQUIRED
)
public
void
deleteGoalForAction
(
Long
goalId
)
{
@Override
public
void
delete
(
Long
goalId
)
{
if
(!
goalRepository
.
existsById
(
goalId
)){
throw
new
NotFoundException
(
"Goal no registrado."
);
}
goalForActionService
.
deleteGoalForAction
(
goalId
);
goalRepository
.
deleteById
(
goalId
);
}
...
...
@@ -148,4 +147,5 @@ public class GoalService extends XDFService<Goal, GoalBean, Long> {
}
return
result
;
}
}
\ No newline at end of file
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