Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Samuel Kulíšek
pa165-secret-service-archive
Commits
5ee39d5d
Commit
5ee39d5d
authored
May 16, 2022
by
Jiri Novotny
Browse files
Finish facade upgrade
parent
b4859414
Pipeline
#140289
passed with stage
in 1 minute and 33 seconds
Changes
9
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
ssa-api/src/main/java/cz/muni/fi/pa165/facade/AgentFacade.java
View file @
5ee39d5d
...
...
@@ -6,6 +6,8 @@ import cz.muni.fi.pa165.dto.AgentListDto;
import
cz.muni.fi.pa165.dto.SkillDto
;
import
org.springframework.data.domain.Page
;
import
java.util.List
;
public
interface
AgentFacade
{
Page
<
AgentListDto
>
getMissionAgents
(
Long
missionId
,
int
page
,
int
pageSize
);
AgentDetailDto
getAgent
(
Long
agentId
);
...
...
@@ -14,4 +16,5 @@ public interface AgentFacade {
Page
<
AgentListDto
>
getAgentWithCountryXp
(
Long
countryId
,
int
page
,
int
pageSize
);
Page
<
AgentListDto
>
getAllAgents
(
int
page
,
int
pageSize
);
Page
<
SkillDto
>
getAllSkills
(
int
page
,
int
pageSize
);
List
<
SkillDto
>
getAllSkills
();
}
ssa-api/src/main/java/cz/muni/fi/pa165/facade/CountryFacade.java
View file @
5ee39d5d
...
...
@@ -4,8 +4,11 @@ import cz.muni.fi.pa165.dto.CountryDetailDto;
import
cz.muni.fi.pa165.dto.CountryNameDto
;
import
org.springframework.data.domain.Page
;
import
java.util.List
;
public
interface
CountryFacade
{
CountryNameDto
getCountryName
(
Long
missionId
);
CountryDetailDto
getCountryDetail
(
Long
missionId
);
Page
<
CountryNameDto
>
getAllCountries
(
int
page
,
int
pageSize
);
List
<
CountryNameDto
>
getAllCountries
();
}
ssa-rest/src/main/java/cz/muni/fi/pa165/rest/controller/AgentController.java
View file @
5ee39d5d
...
...
@@ -3,6 +3,7 @@ package cz.muni.fi.pa165.rest.controller;
import
cz.muni.fi.pa165.dto.AgentCountDto
;
import
cz.muni.fi.pa165.dto.AgentDetailDto
;
import
cz.muni.fi.pa165.dto.AgentListDto
;
import
cz.muni.fi.pa165.dto.SkillDto
;
import
cz.muni.fi.pa165.facade.AgentFacade
;
import
cz.muni.fi.pa165.rest.ApiUris
;
import
io.swagger.v3.oas.annotations.Operation
;
...
...
@@ -89,4 +90,36 @@ public class AgentController {
return
ResponseEntity
.
notFound
().
build
();
}
}
@Operation
(
description
=
"Retrieves all agents in the archive"
)
@GetMapping
(
"/allAgents"
)
public
final
ResponseEntity
<
List
<
AgentListDto
>>
getAllAgents
(
int
page
,
int
pageSize
)
{
//TODO logged in user logic
try
{
return
ResponseEntity
.
ok
().
body
(
agentFacade
.
getAllAgents
(
page
,
pageSize
).
getContent
());
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"Could not retrieve all agents"
,
e
);
return
ResponseEntity
.
notFound
().
build
();
}
}
@Operation
(
description
=
"Retrieves all skills of all agents in the archive"
)
@GetMapping
(
"/allSkills"
)
public
final
ResponseEntity
<
List
<
SkillDto
>>
getAllSkills
(
int
page
,
int
pageSize
)
{
//TODO logged in user logic
if
(
pageSize
==
0
)
{
try
{
return
ResponseEntity
.
ok
().
body
(
agentFacade
.
getAllSkills
());
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"Could not retrieve all skills"
,
e
);
return
ResponseEntity
.
notFound
().
build
();
}
}
try
{
return
ResponseEntity
.
ok
().
body
(
agentFacade
.
getAllSkills
(
page
,
pageSize
).
getContent
());
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"Could not retrieve all skills"
,
e
);
return
ResponseEntity
.
notFound
().
build
();
}
}
}
ssa-rest/src/main/java/cz/muni/fi/pa165/rest/controller/CountryController.java
View file @
5ee39d5d
...
...
@@ -2,6 +2,7 @@ package cz.muni.fi.pa165.rest.controller;
import
cz.muni.fi.pa165.dto.CountryDetailDto
;
import
cz.muni.fi.pa165.dto.CountryNameDto
;
import
cz.muni.fi.pa165.dto.MissionListDto
;
import
cz.muni.fi.pa165.facade.CountryFacade
;
import
cz.muni.fi.pa165.rest.ApiUris
;
import
io.swagger.v3.oas.annotations.Operation
;
...
...
@@ -15,6 +16,8 @@ import org.springframework.web.bind.annotation.PathVariable;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
@RestController
@RequestMapping
(
ApiUris
.
URI_COUNTRIES
)
@Tag
(
name
=
"Countries"
,
description
=
"Management of countries"
)
...
...
@@ -50,4 +53,24 @@ public class CountryController {
return
ResponseEntity
.
notFound
().
build
();
}
}
@Operation
(
description
=
"Retrieves all countries in the archive"
)
@GetMapping
(
"/allCountries"
)
public
final
ResponseEntity
<
List
<
CountryNameDto
>>
getAllCountries
(
int
page
,
int
pageSize
)
{
//TODO logged in user logic
if
(
pageSize
==
0
)
{
try
{
return
ResponseEntity
.
ok
().
body
(
countryFacade
.
getAllCountries
());
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"Could not retrieve all countries"
,
e
);
return
ResponseEntity
.
notFound
().
build
();
}
}
try
{
return
ResponseEntity
.
ok
().
body
(
countryFacade
.
getAllCountries
(
page
,
pageSize
).
getContent
());
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"Could not retrieve all countries"
,
e
);
return
ResponseEntity
.
notFound
().
build
();
}
}
}
ssa-rest/src/main/java/cz/muni/fi/pa165/rest/controller/MissionController.java
View file @
5ee39d5d
...
...
@@ -2,6 +2,7 @@ package cz.muni.fi.pa165.rest.controller;
import
cz.muni.fi.pa165.dto.MissionDetailDto
;
import
cz.muni.fi.pa165.dto.MissionListDto
;
import
cz.muni.fi.pa165.dto.SkillDto
;
import
cz.muni.fi.pa165.facade.MissionFacade
;
import
cz.muni.fi.pa165.rest.ApiUris
;
import
io.swagger.v3.oas.annotations.Operation
;
...
...
@@ -53,4 +54,16 @@ public class MissionController {
}
}
@Operation
(
description
=
"Retrieves all missions in the archive"
)
@GetMapping
(
"/allMissions"
)
public
final
ResponseEntity
<
List
<
MissionListDto
>>
getAllMissions
(
int
page
,
int
pageSize
)
{
//TODO logged in user logic
try
{
return
ResponseEntity
.
ok
().
body
(
missionFacade
.
getAllMissions
(
page
,
pageSize
).
getContent
());
}
catch
(
Exception
e
)
{
LOGGER
.
error
(
"Could not retrieve all missions"
,
e
);
return
ResponseEntity
.
notFound
().
build
();
}
}
}
ssa-service/src/main/java/cz/muni/fi/pa165/facade/AgentFacadeImpl.java
View file @
5ee39d5d
...
...
@@ -132,6 +132,12 @@ public class AgentFacadeImpl implements AgentFacade {
return
skills
.
map
(
skillMapper:
:
map
);
}
@Override
public
List
<
SkillDto
>
getAllSkills
()
{
List
<
Skill
>
skills
=
skillService
.
findAll
();
return
skills
.
stream
().
map
(
skillMapper:
:
map
).
collect
(
Collectors
.
toList
());
}
private
Page
<
AgentListDto
>
createPage
(
List
<
Agent
>
agents
,
Pageable
pageable
)
{
List
<
AgentListDto
>
mappedAgents
=
agents
.
stream
().
map
(
agentListMapper:
:
map
).
collect
(
Collectors
.
toList
());
final
int
start
=
(
int
)
pageable
.
getOffset
();
...
...
ssa-service/src/main/java/cz/muni/fi/pa165/facade/CountryFacadeImpl.java
View file @
5ee39d5d
...
...
@@ -5,6 +5,7 @@ import cz.muni.fi.pa165.config.CountryNameMapper;
import
cz.muni.fi.pa165.dto.CountryDetailDto
;
import
cz.muni.fi.pa165.dto.CountryNameDto
;
import
cz.muni.fi.pa165.entity.Country
;
import
cz.muni.fi.pa165.entity.Skill
;
import
cz.muni.fi.pa165.service.CountryService
;
import
cz.muni.fi.pa165.service.MissionService
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -13,6 +14,9 @@ import org.springframework.data.domain.PageRequest;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* @author Samuel Kulisek, 485087
*/
...
...
@@ -53,4 +57,10 @@ public class CountryFacadeImpl implements CountryFacade {
Page
<
Country
>
countries
=
countryService
.
findAll
(
pageable
);
return
countries
.
map
(
countryNameMapper:
:
map
);
}
@Override
public
List
<
CountryNameDto
>
getAllCountries
()
{
List
<
Country
>
skills
=
countryService
.
findAll
();
return
skills
.
stream
().
map
(
countryNameMapper:
:
map
).
collect
(
Collectors
.
toList
());
}
}
ssa-service/src/main/java/cz/muni/fi/pa165/service/CountryService.java
View file @
5ee39d5d
package
cz.muni.fi.pa165.service
;
import
cz.muni.fi.pa165.entity.Country
;
import
cz.muni.fi.pa165.entity.Skill
;
import
cz.muni.fi.pa165.repository.CountryRepository
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
* @author Samuel Kulisek, 485087
*/
...
...
@@ -27,6 +30,10 @@ public class CountryService {
return
countryRepository
.
findAll
(
page
);
}
public
List
<
Country
>
findAll
()
{
return
countryRepository
.
findAll
();
}
public
Long
create
(
Country
country
)
{
return
countryRepository
.
save
(
country
).
getId
();
}
...
...
ssa-service/src/main/java/cz/muni/fi/pa165/service/SkillService.java
View file @
5ee39d5d
...
...
@@ -8,6 +8,8 @@ import org.springframework.data.domain.Page;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
* @author Samuel Kulisek, 485087
*/
...
...
@@ -28,6 +30,10 @@ public class SkillService {
return
skillRepository
.
findAll
(
page
);
}
public
List
<
Skill
>
findAll
()
{
return
skillRepository
.
findAll
();
}
public
Page
<
Skill
>
findByType
(
SkillType
type
,
Pageable
page
)
{
return
skillRepository
.
findAllByType
(
type
,
page
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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