Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Genesys Backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
44
Issues
44
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Genesys PGR
Genesys Backend
Commits
c8e1f777
Commit
c8e1f777
authored
Jan 07, 2019
by
Matija Obreza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed /api/v1/kpi/observations listing
parent
cd2959eb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
14 deletions
+21
-14
src/main/java/org/genesys2/server/api/v1/KPIReadController.java
...in/java/org/genesys2/server/api/v1/KPIReadController.java
+8
-9
src/main/java/org/genesys2/server/service/KPIService.java
src/main/java/org/genesys2/server/service/KPIService.java
+1
-0
src/main/java/org/genesys2/server/service/impl/KPIServiceImpl.java
...java/org/genesys2/server/service/impl/KPIServiceImpl.java
+11
-4
src/test/java/org/genesys/test/server/api/v1/KPIReadControllerTest.java
...org/genesys/test/server/api/v1/KPIReadControllerTest.java
+1
-1
No files found.
src/main/java/org/genesys2/server/api/v1/KPIReadController.java
View file @
c8e1f777
...
...
@@ -17,19 +17,15 @@
package
org.genesys2.server.api.v1
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
org.genesys2.server.api.Pagination
;
import
org.genesys2.server.model.kpi.Execution
;
import
org.genesys2.server.model.kpi.Observation
;
import
org.genesys2.server.service.KPIService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageImpl
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.GetMapping
;
...
...
@@ -61,11 +57,14 @@ public class KPIReadController {
@Autowired
private
ObjectMapper
objectMapper
;
/**
* List names of executions for which observations are available
*
* @return the list of execution names
*/
@GetMapping
(
value
=
"/observations"
)
public
Page
<
String
>
listExecutions
(
final
Pagination
page
)
{
Pageable
pagination
=
page
.
toPageRequest
(
100
,
Sort
.
Direction
.
ASC
,
"name"
);
Page
<
Execution
>
executions
=
kpiService
.
listExecutions
(
pagination
);
return
new
PageImpl
<
String
>(
executions
.
getContent
().
stream
().
filter
(
exec
->
exec
!=
null
).
map
(
exec
->
exec
.
getName
()).
collect
(
Collectors
.
toList
()),
pagination
,
executions
.
getTotalElements
());
public
List
<
String
>
listExecutions
()
{
return
kpiService
.
listExecutions
().
stream
().
map
(
ex
->
ex
.
getName
()).
collect
(
Collectors
.
toList
());
}
@PostMapping
(
value
=
"/observations/{executionName}"
)
...
...
src/main/java/org/genesys2/server/service/KPIService.java
View file @
c8e1f777
...
...
@@ -68,6 +68,7 @@ public interface KPIService {
Page
<
Dimension
<?>>
listDimensions
(
Pageable
page
);
Page
<
Execution
>
listExecutions
(
Pageable
page
);
List
<
Execution
>
listExecutions
();
Page
<
Observation
>
listObservations
(
ExecutionRun
executionRun
,
Map
<
String
,
String
>
dimensionFilters
,
Pageable
page
);
...
...
src/main/java/org/genesys2/server/service/impl/KPIServiceImpl.java
View file @
c8e1f777
...
...
@@ -65,6 +65,7 @@ import org.springframework.data.domain.PageImpl;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.security.access.prepost.PostAuthorize
;
import
org.springframework.security.access.prepost.PostFilter
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.acls.domain.BasePermission
;
import
org.springframework.stereotype.Service
;
...
...
@@ -101,13 +102,13 @@ public class KPIServiceImpl implements KPIService {
@Autowired
private
ExecutionRunRepository
executionRunRepository
;
/** The securityUtils. */
@Autowired
private
SecurityUtils
securityUtils
;
@Autowired
private
JPAQueryFactory
jpaQueryFactory
;
@Autowired
private
SecurityUtils
securityUtils
;
@PreAuthorize
(
"hasRole('ADMINISTRATOR') or hasPermission(#parameter, 'ADMINISTRATION')"
)
@Override
@Transactional
...
...
@@ -216,6 +217,12 @@ public class KPIServiceImpl implements KPIService {
return
lazyLoad
(
executionRepository
.
save
(
target
));
}
@Override
@PostFilter
(
"hasRole('ADMINISTRATOR') or hasPermission(filterObject, 'READ')"
)
public
List
<
Execution
>
listExecutions
()
{
return
executionRepository
.
findAll
();
}
@Override
public
Page
<
Execution
>
listExecutions
(
Pageable
page
)
{
if
(
securityUtils
.
hasRole
(
UserRole
.
ADMINISTRATOR
))
{
...
...
src/test/java/org/genesys/test/server/api/v1/KPIReadControllerTest.java
View file @
c8e1f777
...
...
@@ -132,7 +132,7 @@ public class KPIReadControllerTest extends AbstractApiTest {
// .andDo(MockMvcResultHandlers.print())
.
andExpect
(
status
().
isOk
())
.
andExpect
(
content
().
contentType
(
MediaType
.
APPLICATION_JSON_UTF8
))
.
andExpect
(
jsonPath
(
"$
.content
"
,
hasSize
(
1
)));
.
andExpect
(
jsonPath
(
"$"
,
hasSize
(
1
)));
}
@Test
...
...
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