Commit c0a755bc authored by Jürgen Hannus's avatar Jürgen Hannus
Browse files

Merge branch 'develop' into 'master'

Release: merge 'develop' into 'master' created by Jürgen Hannus

See merge request teis/common-api-gateway!171
parents 51563694 2545145c
package ee.sm.ti.teis.commongateway.tasks.task.actionplan.request;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.commongateway.tasks.task.actionplan.dto.GetTaskActionPlansDto;
public class GetTaskActionPlansRequest extends AbstractDTO<GetTaskActionPlansDto, ErrorDTO> {
public static final String ROUTING_KEY = "api.GetTaskActionPlansRequest";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
package ee.sm.ti.teis.commongateway.tasks.task.actionplan.request;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
public class GetTaskReferencesRequest extends AbstractDTO<Void, ErrorDTO> {
public static final String ROUTING_KEY = "api.GetTaskReferencesRequest";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
package ee.sm.ti.teis.commongateway.tasks.task.actionplan.request;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
public class GetTaskResponsiblePersonsRequest extends AbstractDTO<Void, ErrorDTO> {
public static final String ROUTING_KEY = "api.GetTaskResponsiblePersonsRequest";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
package ee.sm.ti.teis.commongateway.tasks.task.actionplan.request;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.commongateway.tasks.task.actionplan.dto.UpdateTaskActionPlanStatusDto;
public class UpdateTaskActionPlanStatusRequest extends AbstractDTO<UpdateTaskActionPlanStatusDto, ErrorDTO> {
public static final String ROUTING_KEY = "api.UpdateTaskActionPlanStatusRequest";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
package ee.sm.ti.teis.commongateway.tasks.task.actionplan.response;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.commongateway.tasks.task.dto.TasksDto;
public class GetTaskActionPlansResponse extends AbstractDTO<TasksDto, ErrorDTO> {
public static final String ROUTING_KEY = "api.GetTaskActionPlansResponse";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
package ee.sm.ti.teis.commongateway.tasks.task.actionplan.response;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.commongateway.tasks.task.actionplan.dto.TaskReferencesDto;
public class GetTaskReferencesResponse extends AbstractDTO<TaskReferencesDto, ErrorDTO> {
public static final String ROUTING_KEY = "api.GetTaskReferencesResponse";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
package ee.sm.ti.teis.commongateway.tasks.task.actionplan.response;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.commongateway.tasks.task.actionplan.dto.TaskResponsiblePersonsDto;
public class GetTaskResponsiblePersonsResponse extends AbstractDTO<TaskResponsiblePersonsDto, ErrorDTO> {
public static final String ROUTING_KEY = "api.GetTaskResponsiblePersonsResponse";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
package ee.sm.ti.teis.commongateway.tasks.task.actionplan.response;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.commongateway.tasks.task.dto.TaskDto;
public class UpdateTaskActionPlanStatusResponse extends AbstractDTO<TaskDto, ErrorDTO> {
public static final String ROUTING_KEY = "api.UpdateTaskActionPlanStatusResponse";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
......@@ -41,6 +41,7 @@ public class TaskDto {
private TaskDefinitionDto taskDefinition;
private ClassifierItemLightDto tag;
private String responsiblePerson;
private LocalDateTime completedAt;
private ObjectStatus objectStatus;
}
package ee.sm.ti.teis.commongateway.tasks.task.dto;
import ee.sm.ti.teis.paging.AbstractPagedPayload;
public class TasksDto extends AbstractPagedPayload<TaskDto> {
}
package ee.sm.ti.teis.commongateway.riskassessments.riskassessment;
import ee.sm.ti.teis.commongateway.CommonApiGatewayTestBase;
import ee.sm.ti.teis.commongateway.riskassessments.riskassessment.dto.CopyRiskAssessmentDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskassessment.dto.CreateRiskAssessmentDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskassessment.dto.RiskAssessmentPublicDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskassessment.dto.UpdateRiskAssessmentStatusDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskassessment.dto.UpdateRiskAssessmentTitleDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskassessment.dto.*;
import ee.sm.ti.teis.gatewaycommon.error.NoResponseFromRabbitException;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import org.junit.jupiter.api.Test;
......@@ -58,6 +54,18 @@ class RiskAssessmentControllerTest extends CommonApiGatewayTestBase {
() -> controller.getConclusion(randomUUID(), new RequestMetaDTO()));
}
@Test
void getActionPlanConclusion_badRequest() {
assertThrows(NoResponseFromRabbitException.class,
() -> controller.getActionPlanConclusion(randomUUID(), new RequestMetaDTO()));
}
@Test
void getRiskFactorAssessment_badRequest() {
assertThrows(NoResponseFromRabbitException.class,
() -> controller.getRiskFactorAssessment(randomUUID(), null, new RequestMetaDTO()));
}
@Test
void updateStatus_badRequest() {
assertThrows(NoResponseFromRabbitException.class,
......
......@@ -26,7 +26,8 @@ class RiskFactorAssessmentControllerTest extends CommonApiGatewayTestBase {
@Test
void updateRiskExists_badRequest() {
assertThrows(NoResponseFromRabbitException.class,
() -> controller.updateRiskExists(randomUUID(), new UpdateRiskFactorAssessmentRiskExistsPublicDto(), new RequestMetaDTO()));
() -> controller.updateRiskExists(randomUUID(), new UpdateRiskFactorAssessmentRiskExistsPublicDto(),
new RequestMetaDTO()));
}
@Test
......@@ -36,13 +37,15 @@ class RiskFactorAssessmentControllerTest extends CommonApiGatewayTestBase {
@Test
void getRiskStatementAssessments_badRequest() {
assertThrows(NoResponseFromRabbitException.class, () -> controller.getRiskFactorAssessment(randomUUID(), new RequestMetaDTO()));
assertThrows(NoResponseFromRabbitException.class,
() -> controller.getRiskFactorAssessment(randomUUID(), null, new RequestMetaDTO()));
}
@Test
void updateDescription_badRequest() {
assertThrows(NoResponseFromRabbitException.class,
() -> controller.updateDescription(randomUUID(), new UpdateRiskFactorAssessmentDescriptionPublicDto(), new RequestMetaDTO()));
() -> controller.updateDescription(randomUUID(), new UpdateRiskFactorAssessmentDescriptionPublicDto(),
new RequestMetaDTO()));
}
}
......@@ -4,6 +4,7 @@ import ee.sm.ti.teis.commongateway.CommonApiGatewayTestBase;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.dto.CreateRiskStatementAssessmentPublicDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.dto.PatchRiskStatementAssessmentDescriptionPublicDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.dto.RiskStatementAssessmentPublicDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.dto.UpdateRiskStatementAssessmentActionPublicDto;
import ee.sm.ti.teis.gatewaycommon.error.NoResponseFromRabbitException;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import org.junit.jupiter.api.Test;
......@@ -31,9 +32,9 @@ class RiskStatementAssessmentControllerTest extends CommonApiGatewayTestBase {
@Test
void updateDescription_badRequest() {
assertThrows(NoResponseFromRabbitException.class,
() -> controller.updateDescription(randomUUID(), new PatchRiskStatementAssessmentDescriptionPublicDto(),
new RequestMetaDTO()));
assertThrows(NoResponseFromRabbitException.class, () -> controller.updateDescription(randomUUID(),
new PatchRiskStatementAssessmentDescriptionPublicDto(),
new RequestMetaDTO()));
}
@Test
......@@ -41,4 +42,10 @@ class RiskStatementAssessmentControllerTest extends CommonApiGatewayTestBase {
assertThrows(NoResponseFromRabbitException.class, () -> controller.delete(randomUUID(), new RequestMetaDTO()));
}
@Test
void updateAction_badRequest() {
assertThrows(NoResponseFromRabbitException.class, () -> controller.updateAction(randomUUID(),
new UpdateRiskStatementAssessmentActionPublicDto(), new RequestMetaDTO()));
}
}
package ee.sm.ti.teis.commongateway.tasks.task.actionplan;
import ee.sm.ti.teis.commongateway.CommonApiGatewayTestBase;
import ee.sm.ti.teis.commongateway.tasks.task.actionplan.dto.GetTaskActionPlansDto;
import ee.sm.ti.teis.commongateway.tasks.task.actionplan.dto.TaskActionPlanDto;
import ee.sm.ti.teis.commongateway.tasks.task.actionplan.dto.UpdateTaskActionPlanDto;
import ee.sm.ti.teis.commongateway.tasks.task.actionplan.dto.UpdateTaskActionPlanStatusDto;
import ee.sm.ti.teis.gatewaycommon.error.NoResponseFromRabbitException;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import org.junit.jupiter.api.Test;
......@@ -17,20 +19,32 @@ public class TaskActionPlanControllerTest extends CommonApiGatewayTestBase {
TaskActionPlanController controller;
@Test
void create() {
void create_badRequest() {
assertThrows(NoResponseFromRabbitException.class, () ->
controller.create(new TaskActionPlanDto(), new RequestMetaDTO()));
}
@Test
void delete() {
void delete_badRequest() {
assertThrows(NoResponseFromRabbitException.class, () ->
controller.delete(randomUUID(), new RequestMetaDTO()));
}
@Test
void update() {
void update_badRequest() {
assertThrows(NoResponseFromRabbitException.class, () ->
controller.update(randomUUID(), new UpdateTaskActionPlanDto(), new RequestMetaDTO()));
}
@Test
void getTaskActionPlan_badRequest() {
assertThrows(NoResponseFromRabbitException.class, () ->
controller.getTaskActionPlans(new GetTaskActionPlansDto(), new RequestMetaDTO()));
}
@Test
void updateStatus_badRequest() {
assertThrows(NoResponseFromRabbitException.class, () ->
controller.updateStatus(randomUUID(), new UpdateTaskActionPlanStatusDto(), new RequestMetaDTO()));
}
}
......@@ -4,6 +4,7 @@ import ee.sm.ti.teis.commongateway.riskassessments.riskassessment.dto.*;
import ee.sm.ti.teis.commongateway.riskassessments.riskassessment.request.*;
import ee.sm.ti.teis.gatewaycommon.controller.TeisBaseController;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import ee.sm.ti.teis.types.enums.RiskFactorAssessmentsOutputType;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
......@@ -79,19 +80,33 @@ public class RiskAssessmentController extends TeisBaseController {
@ApiResponse(code = 403, message = "Kasutajal ei ole õigust andmeobjekti pärida"),
@ApiResponse(code = 404, message = "Sisendis esitatud andmetega objekti ei eksisteeri")})
@GetMapping("{id}/conclusion")
public RiskAssessmentConclusionDto getConclusion(@PathVariable UUID id, RequestMetaDTO requestMetaDTO) {
public RiskAssessmentConclusionDto getConclusion(@PathVariable UUID id, RequestMetaDTO requestMetaDTO) {
RiskAssessmentConclusionPublicRequest request = new RiskAssessmentConclusionPublicRequest();
request.setPayload(id, requestMetaDTO);
return service.getConclusion(request);
}
@ApiOperation(value = "${teis.api.risk-assessments.risk-assessment.action-plan-conclusion}", response = RiskAssessmentActionPlanConclusionDto.class)
@ApiResponses(value = {
@ApiResponse(code = 400, message = "Sisend ei vasta nõuetele"),
@ApiResponse(code = 403, message = "Kasutajal puudub nõutav privileeg või õigus seda riskianalüüsi näha"),
@ApiResponse(code = 404, message = "Riskianalüüsi andmeobjekti ei leitud")})
@GetMapping("{id}/action-plan-conclusion")
public RiskAssessmentActionPlanConclusionDto getActionPlanConclusion(@PathVariable UUID id,
RequestMetaDTO requestMetaDTO) {
RiskAssessmentActionPlanConclusionPublicRequest request = new RiskAssessmentActionPlanConclusionPublicRequest();
request.setPayload(id, requestMetaDTO);
return service.getActionPlanConclusion(request);
}
@ApiOperation(value = "${teis.api.risk-assessments.risk-assessment.get-business-types}", response = RiskAssessmentPublicDto.class)
@ApiResponses(value = {
@ApiResponse(code = 403, message = "Kasutajal ei ole õigust andmeobjekti pärida")})
@GetMapping("{id}/business-types")
public RiskAssessmentPublicDto getRiskAssessmentBusinessTypes(@PathVariable UUID id,
RequestMetaDTO requestMetaDTO) {
RequestMetaDTO requestMetaDTO) {
RiskAssessmentBusinessTypePublicRequest request = new RiskAssessmentBusinessTypePublicRequest();
request.setPayload(id, requestMetaDTO);
......@@ -112,12 +127,14 @@ public class RiskAssessmentController extends TeisBaseController {
@ApiOperation(value = "${teis.api.risk-assessments.risk-assessment.get-risk-factor-assessments}", response = RiskAssessmentPublicDto.class)
@ApiResponses(value = {
@ApiResponse(code = 403, message = "Kasutajal ei ole õigust andmeobjekti pärida")})
@ApiResponse(code = 400, message = "Sisend ei vasta nõuetele"),
@ApiResponse(code = 403, message = "Kasutajal puudub nõutav privileeg või õigus seda riskianalüüsi näha"),
@ApiResponse(code = 404, message = "Sisendis viidatud riskianalüüsi ei eksisteeri")})
@GetMapping("{id}/risk-factor-assessments")
public RiskAssessmentPublicDto getRiskFactorAssessment(@PathVariable UUID id,
RequestMetaDTO requestMetaDTO) {
@RequestParam(required = false) RiskFactorAssessmentsOutputType outputType, RequestMetaDTO requestMetaDTO) {
RiskAssessmentRiskFactorAssessmentPublicRequest request = new RiskAssessmentRiskFactorAssessmentPublicRequest();
request.setPayload(id, requestMetaDTO);
request.setPayload(new RiskAssessmentRiskFactorAssessmentPublicRequest.Parameters(id, outputType), requestMetaDTO);
return service.getRiskFactorAssessments(request);
}
......
package ee.sm.ti.teis.commongateway.riskassessments.riskassessment;
import ee.sm.ti.teis.commongateway.riskassessments.riskassessment.dto.RiskAssessmentActionPlanConclusionDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskassessment.dto.RiskAssessmentConclusionDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskassessment.dto.RiskAssessmentPublicDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskassessment.request.*;
......@@ -55,9 +56,18 @@ public class RiskAssessmentProcessingService {
}
throw new NoResponseFromRabbitException(request.getRequestMetaDTO().getRequestId());
}
public RiskAssessmentActionPlanConclusionDto getActionPlanConclusion(
RiskAssessmentActionPlanConclusionPublicRequest request) {
RiskAssessmentActionPlanConclusionPublicResponse response =
(RiskAssessmentActionPlanConclusionPublicResponse) gwRabbitTemplate.convertSendAndReceive(request.routingKey(), request);
if (response != null) {
return response.processResponse();
}
throw new NoResponseFromRabbitException(request.getRequestMetaDTO().getRequestId());
}
public RiskAssessmentPublicDto getRiskAssessmentBusinessTypes(RiskAssessmentBusinessTypePublicRequest request) {
RiskAssessmentBusinessTypePublicResponse response =
......
......@@ -4,6 +4,7 @@ import ee.sm.ti.teis.commongateway.riskassessments.riskfactorassessment.dto.*;
import ee.sm.ti.teis.commongateway.riskassessments.riskfactorassessment.request.*;
import ee.sm.ti.teis.gatewaycommon.controller.TeisBaseController;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import ee.sm.ti.teis.types.enums.RiskFactorAssessmentsOutputType;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
......@@ -26,7 +27,7 @@ public class RiskFactorAssessmentController extends TeisBaseController {
@ApiResponse(code = 404, message = "Ohu hindamisega seotavat riskianalüüsi või ohu kirjelduse andmeobjekti ei leitud.")})
@PostMapping
public RiskFactorAssessmentPublicDto create(@RequestBody CreateRiskFactorAssessmentDto dto,
RequestMetaDTO requestMetaDTO) {
RequestMetaDTO requestMetaDTO) {
CreateRiskFactorAssessmentRequest request = new CreateRiskFactorAssessmentRequest();
request.setPayload(dto, requestMetaDTO);
......@@ -41,8 +42,8 @@ public class RiskFactorAssessmentController extends TeisBaseController {
@ApiResponse(code = 404, message = "Sisendis esitatud andmetega objekti ei eksisteeri")})
@PatchMapping("{id}/risk-exists")
public RiskFactorAssessmentPublicLightDto updateRiskExists(@PathVariable UUID id,
@RequestBody UpdateRiskFactorAssessmentRiskExistsPublicDto dto,
RequestMetaDTO requestMetaDTO) {
@RequestBody UpdateRiskFactorAssessmentRiskExistsPublicDto dto,
RequestMetaDTO requestMetaDTO) {
UpdateRiskFactorAssessmentRiskExistsPublicRequest request = new UpdateRiskFactorAssessmentRiskExistsPublicRequest();
dto.setId(id);
request.setPayload(dto, requestMetaDTO);
......@@ -55,7 +56,7 @@ public class RiskFactorAssessmentController extends TeisBaseController {
@ApiResponse(code = 400, message = "Sisendi parameetrid ei vasta nõuetele"),
@ApiResponse(code = 403, message = "Kasutajal ei ole õigust andmeobjekti pärida")})
@DeleteMapping("{id}")
public void delete(@PathVariable UUID id, RequestMetaDTO requestMetaDTO) {
public void delete(@PathVariable UUID id, RequestMetaDTO requestMetaDTO) {
DeleteRiskFactorAssessmentPublicRequest request = new DeleteRiskFactorAssessmentPublicRequest();
request.setPayload(id, requestMetaDTO);
......@@ -69,9 +70,10 @@ public class RiskFactorAssessmentController extends TeisBaseController {
@ApiResponse(code = 403, message = "Kasutajal ei ole õigust andmeobjekti pärida"),
@ApiResponse(code = 404, message = "Sisendis esitatud andmetega objekti ei eksisteeri")})
@GetMapping("{id}")
public RiskFactorAssessmentPublicDto getRiskFactorAssessment(@PathVariable UUID id, RequestMetaDTO requestMetaDTO) {
public RiskFactorAssessmentPublicDto getRiskFactorAssessment(@PathVariable UUID id,
@RequestParam(required = false) RiskFactorAssessmentsOutputType outputType, RequestMetaDTO requestMetaDTO) {
RiskFactorAssessmentPublicRequest request = new RiskFactorAssessmentPublicRequest();
request.setPayload(id, requestMetaDTO);
request.setPayload(new RiskFactorAssessmentPublicRequest.Parameters(id, outputType), requestMetaDTO);
return service.getRiskFactorAssessment(request);
}
......@@ -84,8 +86,7 @@ public class RiskFactorAssessmentController extends TeisBaseController {
@ApiResponse(code = 404, message = "Sisendis esitatud andmetega objekti ei eksisteeri")})
@PatchMapping("{id}/description")
public RiskFactorAssessmentPublicLightDto updateDescription(@PathVariable UUID id,
@RequestBody UpdateRiskFactorAssessmentDescriptionPublicDto dto,
RequestMetaDTO requestMetaDTO) {
@RequestBody UpdateRiskFactorAssessmentDescriptionPublicDto dto, RequestMetaDTO requestMetaDTO) {
UpdateRiskFactorAssessmentDescriptionPublicRequest request = new UpdateRiskFactorAssessmentDescriptionPublicRequest();
dto.setId(id);
request.setPayload(dto, requestMetaDTO);
......
package ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.dto.CreateRiskStatementAssessmentPublicDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.dto.PatchRiskStatementAssessmentDescriptionPublicDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.dto.RiskStatementAssessmentPublicDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.request.CreateRiskStatementAssessmentPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.request.DeleteRiskStatementAssessmentPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.request.PatchRiskStatementAssessmentDescriptionPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.request.PatchRiskStatementAssessmentPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.dto.*;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.request.*;
import ee.sm.ti.teis.gatewaycommon.controller.TeisBaseController;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import io.swagger.annotations.ApiOperation;
......@@ -32,8 +27,8 @@ public class RiskStatementAssessmentController extends TeisBaseController {
@ApiResponse(code = 404, message = "Sisendis esitatud andmetega objekti ei eksisteeri")})
@PatchMapping("{id}/assessment")
public RiskStatementAssessmentPublicDto update(@PathVariable UUID id,
@RequestBody RiskStatementAssessmentPublicDto dto,
RequestMetaDTO requestMetaDTO) {
@RequestBody RiskStatementAssessmentPublicDto dto,
RequestMetaDTO requestMetaDTO) {
PatchRiskStatementAssessmentPublicRequest request = new PatchRiskStatementAssessmentPublicRequest();
dto.setId(id);
request.setPayload(dto, requestMetaDTO);
......@@ -49,7 +44,7 @@ public class RiskStatementAssessmentController extends TeisBaseController {
@ApiResponse(code = 404, message = "Sisendis esitatud andmetega objekti ei eksisteeri")})
@PostMapping
public RiskStatementAssessmentPublicDto create(@RequestBody CreateRiskStatementAssessmentPublicDto dto,
RequestMetaDTO requestMetaDTO) {
RequestMetaDTO requestMetaDTO) {
CreateRiskStatementAssessmentPublicRequest request = new CreateRiskStatementAssessmentPublicRequest();
request.setPayload(dto, requestMetaDTO);
......@@ -62,7 +57,7 @@ public class RiskStatementAssessmentController extends TeisBaseController {
@ApiResponse(code = 403, message = "Kasutajal ei ole õigust andmeobjekti pärida"),
@ApiResponse(code = 404, message = "Sisendis esitatud andmetega objekti ei eksisteeri")})
@DeleteMapping("{id}")
public void delete(@PathVariable UUID id, RequestMetaDTO requestMetaDTO) {
public void delete(@PathVariable UUID id, RequestMetaDTO requestMetaDTO) {
DeleteRiskStatementAssessmentPublicRequest request = new DeleteRiskStatementAssessmentPublicRequest();
request.setPayload(id, requestMetaDTO);
......@@ -77,12 +72,28 @@ public class RiskStatementAssessmentController extends TeisBaseController {
@ApiResponse(code = 404, message = "Sisendis esitatud andmetega objekti ei eksisteeri")})
@PatchMapping("{id}/description")
public RiskStatementAssessmentPublicDto updateDescription(@PathVariable UUID id,
@RequestBody PatchRiskStatementAssessmentDescriptionPublicDto dto,
RequestMetaDTO requestMetaDTO) {
@RequestBody PatchRiskStatementAssessmentDescriptionPublicDto dto,
RequestMetaDTO requestMetaDTO) {
PatchRiskStatementAssessmentDescriptionPublicRequest request = new PatchRiskStatementAssessmentDescriptionPublicRequest();
dto.setRiskStatementAssessmentId(id);
request.setPayload(dto, requestMetaDTO);
return service.updateDescription(request);
}
@ApiOperation(value = "${teis.api.risk-assessments.risk-statement-assessment.patch-action}",
response = RiskStatementAssessmentActionPublicDto.class)
@ApiResponses(value = {
@ApiResponse(code = 400, message = "Sisendi parameetrid ei vasta nõuetele"),
@ApiResponse(code = 403, message = "Kasutajal puudub nõutav privileeg või õigus seda riskianalüüsi muuta"),
@ApiResponse(code = 404, message = "Riski maandamise meetme hinnangu andmeobjekti ei leitud")})
@PatchMapping("{id}/action")
public RiskStatementAssessmentActionPublicDto updateAction(@PathVariable UUID id,
@RequestBody UpdateRiskStatementAssessmentActionPublicDto dto, RequestMetaDTO requestMetaDTO) {
UpdateRiskStatementAssessmentActionPublicRequest request = new UpdateRiskStatementAssessmentActionPublicRequest();
dto.setId(id);
request.setPayload(dto, requestMetaDTO);
return service.updateAction(request);
}
}
package ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.dto.RiskStatementAssessmentActionPublicDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.dto.RiskStatementAssessmentPublicDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.request.CreateRiskStatementAssessmentPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.request.DeleteRiskStatementAssessmentPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.request.PatchRiskStatementAssessmentDescriptionPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.request.PatchRiskStatementAssessmentPublicRequest;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.response.CreateRiskStatementAssessmentPublicResponse;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.response.DeleteRiskStatementAssessmentPublicResponse;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.response.PatchRiskStatementAssessmentDescriptionPublicResponse;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.response.PatchRiskStatementAssessmentPublicResponse;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.request.*;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.response.*;
import ee.sm.ti.teis.gatewaycommon.error.NoResponseFromRabbitException;
import lombok.RequiredArgsConstructor;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
......@@ -60,4 +55,14 @@ public class RiskStatementAssessmentProcessingService {
throw new NoResponseFromRabbitException(request.getRequestMetaDTO().getRequestId());
}
public RiskStatementAssessmentActionPublicDto updateAction(UpdateRiskStatementAssessmentActionPublicRequest request) {
UpdateRiskStatementAssessmentActionPublicResponse response =
(UpdateRiskStatementAssessmentActionPublicResponse) gwRabbitTemplate.convertSendAndReceive(request.routingKey(), request);
if (response != null) {
return response.processResponse();
}
throw new NoResponseFromRabbitException(request.getRequestMetaDTO().getRequestId());
}
}