Commit 264ce017 authored by Siiri Tann's avatar Siiri Tann
Browse files

Merge branch 'TEIS-407' into 'develop'

TEIS-407: added new endpoint for updating procedural act topics.

See merge request teis/office-api-gateway!180
parents 323509dc 33e9bdf1
package ee.sm.ti.teis.officegateway.proceedings.proceduralact.request;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.commongateway.classifier.ClassifierItemLightDto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
import java.util.UUID;
public class UpdateProceduralActInspectionTopicsRequest extends AbstractDTO<UpdateProceduralActInspectionTopicsRequest.Parameters, ErrorDTO> {
public static final String ROUTING_KEY = "api.UpdateProceduralActInspectionTopicsRequest";
@Override
public String routingKey() {
return ROUTING_KEY;
}
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class Parameters {
private UUID id;
private List<ClassifierItemLightDto> inspectionTopicCodes;
}
}
package ee.sm.ti.teis.officegateway.proceedings.proceduralact.response;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.officegateway.proceedings.proceduralact.dto.ProceduralActInspectionTopicDto;
import java.util.List;
public class UpdateProceduralActInspectionTopicsResponse extends AbstractDTO<List<ProceduralActInspectionTopicDto>, ErrorDTO> {
public static final String ROUTING_KEY = "api.UpdateProceduralActInspectionTopicsResponse";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
......@@ -11,6 +11,7 @@ import java.util.List;
import java.util.UUID;
public class UpdateProceedingInspectionTopicRequest extends AbstractDTO<UpdateProceedingInspectionTopicRequest.Parameters, ErrorDTO> {
public static final String ROUTING_KEY = "api.UpdateProceedingInspectionTopicRequest";
@Override
......
package ee.sm.ti.teis.officegateway.proceedings.proceduralact;
import ee.sm.ti.teis.commongateway.classifier.ClassifierItemLightDto;
import ee.sm.ti.teis.gatewaycommon.error.NoResponseFromRabbitException;
import ee.sm.ti.teis.officegateway.OfficeApiGatewayTestBase;
import ee.sm.ti.teis.officegateway.proceedings.proceduralact.controller.ProceduralActController;
......@@ -11,6 +12,8 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import static java.util.UUID.randomUUID;
import static org.junit.jupiter.api.Assertions.assertThrows;
......@@ -53,6 +56,13 @@ class ProceduralActControllerTest extends OfficeApiGatewayTestBase {
new RequestMetaDTO()));
}
@Test
void putProceduralActInspectionTopics_badRequest() {
List<ClassifierItemLightDto> inspectionTopicCodes = new ArrayList<>();
assertThrows(NoResponseFromRabbitException.class, () ->
controller.updateProceduralActInspectionTopics(randomUUID(), inspectionTopicCodes, new RequestMetaDTO()));
}
@Test
void createProceduralActConductingTime_badRequest() {
assertThrows(NoResponseFromRabbitException.class, () ->
......
package ee.sm.ti.teis.officegateway.proceedings.proceduralact.controller;
import ee.sm.ti.teis.commongateway.classifier.ClassifierItemLightDto;
import ee.sm.ti.teis.gatewaycommon.controller.TeisBaseController;
import ee.sm.ti.teis.gatewaycommon.rabbit.RequestProcessingService;
import ee.sm.ti.teis.officegateway.proceedings.proceduralact.dto.ProceduralActConductingTimeDto;
import ee.sm.ti.teis.officegateway.proceedings.proceduralact.dto.ProceduralActDto;
import ee.sm.ti.teis.officegateway.proceedings.proceduralact.dto.ProceduralActInspectionTopicDto;
......@@ -23,6 +25,7 @@ import java.util.UUID;
public class ProceduralActController extends TeisBaseController {
private final ProceduralActProcessingService processingService;
private final RequestProcessingService service;
@ApiOperation(value = "${teis.api.messages.proceeding.get-procedural-acts}", response = ProceduralActDto.class)
@GetMapping
......@@ -30,7 +33,7 @@ public class ProceduralActController extends TeisBaseController {
ProceduralActsRequest request = new ProceduralActsRequest();
request.setPayload(id, requestMetaDTO);
return processingService.getProceduralActs(request);
return (List<ProceduralActDto>) service.sendAndReceive(request);
}
@ApiOperation(value = "${teis.api.messages.proceeding.get-procedural-act}", response = ProceduralActDto.class)
......@@ -38,39 +41,37 @@ public class ProceduralActController extends TeisBaseController {
public ProceduralActDto getProceduralAct(@PathVariable UUID id, RequestMetaDTO requestMetaDTO) {
ProceduralActRequest request = new ProceduralActRequest();
request.setPayload(id, requestMetaDTO);
return processingService.getProceduralAct(request);
return (ProceduralActDto) service.sendAndReceive(request);
}
@ApiOperation(value = "${teis.api.messages.proceeding.post-procedural-act}", response = ProceduralActDto.class)
@PostMapping
public ProceduralActDto create(@RequestBody ProceduralActDto dto,
RequestMetaDTO requestMetaDTO) {
public ProceduralActDto create(@RequestBody ProceduralActDto dto, RequestMetaDTO requestMetaDTO) {
CreateProceduralActRequest request = new CreateProceduralActRequest();
request.setPayload(dto, requestMetaDTO);
return processingService.create(request);
return (ProceduralActDto) service.sendAndReceive(request);
}
@ApiOperation(value = "${teis.api.messages.proceeding.post-procedural-act}", response = ProceduralActDto.class)
@PutMapping("{id}")
public ProceduralActDto update(@PathVariable UUID id, @RequestBody ProceduralActDto dto,
RequestMetaDTO requestMetaDTO) {
public ProceduralActDto update(@PathVariable UUID id, @RequestBody ProceduralActDto dto, RequestMetaDTO requestMetaDTO) {
UpdateProceduralActRequest request = new UpdateProceduralActRequest();
dto.setId(id);
request.setPayload(dto, requestMetaDTO);
return processingService.update(request);
return (ProceduralActDto) service.sendAndReceive(request);
}
@ApiOperation(value = "${teis.api.messages.proceeding.patch-procedural-act}", response = ProceduralActDto.class)
@PatchMapping("{id}/status")
public ProceduralActDto updateStatus(@PathVariable UUID id, @RequestBody StatusDto statusDto,
RequestMetaDTO requestMetaDTO) {
public ProceduralActDto updateStatus(@PathVariable UUID id, @RequestBody StatusDto statusDto, RequestMetaDTO requestMetaDTO) {
UpdateProceduralActStatusRequest request = new UpdateProceduralActStatusRequest();
statusDto.setId(id);
request.setPayload(statusDto, requestMetaDTO);
return processingService.updateStatus(request);
return (ProceduralActDto) service.sendAndReceive(request);
}
@ApiOperation(value = "${teis.api.messages.proceeding.delete-procedural-act}", response = ProceduralActDto.class)
......@@ -79,7 +80,7 @@ public class ProceduralActController extends TeisBaseController {
DeleteProceduralActRequest request = new DeleteProceduralActRequest();
request.setPayload(id, requestMetaDTO);
return processingService.delete(request);
return (ProceduralActDto) service.sendAndReceive(request);
}
@ApiOperation(value = "${teis.api.messages.proceeding.get-procedural-act-inspection-topics}", response = ProceduralActInspectionTopicDto.class)
......@@ -88,20 +89,29 @@ public class ProceduralActController extends TeisBaseController {
ProceduralActInspectionTopicsRequest request = new ProceduralActInspectionTopicsRequest();
request.setPayload(id, requestMetaDTO);
return processingService.getProceduralActInspectionTopics(request);
return (List<ProceduralActInspectionTopicDto>) service.sendAndReceive(request);
}
@ApiOperation(value = "${teis.api.messages.proceeding.put-procedural-act-inspection-topics}", response = ProceduralActInspectionTopicDto.class)
@PutMapping(value = "{id}/inspection-topics")
public List<ProceduralActInspectionTopicDto> updateProceduralActInspectionTopics(@PathVariable UUID id,
@RequestBody(required = false) List<ClassifierItemLightDto> inspectionTopicCodes,
RequestMetaDTO requestMetaDTO) {
UpdateProceduralActInspectionTopicsRequest request = new UpdateProceduralActInspectionTopicsRequest();
request.setPayload(new UpdateProceduralActInspectionTopicsRequest.Parameters(id, inspectionTopicCodes), requestMetaDTO);
return (List<ProceduralActInspectionTopicDto>) service.sendAndReceive(request);
}
@ApiOperation(value = "${teis.api.messages.proceeding.post-procedural-act-conducting-time}", response = ProceduralActDto.class)
@PostMapping(value = "{id}/conducting-time")
public ProceduralActConductingTimeDto createProceduralActConductingTime(
@PathVariable UUID id,
@RequestBody ProceduralActConductingTimeDto dto,
RequestMetaDTO requestMetaDTO) {
public ProceduralActConductingTimeDto createProceduralActConductingTime(@PathVariable UUID id,
@RequestBody ProceduralActConductingTimeDto dto, RequestMetaDTO requestMetaDTO) {
CreateProceduralActConductingTimeRequest request = new CreateProceduralActConductingTimeRequest();
dto.setProceduralActId(id);
request.setPayload(dto, requestMetaDTO);
return processingService.createProceduralActConductingTime(request);
return (ProceduralActConductingTimeDto) service.sendAndReceive(request);
}
@ApiOperation(value = "${teis.api.messages.proceeding.get-procedural-act-minutes-preview}")
......@@ -116,14 +126,15 @@ public class ProceduralActController extends TeisBaseController {
@ApiOperation(value = "${teis.api.messages.proceeding.procedural-act-feedback}")
@GetMapping(value = "feedback-addressees")
public void getFeedbackCSV(@RequestParam(required = false) LocalDate endDatePeriodStart,
@RequestParam(required = false) LocalDate endDatePeriodEnd,
RequestMetaDTO requestMetaDTO,
HttpServletResponse response) {
@RequestParam(required = false) LocalDate endDatePeriodEnd,
RequestMetaDTO requestMetaDTO,
HttpServletResponse response) {
ProceduralActFeedbackCSVRequest request = new ProceduralActFeedbackCSVRequest();
ProceduralActFeedbackCSVRequest.Parameters payload = new ProceduralActFeedbackCSVRequest.Parameters();
payload.setEndDatePeriodEnd(endDatePeriodEnd);
payload.setEndDatePeriodStart(endDatePeriodStart);
request.setPayload(payload, requestMetaDTO);
processingService.getFeedbackCSV(request, response);
}
......
......@@ -4,11 +4,9 @@ import ee.sm.ti.teis.commongateway.docgen.dto.GeneratedDocumentDto;
import ee.sm.ti.teis.exceptions.TeisResourceNotFoundException;
import ee.sm.ti.teis.gatewaycommon.error.NoResponseFromRabbitException;
import ee.sm.ti.teis.officegateway.docgen.response.PreviewDocumentResponse;
import ee.sm.ti.teis.officegateway.proceedings.proceduralact.dto.ProceduralActConductingTimeDto;
import ee.sm.ti.teis.officegateway.proceedings.proceduralact.dto.ProceduralActDto;
import ee.sm.ti.teis.officegateway.proceedings.proceduralact.dto.ProceduralActInspectionTopicDto;
import ee.sm.ti.teis.officegateway.proceedings.proceduralact.request.*;
import ee.sm.ti.teis.officegateway.proceedings.proceduralact.response.*;
import ee.sm.ti.teis.officegateway.proceedings.proceduralact.request.ProceduralActFeedbackCSVRequest;
import ee.sm.ti.teis.officegateway.proceedings.proceduralact.request.ProceduralActPreviewRequest;
import ee.sm.ti.teis.officegateway.proceedings.proceduralact.response.ProceduralActFeedbackCSVResponse;
import lombok.RequiredArgsConstructor;
import org.apache.tomcat.util.http.fileupload.IOUtils;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
......@@ -17,102 +15,13 @@ import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.List;
@Service
@Deprecated(since = "1.19.0-SNAPSHOT", forRemoval = true)
@RequiredArgsConstructor
public class ProceduralActProcessingService {
private final RabbitTemplate gwRabbitTemplate;
public List<ProceduralActDto> getProceduralActs(ProceduralActsRequest request) {
ProceduralActsResponse response =
(ProceduralActsResponse) gwRabbitTemplate.convertSendAndReceive(request.routingKey(), request);
if (response != null) {
return response.processResponse();
}
throw new NoResponseFromRabbitException(request.getRequestMetaDTO().getRequestId());
}
public ProceduralActDto getProceduralAct(ProceduralActRequest request) {
ProceduralActResponse response =
(ProceduralActResponse) gwRabbitTemplate.convertSendAndReceive(request.routingKey(), request);
if (response != null) {
return response.processResponse();
}
throw new NoResponseFromRabbitException(request.getRequestMetaDTO().getRequestId());
}
public ProceduralActDto create(CreateProceduralActRequest request) {
CreateProceduralActResponse response =
(CreateProceduralActResponse) gwRabbitTemplate.convertSendAndReceive(request.routingKey(), request);
if (response != null) {
return response.processResponse();
}
throw new NoResponseFromRabbitException(request.getRequestMetaDTO().getRequestId());
}
public ProceduralActDto update(UpdateProceduralActRequest request) {
UpdateProceduralActResponse response =
(UpdateProceduralActResponse) gwRabbitTemplate.convertSendAndReceive(request.routingKey(), request);
if (response != null) {
return response.processResponse();
}
throw new NoResponseFromRabbitException(request.getRequestMetaDTO().getRequestId());
}
public ProceduralActDto updateStatus(UpdateProceduralActStatusRequest request) {
UpdateProceduralActStatusResponse response =
(UpdateProceduralActStatusResponse) gwRabbitTemplate.convertSendAndReceive(request.routingKey(), request);
if (response != null) {
return response.processResponse();
}
throw new NoResponseFromRabbitException(request.getRequestMetaDTO().getRequestId());
}
public ProceduralActDto delete(DeleteProceduralActRequest request) {
DeleteProceduralActResponse response =
(DeleteProceduralActResponse) gwRabbitTemplate.convertSendAndReceive(request.routingKey(), request);
if (response != null) {
return response.processResponse();
}
throw new NoResponseFromRabbitException(request.getRequestMetaDTO().getRequestId());
}
public List<ProceduralActInspectionTopicDto> getProceduralActInspectionTopics(ProceduralActInspectionTopicsRequest request) {
ProceduralActInspectionTopicsResponse response =
(ProceduralActInspectionTopicsResponse) gwRabbitTemplate.convertSendAndReceive(request.routingKey(), request);
if (response != null) {
return response.processResponse();
}
throw new NoResponseFromRabbitException(request.getRequestMetaDTO().getRequestId());
}
public ProceduralActConductingTimeDto createProceduralActConductingTime(CreateProceduralActConductingTimeRequest request) {
CreateProceduralActConductingTimeResponse response =
(CreateProceduralActConductingTimeResponse) gwRabbitTemplate.convertSendAndReceive(request.routingKey(), request);
if (response != null) {
return response.processResponse();
}
throw new NoResponseFromRabbitException(request.getRequestMetaDTO().getRequestId());
}
public void preview(ProceduralActPreviewRequest request, HttpServletResponse response) {
GeneratedDocumentDto generatedDocument = getNoticePreview(request);
response.addHeader("Content-disposition", "attachment;filename=" + generatedDocument.getDocName());
......
......@@ -2,6 +2,7 @@ package ee.sm.ti.teis.officegateway.proceedings.supervision.inspection.topic;
import ee.sm.ti.teis.commongateway.classifier.ClassifierItemLightDto;
import ee.sm.ti.teis.gatewaycommon.controller.TeisBaseController;
import ee.sm.ti.teis.gatewaycommon.rabbit.RequestProcessingService;
import ee.sm.ti.teis.officegateway.proceedings.supervision.inspection.topic.request.SupervisionPlanInspectionTopicsRequest;
import ee.sm.ti.teis.officegateway.proceedings.supervision.inspection.topic.request.UpdateSupervisionPlanInspectionTopicsRequest;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
......@@ -21,7 +22,7 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
@RequiredArgsConstructor
public class SupervisionPlanTopicController extends TeisBaseController {
private final SupervisionPlanTopicProcessingService processingService;
private final RequestProcessingService service;
@ApiOperation(value = "${teis.api.messages.proceeding.get-supervision-plan-inspection-topics}",
response = SupervisionPlanInspectionTopicDto.class)
......@@ -32,7 +33,7 @@ public class SupervisionPlanTopicController extends TeisBaseController {
SupervisionPlanInspectionTopicsRequest request = new SupervisionPlanInspectionTopicsRequest();
request.setPayload(id, requestMetaDTO);
return processingService.getTopics(request);
return (List<SupervisionPlanInspectionTopicDto>) service.sendAndReceive(request);
}
@ApiOperation(value = "${teis.api.messages.proceeding.put-supervision-plan-inspection-topics}",
......@@ -45,6 +46,6 @@ public class SupervisionPlanTopicController extends TeisBaseController {
UpdateSupervisionPlanInspectionTopicsRequest request = new UpdateSupervisionPlanInspectionTopicsRequest();
request.setPayload(new UpdateSupervisionPlanInspectionTopicsRequest.Parameters(id, inspectionTopicCodes), requestMetaDTO);
return processingService.updateTopics(request);
return (List<SupervisionPlanInspectionTopicDto>) service.sendAndReceive(request);
}
}
package ee.sm.ti.teis.officegateway.proceedings.supervision.inspection.topic;
import ee.sm.ti.teis.gatewaycommon.error.NoResponseFromRabbitException;
import ee.sm.ti.teis.officegateway.proceedings.supervision.inspection.topic.request.SupervisionPlanInspectionTopicsRequest;
import ee.sm.ti.teis.officegateway.proceedings.supervision.inspection.topic.request.UpdateSupervisionPlanInspectionTopicsRequest;
import ee.sm.ti.teis.officegateway.proceedings.supervision.inspection.topic.response.SupervisionPlanInspectionTopicsResponse;
import ee.sm.ti.teis.officegateway.proceedings.supervision.inspection.topic.response.UpdateSupervisionPlanInspectionTopicsResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@Deprecated(since = "1.19.0-SNAPSHOT", forRemoval = true)
@RequiredArgsConstructor
public class SupervisionPlanTopicProcessingService {
private final RabbitTemplate gwRabbitTemplate;
List<SupervisionPlanInspectionTopicDto> getTopics(
SupervisionPlanInspectionTopicsRequest request) {
SupervisionPlanInspectionTopicsResponse response =
(SupervisionPlanInspectionTopicsResponse) gwRabbitTemplate.convertSendAndReceive(request.routingKey(), request);
if (response != null) {
return response.processResponse();
}
throw new NoResponseFromRabbitException(request.getRequestMetaDTO().getRequestId());
}
List<SupervisionPlanInspectionTopicDto> updateTopics(
UpdateSupervisionPlanInspectionTopicsRequest request) {
UpdateSupervisionPlanInspectionTopicsResponse response =
(UpdateSupervisionPlanInspectionTopicsResponse) gwRabbitTemplate.convertSendAndReceive(request.routingKey(), request);
if (response != null) {
return response.processResponse();
}
throw new NoResponseFromRabbitException(request.getRequestMetaDTO().getRequestId());
}
}
......@@ -79,6 +79,7 @@ teis.api.messages.get-procedural-act-comment: APIga tagastab antud proceduralAct
teis.api.messages.proceeding.delete-procedural-act-comment: APIga on võimalik kustutada kontrolli märkuse/kommentaari objekti. Mõeldud kontrolli märkuse/kommentaari kustutamiseks.
teis.api.messages.proceeding.put-procedural-act-comment: APIga on võimalik muuta kontrolli käigus lisatud kommentaare/märkmeid. Mõeldud kontrolli käigus kontrollile lisatavate kommentaaride/märkmete muutmiseks.
teis.api.messages.proceeding.get-procedural-act-inspection-topics: API-ga on võimalik otsida kontrollile lisatud kontrolli teemasid.
teis.api.messages.proceeding.put-procedural-act-inspection-topics: API-ga on võimalik muuta kontrollil kontrolliteemasid.
teis.api.messages.proceeding.post-procedural-act-conducting-time: API-ga on võimalik salvestada kontrolli läbiviimise aja objekti andmed.
teis.api.messages.proceeding.post-procedural-act-violation: API abil on võimalik luua uus puuduse fikseerimise aja objekt. Mõeldud lahendatamata puuduse uuesti fikseerimiseks uue kontrolli raames.
teis.api.messages.proceeding.delete-procedural-act-violation: API abil on võimalik kustutada puuduse fikseerimise aja objekti andmeid. Mõeldud korduva puuduse fikseerimise kustutamiseks.
......
theGroup=ee.sm.ti.teis
theVersion=1.24.0
theVersion=1.25.0-SNAPSHOT
commonsVersion=1.24.0
commonApiGatewayVersion=1.24.0
pluginVersion=1.3.0
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment