Skip to content

Commit 260ff91

Browse files
committed
story(ccls-2143): add evidence doc types endpoint
1 parent 185383b commit 260ff91

File tree

13 files changed

+387
-17
lines changed

13 files changed

+387
-17
lines changed

data-api/open-api-specification.yml

+59-1
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,41 @@ paths:
703703
description: 'Not found'
704704
'500':
705705
description: 'Internal server error'
706+
/lookup/evidence-document-types:
707+
get:
708+
tags:
709+
- lookup
710+
summary: 'Get a list of evidence document type lookup values'
711+
description: Get a list of evidence document type lookup values which match the provided type
712+
and code.
713+
operationId: 'getEvidenceDocumentTypeLookupValues'
714+
x-spring-paginated: true
715+
parameters:
716+
- name: 'type'
717+
in: 'query'
718+
schema:
719+
type: 'string'
720+
example: 'XXCCMS_OPA_EVIDENCE_ITEMS'
721+
- name: 'code'
722+
in: 'query'
723+
schema:
724+
type: 'string'
725+
example: 'D'
726+
responses:
727+
'200':
728+
description: 'Successful operation'
729+
content:
730+
application/json:
731+
schema:
732+
$ref: "#/components/schemas/evidenceDocumentTypeLookupDetail"
733+
'400':
734+
description: 'Bad request'
735+
'401':
736+
description: 'Unauthorized'
737+
'404':
738+
description: 'Not found'
739+
'500':
740+
description: 'Internal server error'
706741
/lookup/common:
707742
get:
708743
tags:
@@ -1149,6 +1184,29 @@ components:
11491184
type: 'string'
11501185
mandatory_flag:
11511186
type: 'boolean'
1187+
evidenceDocumentTypeLookupValueDetail:
1188+
type: 'object'
1189+
properties:
1190+
type:
1191+
type: 'string'
1192+
code:
1193+
type: 'string'
1194+
description:
1195+
type: 'string'
1196+
start_date_active:
1197+
type: 'string'
1198+
end_date_active:
1199+
type: 'string'
1200+
evidenceDocumentTypeLookupDetail:
1201+
allOf:
1202+
- $ref: "#/components/schemas/page"
1203+
type: 'object'
1204+
properties:
1205+
content:
1206+
type: 'array'
1207+
default: []
1208+
items:
1209+
$ref: "#/components/schemas/evidenceDocumentTypeLookupValueDetail"
11521210
commonLookupValueDetail:
11531211
type: 'object'
11541212
properties:
@@ -1175,7 +1233,7 @@ components:
11751233
properties:
11761234
content:
11771235
type: 'array'
1178-
default: []
1236+
default: [ ]
11791237
items:
11801238
$ref: "#/components/schemas/commonLookupValueDetail"
11811239
relationshipToCaseLookupValueDetail:

data-service/src/integrationTest/java/uk/gov/laa/ccms/data/service/LookupServiceIntegrationTest.java

+28
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import uk.gov.laa.ccms.data.model.CaseStatusLookupDetail;
2121
import uk.gov.laa.ccms.data.model.CategoryOfLawLookupDetail;
2222
import uk.gov.laa.ccms.data.model.CommonLookupDetail;
23+
import uk.gov.laa.ccms.data.model.EvidenceDocumentTypeLookupDetail;
2324
import uk.gov.laa.ccms.data.model.OutcomeResultLookupDetail;
2425
import uk.gov.laa.ccms.data.model.RelationshipToCaseLookupDetail;
2526
import uk.gov.laa.ccms.data.model.StageEndLookupDetail;
@@ -313,4 +314,31 @@ public void testGetCategoriesOfLaw(String code, String desc, Boolean copyCostLim
313314
assertNotNull(result);
314315
assertEquals(expectedElements, result.getTotalElements());
315316
}
317+
318+
@ParameterizedTest
319+
@Sql(statements = {
320+
"INSERT INTO XXCCMS_EVIDENCE_DOC_TYPE_V (LOV_TYPE, CODE, DESCRIPTION) " +
321+
"VALUES ('TYPE1', 'CODE1', 'description 1')",
322+
"INSERT INTO XXCCMS_EVIDENCE_DOC_TYPE_V (LOV_TYPE, CODE, DESCRIPTION) " +
323+
"VALUES ('TYPE1', 'CODE2', 'description 2')",
324+
"INSERT INTO XXCCMS_EVIDENCE_DOC_TYPE_V (LOV_TYPE, CODE, DESCRIPTION) " +
325+
"VALUES ('TYPE2', 'CODE2', 'description 3')",
326+
})
327+
@CsvSource(value= {
328+
"TYPE1, null, 2",
329+
"TYPE1, CODE2, 1",
330+
"null, CODE2, 2"},
331+
nullValues={"null"})
332+
public void testGetEvidenceDocumentTypes(String type, String code, Integer expectedElements) {
333+
// Create a pageable object
334+
Pageable pageable = PageRequest.of(0, 10);
335+
336+
// Call the service method
337+
EvidenceDocumentTypeLookupDetail result = lookupService.getEvidenceDocumentTypeLookupValues(
338+
type, code, pageable);
339+
340+
// Assert the result
341+
assertNotNull(result);
342+
assertEquals(expectedElements, result.getTotalElements());
343+
}
316344
}

data-service/src/integrationTest/resources/sql/lookup_create_schema.sql

+8
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,12 @@ CREATE TABLE XXCCMS_CATEGORY_OF_LAW_V (
7676
CATEGORY_OF_LAW_CODE VARCHAR2(30),
7777
MATTER_TYPE_DESCRIPTION VARCHAR2(80),
7878
COPY_COST_LIMIT_IND VARCHAR2(150)
79+
);
80+
81+
CREATE TABLE XXCCMS_EVIDENCE_DOC_TYPE_V (
82+
LOV_TYPE VARCHAR2(30),
83+
CODE VARCHAR2(30),
84+
DESCRIPTION VARCHAR2(80),
85+
START_DATE_ACTIVE DATE,
86+
END_DATE_ACTIVE DATE
7987
);

data-service/src/integrationTest/resources/sql/lookup_drop_schema.sql

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ DROP TABLE XXCCMS_PER_RELTOCASE_V;
88
DROP TABLE XXCCMS_ORG_RELTOCASE_V;
99
DROP TABLE XXCCMS_AWARD_TYPE_V;
1010
DROP TABLE XXCCMS_CATEGORY_OF_LAW_V;
11+
DROP TABLE XXCCMS_EVIDENCE_DOC_TYPE_V;

data-service/src/main/java/uk/gov/laa/ccms/data/controller/LookupController.java

+19
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import uk.gov.laa.ccms.data.model.CategoryOfLawLookupDetail;
1212
import uk.gov.laa.ccms.data.model.ClientInvolvementTypeLookupDetail;
1313
import uk.gov.laa.ccms.data.model.CommonLookupDetail;
14+
import uk.gov.laa.ccms.data.model.EvidenceDocumentTypeLookupDetail;
1415
import uk.gov.laa.ccms.data.model.LevelOfServiceLookupDetail;
1516
import uk.gov.laa.ccms.data.model.MatterTypeLookupDetail;
1617
import uk.gov.laa.ccms.data.model.OutcomeResultLookupDetail;
@@ -281,4 +282,22 @@ public ResponseEntity<CategoryOfLawLookupDetail> getCategoryOfLawLookupValues(
281282
return ResponseEntity.ok(lookupService.getCategoryOfLawLookupValues(
282283
code, matterTypeDescription, copyCostLimit, pageable));
283284
}
285+
286+
/**
287+
* GET evidence document type lookup values by type and code.
288+
*
289+
* @param type the type of lookup value
290+
* @param code the evidence document type code
291+
* @param pageable pagination information
292+
* @return the ResponseEntity with status 200 (OK) and the list of evidence document type
293+
* values in the body.
294+
*/
295+
@Override
296+
public ResponseEntity<EvidenceDocumentTypeLookupDetail> getEvidenceDocumentTypeLookupValues(
297+
String type,
298+
String code,
299+
Pageable pageable) {
300+
return ResponseEntity.ok(lookupService.getEvidenceDocumentTypeLookupValues(
301+
type, code, pageable));
302+
}
284303
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package uk.gov.laa.ccms.data.entity;
2+
3+
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
4+
import com.fasterxml.jackson.databind.annotation.JsonNaming;
5+
import jakarta.persistence.Column;
6+
import jakarta.persistence.EmbeddedId;
7+
import jakarta.persistence.Entity;
8+
import jakarta.persistence.Table;
9+
import java.io.Serializable;
10+
import java.time.LocalDateTime;
11+
import lombok.Data;
12+
import lombok.NoArgsConstructor;
13+
import org.hibernate.annotations.Immutable;
14+
15+
16+
/**
17+
* Represents a evidence document type lookup value entity.
18+
*
19+
* <p>This entity corresponds to the "XXCCMS_EVIDENCE_DOC_TYPE_V" view in the database and is used
20+
* for evidence document type lookup values. Each record is uniquely identified by its type and
21+
* code, both serving as composite primary keys.</p>
22+
*
23+
* <p>This entity is immutable, meaning its state cannot be changed once it's created.</p>
24+
*
25+
* @see PropertyNamingStrategies.SnakeCaseStrategy
26+
*/
27+
@Data
28+
@Entity
29+
@NoArgsConstructor
30+
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
31+
@Table(name = "XXCCMS_EVIDENCE_DOC_TYPE_V")
32+
@Immutable
33+
public class EvidenceDocumentTypeLookupValue implements Serializable {
34+
35+
@EmbeddedId
36+
private EvidenceDocumentTypeLookupValueId id;
37+
38+
@Column(name = "DESCRIPTION")
39+
private String description;
40+
41+
@Column(name = "START_DATE_ACTIVE")
42+
private LocalDateTime startDateActive;
43+
44+
@Column(name = "END_DATE_ACTIVE")
45+
private LocalDateTime endDateActive;
46+
}
47+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package uk.gov.laa.ccms.data.entity;
2+
3+
import jakarta.persistence.Column;
4+
import java.io.Serializable;
5+
import lombok.AllArgsConstructor;
6+
import lombok.Data;
7+
import lombok.NoArgsConstructor;
8+
import org.hibernate.annotations.Immutable;
9+
10+
11+
/**
12+
* Represents the composite primary key for the {@link EvidenceDocumentTypeLookupValue} entity.
13+
*
14+
* <p>This class is used to uniquely identify each record in the associated evidence
15+
* document type lookup value entity. The combination of the lookup value type and its code
16+
* forms the composite key.</p>
17+
*
18+
* <p>The class is marked as immutable, ensuring the integrity and consistency of the identifier
19+
* once it's created.</p>
20+
*
21+
* @see EvidenceDocumentTypeLookupValue
22+
*/
23+
@Data
24+
@NoArgsConstructor
25+
@AllArgsConstructor
26+
@Immutable
27+
public class EvidenceDocumentTypeLookupValueId implements Serializable {
28+
29+
@Column(name = "LOV_TYPE")
30+
private String type;
31+
32+
@Column(name = "CODE")
33+
private String code;
34+
35+
}

data-service/src/main/java/uk/gov/laa/ccms/data/mapper/LookupMapper.java

+11
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import uk.gov.laa.ccms.data.entity.CategoryOfLawLookupValue;
1010
import uk.gov.laa.ccms.data.entity.CommonLookupValue;
1111
import uk.gov.laa.ccms.data.entity.CountryLookupValue;
12+
import uk.gov.laa.ccms.data.entity.EvidenceDocumentTypeLookupValue;
1213
import uk.gov.laa.ccms.data.entity.LevelOfService;
1314
import uk.gov.laa.ccms.data.entity.MatterType;
1415
import uk.gov.laa.ccms.data.entity.OrganisationRelationshipToCaseLookupValue;
@@ -27,6 +28,8 @@
2728
import uk.gov.laa.ccms.data.model.ClientInvolvementTypeLookupValueDetail;
2829
import uk.gov.laa.ccms.data.model.CommonLookupDetail;
2930
import uk.gov.laa.ccms.data.model.CommonLookupValueDetail;
31+
import uk.gov.laa.ccms.data.model.EvidenceDocumentTypeLookupDetail;
32+
import uk.gov.laa.ccms.data.model.EvidenceDocumentTypeLookupValueDetail;
3033
import uk.gov.laa.ccms.data.model.LevelOfServiceLookupDetail;
3134
import uk.gov.laa.ccms.data.model.LevelOfServiceLookupValueDetail;
3235
import uk.gov.laa.ccms.data.model.MatterTypeLookupDetail;
@@ -131,4 +134,12 @@ CategoryOfLawLookupDetail toCategoryOfLawLookupDetail(
131134
CategoryOfLawLookupValueDetail toCategoryOfLawLookupValueDetail(
132135
CategoryOfLawLookupValue categoryOfLawLookupValue);
133136

137+
EvidenceDocumentTypeLookupDetail toEvidenceDocumentTypeLookupDetail(
138+
Page<EvidenceDocumentTypeLookupValue> evidenceDocumentTypeLookupValues);
139+
140+
@Mapping(target = "type", source = "id.type")
141+
@Mapping(target = "code", source = "id.code")
142+
EvidenceDocumentTypeLookupValueDetail toEvidenceDocumentTypeLookupValueDetail(
143+
EvidenceDocumentTypeLookupValue evidenceDocumentTypeLookupValue);
144+
134145
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package uk.gov.laa.ccms.data.repository;
2+
3+
import org.springframework.stereotype.Repository;
4+
import uk.gov.laa.ccms.data.entity.EvidenceDocumentTypeLookupValue;
5+
6+
7+
/**
8+
* This is a Spring repository for EvidenceDocumentTypeLookupValue entity operations.
9+
* It extends ReadOnlyRepository interface for providing basic read-only operations on
10+
* EvidenceDocumentTypeLookupValue entities. The primary key for EvidenceDocumentTypeLookupValue
11+
* entity is CommonLookupValueId.
12+
* It is annotated with @Repository, which makes it a part of the Spring framework's
13+
* persistence layer.
14+
*
15+
* @Repository allows for exception translation into Spring's DataAccessException hierarchy.
16+
*/
17+
@Repository
18+
public interface EvidenceDocumentTypeLookupValueRepository
19+
extends ReadOnlyRepository<EvidenceDocumentTypeLookupValue, EvidenceDocumentTypeLookupValue> {
20+
21+
}

0 commit comments

Comments
 (0)