diff --git a/data-api/open-api-specification.yml b/data-api/open-api-specification.yml index 6dba006..2a0c887 100644 --- a/data-api/open-api-specification.yml +++ b/data-api/open-api-specification.yml @@ -1480,6 +1480,11 @@ components: type: 'string' file_upload_prompt: type: 'string' + data_items: + type: 'array' + default: [ ] + items: + $ref: "#/components/schemas/providerRequestDataLookupValueDetail" providerRequestTypeLookupDetail: allOf: - $ref: "#/components/schemas/page" @@ -1490,6 +1495,21 @@ components: default: [ ] items: $ref: "#/components/schemas/providerRequestTypeLookupValueDetail" + providerRequestDataLookupValueDetail: + type: 'object' + properties: + code: + type: 'string' + label: + type: 'string' + type: + type: 'string' + mandatory_flag: + type: 'boolean' + sequence: + type: 'string' + lov_lookup_type: + type: 'string' page: type: 'object' properties: diff --git a/data-service/src/integrationTest/resources/sql/lookup_create_schema.sql b/data-service/src/integrationTest/resources/sql/lookup_create_schema.sql index a7f2bc0..e2ffe51 100644 --- a/data-service/src/integrationTest/resources/sql/lookup_create_schema.sql +++ b/data-service/src/integrationTest/resources/sql/lookup_create_schema.sql @@ -120,3 +120,16 @@ CREATE TABLE XXCCMS_PROVIDER_REQTYPES_V ( FILE_UPLD_PROMPT VARCHAR(255) ); +CREATE TABLE XXCCMS_PROVIDER_REQUEST_DATA_V ( + REQUEST_TYPE VARCHAR(255) NOT NULL, + DATA_ITEM_CODE VARCHAR(255) NOT NULL, + DATA_ITEM_LABEL VARCHAR(255), + DATA_ITEM_TYPE VARCHAR(255) NOT NULL, + MANDATORY_FLAG VARCHAR(255) NOT NULL, + DATA_ITEM_SEQ VARCHAR(255) NOT NULL, + LOV_LOOKUP_TYPE VARCHAR(255), + PRIMARY KEY (REQUEST_TYPE, DATA_ITEM_CODE) +); + + + diff --git a/data-service/src/integrationTest/resources/sql/lookup_drop_schema.sql b/data-service/src/integrationTest/resources/sql/lookup_drop_schema.sql index 23a381f..5b097b7 100644 --- a/data-service/src/integrationTest/resources/sql/lookup_drop_schema.sql +++ b/data-service/src/integrationTest/resources/sql/lookup_drop_schema.sql @@ -12,6 +12,7 @@ DROP TABLE XXCCMS_EVIDENCE_DOC_TYPE_V; DROP TABLE XXCCMS_PUI_OPA_ENTITIES_V; DROP TABLE XXCCMS_PUI_OPA_ATTRIBUTE_V; DROP TABLE XXCCMS_PROVIDER_REQTYPES_V; +DROP TABLE XXCCMS_PROVIDER_REQUEST_DATA_V; diff --git a/data-service/src/main/java/uk/gov/laa/ccms/data/entity/ProviderRequestData.java b/data-service/src/main/java/uk/gov/laa/ccms/data/entity/ProviderRequestData.java new file mode 100644 index 0000000..6709161 --- /dev/null +++ b/data-service/src/main/java/uk/gov/laa/ccms/data/entity/ProviderRequestData.java @@ -0,0 +1,51 @@ +package uk.gov.laa.ccms.data.entity; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import jakarta.persistence.Column; +import jakarta.persistence.EmbeddedId; +import jakarta.persistence.Entity; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.hibernate.annotations.Immutable; + +/** + * Entity representing the provider request data. + */ +@Entity +@Table(name = "XXCCMS_PROVIDER_REQUEST_DATA_V") +@Data +@NoArgsConstructor +@Immutable +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +public class ProviderRequestData implements Serializable { + + @EmbeddedId + private ProviderRequestDataId id; + + @Column(name = "data_item_label") + private String dataItemLabel; + + @Column(name = "data_item_type", nullable = false) + private String dataItemType; + + @Column(name = "mandatory_flag", nullable = false) + private String mandatoryFlag; + + @Column(name = "data_item_seq", nullable = false) + private String dataItemSeq; + + @Column(name = "lov_lookup_type") + private String lovLookupType; + + @ManyToOne + @JoinColumn(name = "REQUEST_TYPE") + private ProviderRequestType providerRequestType; + + + +} diff --git a/data-service/src/main/java/uk/gov/laa/ccms/data/entity/ProviderRequestDataId.java b/data-service/src/main/java/uk/gov/laa/ccms/data/entity/ProviderRequestDataId.java new file mode 100644 index 0000000..4986f51 --- /dev/null +++ b/data-service/src/main/java/uk/gov/laa/ccms/data/entity/ProviderRequestDataId.java @@ -0,0 +1,22 @@ +package uk.gov.laa.ccms.data.entity; + +import jakarta.persistence.Column; +import java.io.Serializable; +import lombok.Data; +import org.hibernate.annotations.Immutable; + +/** + * Composite ID class for provider request data. + */ +@Data +@Immutable +public class ProviderRequestDataId implements Serializable { + + + @Column(name = "request_type", nullable = false, insertable = false, updatable = false) + private String requestType; + + @Column(name = "data_item_code", nullable = false) + private String dataItemCode; + +} diff --git a/data-service/src/main/java/uk/gov/laa/ccms/data/entity/ProviderRequestType.java b/data-service/src/main/java/uk/gov/laa/ccms/data/entity/ProviderRequestType.java index dcb152a..560b9da 100644 --- a/data-service/src/main/java/uk/gov/laa/ccms/data/entity/ProviderRequestType.java +++ b/data-service/src/main/java/uk/gov/laa/ccms/data/entity/ProviderRequestType.java @@ -4,8 +4,11 @@ import com.fasterxml.jackson.databind.annotation.JsonNaming; import jakarta.persistence.Column; import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; import jakarta.persistence.Id; +import jakarta.persistence.OneToMany; import jakarta.persistence.Table; +import java.util.List; import lombok.Data; import lombok.NoArgsConstructor; import org.hibernate.annotations.Immutable; @@ -49,5 +52,8 @@ public class ProviderRequestType { @Column(name = "FILE_UPLD_PROMPT") private String fileUploadPrompt; + @OneToMany(mappedBy = "providerRequestType", fetch = FetchType.EAGER) + private List providerRequestData; + } diff --git a/data-service/src/main/java/uk/gov/laa/ccms/data/mapper/LookupMapper.java b/data-service/src/main/java/uk/gov/laa/ccms/data/mapper/LookupMapper.java index d6d9fa3..2b6f4dc 100644 --- a/data-service/src/main/java/uk/gov/laa/ccms/data/mapper/LookupMapper.java +++ b/data-service/src/main/java/uk/gov/laa/ccms/data/mapper/LookupMapper.java @@ -19,6 +19,7 @@ import uk.gov.laa.ccms.data.entity.OutcomeResultLookupValue; import uk.gov.laa.ccms.data.entity.PersonRelationshipToCaseLookupValue; import uk.gov.laa.ccms.data.entity.ProceedingClientInvolvementType; +import uk.gov.laa.ccms.data.entity.ProviderRequestData; import uk.gov.laa.ccms.data.entity.ProviderRequestType; import uk.gov.laa.ccms.data.entity.StageEndLookupValue; import uk.gov.laa.ccms.data.model.AmendmentTypeLookupDetail; @@ -44,6 +45,7 @@ import uk.gov.laa.ccms.data.model.MatterTypeLookupDetail; import uk.gov.laa.ccms.data.model.OutcomeResultLookupDetail; import uk.gov.laa.ccms.data.model.OutcomeResultLookupValueDetail; +import uk.gov.laa.ccms.data.model.ProviderRequestDataLookupValueDetail; import uk.gov.laa.ccms.data.model.ProviderRequestTypeLookupDetail; import uk.gov.laa.ccms.data.model.ProviderRequestTypeLookupValueDetail; import uk.gov.laa.ccms.data.model.RelationshipToCaseLookupDetail; @@ -181,9 +183,18 @@ ProviderRequestTypeLookupDetail toProviderRequestTypeLookupDetail( @Mapping(source = "caseRelated", target = "isCaseRelated") @Mapping(source = "additionalInformationPrompt", target = "additionalInformationPrompt") @Mapping(source = "fileUploadEnabled", target = "isFileUploadEnabled") + @Mapping(source = "providerRequestData", target = "dataItems") ProviderRequestTypeLookupValueDetail toProviderRequestTypeLookupValueDetail( ProviderRequestType providerRequestType); + @Mapping(source = "id.dataItemCode", target = "code") + @Mapping(source = "dataItemLabel", target = "label") + @Mapping(source = "dataItemType", target = "type") + @Mapping(source = "dataItemSeq", target = "sequence") + ProviderRequestDataLookupValueDetail toProviderRequestDataLookupValueDetail( + ProviderRequestData providerRequestData); + + } \ No newline at end of file diff --git a/data-service/src/test/java/uk/gov/laa/ccms/data/mapper/LookupMapperImplTest.java b/data-service/src/test/java/uk/gov/laa/ccms/data/mapper/LookupMapperImplTest.java index a99af5e..8e5cb64 100644 --- a/data-service/src/test/java/uk/gov/laa/ccms/data/mapper/LookupMapperImplTest.java +++ b/data-service/src/test/java/uk/gov/laa/ccms/data/mapper/LookupMapperImplTest.java @@ -1097,6 +1097,7 @@ void toProviderRequestTypeLookupValueDetail_returnsCorrectDetail() { providerRequestType.setTaskTypeId("123"); providerRequestType.setAccessFunctionCode("accessCode"); providerRequestType.setFileUploadPrompt("File upload"); + providerRequestType.setProviderRequestData(new ArrayList<>()); ProviderRequestTypeLookupValueDetail expected = new ProviderRequestTypeLookupValueDetail(); expected.setIsCaseRelated(providerRequestType.getCaseRelated());