Commit 6952c66f authored by Enriko Käsper's avatar Enriko Käsper
Browse files

Merge branch 'develop' into 'master'

Release: merge 'develop' into 'master' created by Enriko Käsper

See merge request teis/common-api-gateway!133
parents 0c62d781 6a036336
......@@ -13,6 +13,7 @@ import lombok.NoArgsConstructor;
public class ClassifierItemSearchFilterDto {
private String definitionId;
private String itemCode;
private String itemName;
private String attributeCode;
private String attributeValue;
private Integer itemLevel;
......
package ee.sm.ti.teis.commongateway.representative.authoritypermission.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class AuthorityPermissionExistsDto {
@NotNull
private boolean permissionExists;
}
package ee.sm.ti.teis.commongateway.representative.authoritypermission.dto;
import ee.sm.ti.teis.types.enums.AuthorityType;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
import java.util.UUID;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ValidateAuthorityPermissionDto {
@NotNull
private UUID personId;
@NotNull
private UUID grantorId;
@NotNull
private AuthorityType authorityType;
}
package ee.sm.ti.teis.commongateway.representative.authoritypermission.request;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.commongateway.representative.authoritypermission.dto.ValidateAuthorityPermissionDto;
public class ValidateAuthorityPermissionRequest extends AbstractDTO<ValidateAuthorityPermissionDto, ErrorDTO> {
public static final String ROUTING_KEY = "api.ValidateAuthorityPermissionRequest";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
package ee.sm.ti.teis.commongateway.representative.authoritypermission.response;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.commongateway.representative.authoritypermission.dto.AuthorityPermissionExistsDto;
public class ValidateAuthorityPermissionResponse extends AbstractDTO<AuthorityPermissionExistsDto, ErrorDTO> {
public static final String ROUTING_KEY = "api.ValidateAuthorityPermissionResponse";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
package ee.sm.ti.teis.commongateway.riskassessments.riskfactorassessment.dto;
import ee.sm.ti.teis.commongateway.riskassessments.riskfactor.dto.RiskFactorPublicDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskfactordetailsassessment.dto.RiskFactorDetailsAssessmentPublicDto;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.dto.RiskStatementAssessmentPublicDto;
import ee.sm.ti.teis.types.enums.ObjectStatus;
import ee.sm.ti.teis.types.enums.RiskFactorAssessmentStatus;
......@@ -23,6 +24,7 @@ public class RiskFactorAssessmentPublicDto {
private RiskFactorPublicDto riskFactor;
private List<RiskStatementAssessmentPublicDto> riskStatementAssessments;
private RiskFactorAssessmentStatus riskFactorAssessmentStatus;
private List<RiskFactorDetailsAssessmentPublicDto> riskFactorDetailsAssessments;
private String name;
private String description;
private Boolean riskExists;
......
package ee.sm.ti.teis.commongateway.riskassessments.riskfactordetailsassessment.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.UUID;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class RiskFactorDetailsAssessmentPublicDto {
private UUID id;
private UUID riskFactorAssessmentId;
private RiskFactorDetailsPublicLightDto riskFactorDetails;
private Boolean assessment;
}
package ee.sm.ti.teis.commongateway.riskassessments.riskfactordetailsassessment.dto;
import ee.sm.ti.teis.commongateway.classifier.ClassifierItemLightDto;
import ee.sm.ti.teis.types.enums.ObjectStatus;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.UUID;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class RiskFactorDetailsPublicLightDto {
private UUID id;
private UUID riskFactorId;
private String description;
private UUID relatedRiskFactorId;
private ClassifierItemLightDto status;
private ObjectStatus objectStatus;
}
\ No newline at end of file
package ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.UUID;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PatchRiskStatementAssessmentDescriptionPublicDto {
@NotNull
private UUID riskStatementAssessmentId;
@NotNull
@Size(min = 3)
private String description;
}
package ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.request;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
import java.util.UUID;
public class DeleteRiskStatementAssessmentPublicRequest extends AbstractDTO<UUID, ErrorDTO> {
public static final String ROUTING_KEY = "api.DeleteRiskStatementAssessmentPublicRequest";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
package ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.request;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.dto.PatchRiskStatementAssessmentDescriptionPublicDto;
public class PatchRiskStatementAssessmentDescriptionPublicRequest extends AbstractDTO<PatchRiskStatementAssessmentDescriptionPublicDto, ErrorDTO> {
public static final String ROUTING_KEY = "api.PatchRiskStatementAssessmentDescriptionPublicRequest";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
package ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.response;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
public class DeleteRiskStatementAssessmentPublicResponse extends AbstractDTO<Void, ErrorDTO> {
public static final String ROUTING_KEY = "api.DeleteRiskStatementAssessmentPublicResponse";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
package ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.response;
import ee.sm.ti.teis.AbstractDTO;
import ee.sm.ti.teis.ErrorDTO;
import ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment.dto.RiskStatementAssessmentPublicDto;
public class PatchRiskStatementAssessmentDescriptionPublicResponse extends AbstractDTO<RiskStatementAssessmentPublicDto, ErrorDTO> {
public static final String ROUTING_KEY = "api.PatchRiskStatementAssessmentDescriptionPublicResponse";
@Override
public String routingKey() {
return ROUTING_KEY;
}
}
package ee.sm.ti.teis.commongateway.representative.authoritypermission;
import ee.sm.ti.teis.commongateway.CommonApiGatewayTestBase;
import ee.sm.ti.teis.gatewaycommon.error.NoResponseFromRabbitException;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import ee.sm.ti.teis.types.enums.AuthorityType;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import static java.util.UUID.randomUUID;
import static org.junit.jupiter.api.Assertions.assertThrows;
class AuthorityPermissionTestControllerTest extends CommonApiGatewayTestBase {
@Autowired
AuthorityPermissionTestController controller;
@Test
void validateAuthorityPermission_test() {
assertThrows(NoResponseFromRabbitException.class, () ->
controller.validate(randomUUID(), randomUUID(), AuthorityType.OH, new RequestMetaDTO()));
}
}
package ee.sm.ti.teis.commongateway.representative.authoritypermission;
import ee.sm.ti.teis.commongateway.representative.authoritypermission.dto.AuthorityPermissionExistsDto;
import ee.sm.ti.teis.commongateway.representative.authoritypermission.request.ValidateAuthorityPermissionRequest;
import ee.sm.ti.teis.commongateway.representative.authoritypermission.response.ValidateAuthorityPermissionResponse;
import ee.sm.ti.teis.gatewaycommon.error.NoResponseFromRabbitException;
import lombok.RequiredArgsConstructor;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;
@Service
@RequiredArgsConstructor
public class AuthorityPermissionProcessingService {
private final RabbitTemplate gwRabbitTemplate;
public AuthorityPermissionExistsDto validate(ValidateAuthorityPermissionRequest request) {
ValidateAuthorityPermissionResponse response =
(ValidateAuthorityPermissionResponse) gwRabbitTemplate.convertSendAndReceive(request.routingKey(), request);
if (response != null) {
return response.processResponse();
}
throw new NoResponseFromRabbitException(request.getRequestMetaDTO().getRequestId());
}
}
package ee.sm.ti.teis.commongateway.representative.authoritypermission;
import ee.sm.ti.teis.commongateway.representative.authoritypermission.dto.AuthorityPermissionExistsDto;
import ee.sm.ti.teis.commongateway.representative.authoritypermission.dto.ValidateAuthorityPermissionDto;
import ee.sm.ti.teis.commongateway.representative.authoritypermission.request.ValidateAuthorityPermissionRequest;
import ee.sm.ti.teis.gatewaycommon.controller.TeisBaseController;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
import ee.sm.ti.teis.types.enums.AuthorityType;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Profile;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
import java.util.UUID;
@Profile({"dev", "test", "local", "integtest"})
@RestController
@RequestMapping("representatives/authority-permissions")
@RequiredArgsConstructor
public class AuthorityPermissionTestController extends TeisBaseController {
private final AuthorityPermissionProcessingService service;
@ApiOperation(value = "${teis.api.representatives.authority-permissions.validate}", response = AuthorityPermissionExistsDto.class)
@ApiResponses(value = {
@ApiResponse(code = 400, message = "Sisend ei vasta nõuetele")})
@GetMapping("validate")
public AuthorityPermissionExistsDto validate(@RequestParam(name = "personId", required = true) UUID personId,
@RequestParam(name = "grantorId", required = true) UUID grantorId,
@RequestParam(name = "authorityType", required = true) AuthorityType authorityType,
@ApiIgnore RequestMetaDTO requestMetaDTO) {
ValidateAuthorityPermissionRequest request = new ValidateAuthorityPermissionRequest();
ValidateAuthorityPermissionDto dto = ValidateAuthorityPermissionDto.builder()
.personId(personId)
.grantorId(grantorId)
.authorityType(authorityType)
.build();
request.setPayload(dto, requestMetaDTO);
return service.validate(request);
}
}
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.gatewaycommon.controller.TeisBaseController;
import ee.sm.ti.teis.servicerequest.RequestMetaDTO;
......@@ -10,12 +13,7 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.UUID;
......@@ -59,4 +57,34 @@ public class RiskStatementAssessmentController extends TeisBaseController {
return service.createAssessment(request);
}
@ApiOperation(value = "${teis.api.risk-assessments.risk-statement-assessment.delete}")
@ApiResponses(value = {
@ApiResponse(code = 400, message = "Sisendi parameetrid ei vasta nõuetele"),
@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 deleteAssessment(@PathVariable UUID id, @ApiIgnore RequestMetaDTO requestMetaDTO) {
DeleteRiskStatementAssessmentPublicRequest request = new DeleteRiskStatementAssessmentPublicRequest();
request.setPayload(id, requestMetaDTO);
service.delete(request);
}
@ApiOperation(value = "${teis.api.risk-assessments.risk-statement-assessment.patch-description}",
response = RiskStatementAssessmentPublicDto.class)
@ApiResponses(value = {
@ApiResponse(code = 400, message = "Sisendi parameetrid ei vasta nõuetele"),
@ApiResponse(code = 403, message = "Kasutajal ei ole õigust andmeobjekti pärida"),
@ApiResponse(code = 404, message = "Sisendis esitatud andmetega objekti ei eksisteeri")})
@PatchMapping("{id}/description")
public RiskStatementAssessmentPublicDto updateDescription(@PathVariable UUID id,
@RequestBody PatchRiskStatementAssessmentDescriptionPublicDto dto,
@ApiIgnore RequestMetaDTO requestMetaDTO) {
PatchRiskStatementAssessmentDescriptionPublicRequest request = new PatchRiskStatementAssessmentDescriptionPublicRequest();
dto.setRiskStatementAssessmentId(id);
request.setPayload(dto, requestMetaDTO);
return service.updateDescription(request);
}
}
......@@ -2,8 +2,12 @@ package ee.sm.ti.teis.commongateway.riskassessments.riskstatementassessment;
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.gatewaycommon.error.NoResponseFromRabbitException;
import lombok.RequiredArgsConstructor;
......@@ -35,4 +39,25 @@ public class RiskStatementAssessmentProcessingService {
throw new NoResponseFromRabbitException(request.getRequestMetaDTO().getRequestId());
}
public void delete(DeleteRiskStatementAssessmentPublicRequest request) {
DeleteRiskStatementAssessmentPublicResponse response =
(DeleteRiskStatementAssessmentPublicResponse) gwRabbitTemplate.convertSendAndReceive(request.routingKey(), request);
if (response != null) {
response.processResponse();
return;
}
throw new NoResponseFromRabbitException(request.getRequestMetaDTO().getRequestId());
}
public RiskStatementAssessmentPublicDto updateDescription(PatchRiskStatementAssessmentDescriptionPublicRequest request) {
PatchRiskStatementAssessmentDescriptionPublicResponse response =
(PatchRiskStatementAssessmentDescriptionPublicResponse) gwRabbitTemplate.convertSendAndReceive(request.routingKey(), request);
if (response != null) {
return response.processResponse();
}
throw new NoResponseFromRabbitException(request.getRequestMetaDTO().getRequestId());
}
}
......@@ -139,6 +139,8 @@ teis.api.risk-assessments.risk-assessment.delete: Teenus kustutab riskianalüüs
teis.api.risk-assessments.risk-assessment.copy: Teenus loob uue riskianalüüsi olemasoleva riskianalüüsi kopeerimise teel.
teis.api.risk-assessments.risk-statement-assessment.patch: Teenus salvestab abinõu rakendamise vastuse (kas abinõu on rakendatud). Teenust kasutab iseteenindus, et salvestada kasutaja tehtud valikud.
teis.api.risk-assessments.risk-statement-assessment.patch-description: Teenus salvestab täiendavalt lisatud abinõu kirjelduse muudatuse. Teenust kasutab iseteenindus, et kasutaja saaks korrigeerida vigaselt sisestatud kirjeldust.
teis.api.risk-assessments.risk-statement-assessment.create: Teenus salvestab täiendava abinõu rakendamise andmed. Teenust kasutab iseteenindus, et salvestada kasutaja sisestatud täiendava abinõu rakendamise andmed.
teis.api.risk-assessments.risk-statement-assessment.delete: Teenus kustutab abinõu rakendamise väite kohta antud vastuse. Teenust kasutab iseteenindus, et kasutaja saaks kustutada ekslikult lisatud andmeobjekti.
teis.api.representatives.authority-permissions.validate: Test-teenus võimaldab kontrollida, kas ettevõttel on ligipääsu õigus teatud ettevõtte andmetele (nt kas töötervishoiu arst omab ligipääsu teatud ettevõtte andmetele).
theGroup=ee.sm.ti.teis
//commonApiGatewayVersion=forSearch ^commonApiGatewayVersion=.*?-SNAPSHOT
theVersion=1.10.0
commonsVersion=1.9.0
theVersion=1.11.0
commonsVersion=1.11.0
pluginVersion=1.1.1
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