Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

story(ccls-2143): add evidence doc types endpoint #92

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 59 additions & 1 deletion data-api/open-api-specification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,41 @@ paths:
description: 'Not found'
'500':
description: 'Internal server error'
/lookup/evidence-document-types:
get:
tags:
- lookup
summary: 'Get a list of evidence document type lookup values'
description: Get a list of evidence document type lookup values which match the provided type
and code.
operationId: 'getEvidenceDocumentTypeLookupValues'
x-spring-paginated: true
parameters:
- name: 'type'
in: 'query'
schema:
type: 'string'
example: 'XXCCMS_OPA_EVIDENCE_ITEMS'
- name: 'code'
in: 'query'
schema:
type: 'string'
example: 'D'
responses:
'200':
description: 'Successful operation'
content:
application/json:
schema:
$ref: "#/components/schemas/evidenceDocumentTypeLookupDetail"
'400':
description: 'Bad request'
'401':
description: 'Unauthorized'
'404':
description: 'Not found'
'500':
description: 'Internal server error'
/lookup/common:
get:
tags:
Expand Down Expand Up @@ -1149,6 +1184,29 @@ components:
type: 'string'
mandatory_flag:
type: 'boolean'
evidenceDocumentTypeLookupValueDetail:
type: 'object'
properties:
type:
type: 'string'
code:
type: 'string'
description:
type: 'string'
start_date_active:
type: 'string'
end_date_active:
type: 'string'
evidenceDocumentTypeLookupDetail:
allOf:
- $ref: "#/components/schemas/page"
type: 'object'
properties:
content:
type: 'array'
default: []
items:
$ref: "#/components/schemas/evidenceDocumentTypeLookupValueDetail"
commonLookupValueDetail:
type: 'object'
properties:
Expand All @@ -1175,7 +1233,7 @@ components:
properties:
content:
type: 'array'
default: []
default: [ ]
items:
$ref: "#/components/schemas/commonLookupValueDetail"
relationshipToCaseLookupValueDetail:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import uk.gov.laa.ccms.data.model.CaseStatusLookupDetail;
import uk.gov.laa.ccms.data.model.CategoryOfLawLookupDetail;
import uk.gov.laa.ccms.data.model.CommonLookupDetail;
import uk.gov.laa.ccms.data.model.EvidenceDocumentTypeLookupDetail;
import uk.gov.laa.ccms.data.model.OutcomeResultLookupDetail;
import uk.gov.laa.ccms.data.model.RelationshipToCaseLookupDetail;
import uk.gov.laa.ccms.data.model.StageEndLookupDetail;
Expand Down Expand Up @@ -313,4 +314,31 @@ public void testGetCategoriesOfLaw(String code, String desc, Boolean copyCostLim
assertNotNull(result);
assertEquals(expectedElements, result.getTotalElements());
}

@ParameterizedTest
@Sql(statements = {
"INSERT INTO XXCCMS_EVIDENCE_DOC_TYPE_V (LOV_TYPE, CODE, DESCRIPTION) " +
"VALUES ('TYPE1', 'CODE1', 'description 1')",
"INSERT INTO XXCCMS_EVIDENCE_DOC_TYPE_V (LOV_TYPE, CODE, DESCRIPTION) " +
"VALUES ('TYPE1', 'CODE2', 'description 2')",
"INSERT INTO XXCCMS_EVIDENCE_DOC_TYPE_V (LOV_TYPE, CODE, DESCRIPTION) " +
"VALUES ('TYPE2', 'CODE2', 'description 3')",
})
@CsvSource(value= {
"TYPE1, null, 2",
"TYPE1, CODE2, 1",
"null, CODE2, 2"},
nullValues={"null"})
public void testGetEvidenceDocumentTypes(String type, String code, Integer expectedElements) {
// Create a pageable object
Pageable pageable = PageRequest.of(0, 10);

// Call the service method
EvidenceDocumentTypeLookupDetail result = lookupService.getEvidenceDocumentTypeLookupValues(
type, code, pageable);

// Assert the result
assertNotNull(result);
assertEquals(expectedElements, result.getTotalElements());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,12 @@ CREATE TABLE XXCCMS_CATEGORY_OF_LAW_V (
CATEGORY_OF_LAW_CODE VARCHAR2(30),
MATTER_TYPE_DESCRIPTION VARCHAR2(80),
COPY_COST_LIMIT_IND VARCHAR2(150)
);

CREATE TABLE XXCCMS_EVIDENCE_DOC_TYPE_V (
LOV_TYPE VARCHAR2(30),
CODE VARCHAR2(30),
DESCRIPTION VARCHAR2(80),
START_DATE_ACTIVE DATE,
END_DATE_ACTIVE DATE
);
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ DROP TABLE XXCCMS_PER_RELTOCASE_V;
DROP TABLE XXCCMS_ORG_RELTOCASE_V;
DROP TABLE XXCCMS_AWARD_TYPE_V;
DROP TABLE XXCCMS_CATEGORY_OF_LAW_V;
DROP TABLE XXCCMS_EVIDENCE_DOC_TYPE_V;
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import uk.gov.laa.ccms.data.model.CategoryOfLawLookupDetail;
import uk.gov.laa.ccms.data.model.ClientInvolvementTypeLookupDetail;
import uk.gov.laa.ccms.data.model.CommonLookupDetail;
import uk.gov.laa.ccms.data.model.EvidenceDocumentTypeLookupDetail;
import uk.gov.laa.ccms.data.model.LevelOfServiceLookupDetail;
import uk.gov.laa.ccms.data.model.MatterTypeLookupDetail;
import uk.gov.laa.ccms.data.model.OutcomeResultLookupDetail;
Expand Down Expand Up @@ -281,4 +282,22 @@ public ResponseEntity<CategoryOfLawLookupDetail> getCategoryOfLawLookupValues(
return ResponseEntity.ok(lookupService.getCategoryOfLawLookupValues(
code, matterTypeDescription, copyCostLimit, pageable));
}

/**
* GET evidence document type lookup values by type and code.
*
* @param type the type of lookup value
* @param code the evidence document type code
* @param pageable pagination information
* @return the ResponseEntity with status 200 (OK) and the list of evidence document type
* values in the body.
*/
@Override
public ResponseEntity<EvidenceDocumentTypeLookupDetail> getEvidenceDocumentTypeLookupValues(
String type,
String code,
Pageable pageable) {
return ResponseEntity.ok(lookupService.getEvidenceDocumentTypeLookupValues(
type, code, pageable));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
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.Table;
import java.io.Serializable;
import java.time.LocalDateTime;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Immutable;


/**
* Represents a evidence document type lookup value entity.
*
* <p>This entity corresponds to the "XXCCMS_EVIDENCE_DOC_TYPE_V" view in the database and is used
* for evidence document type lookup values. Each record is uniquely identified by its type and
* code, both serving as composite primary keys.</p>
*
* <p>This entity is immutable, meaning its state cannot be changed once it's created.</p>
*
* @see PropertyNamingStrategies.SnakeCaseStrategy
*/
@Data
@Entity
@NoArgsConstructor
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
@Table(name = "XXCCMS_EVIDENCE_DOC_TYPE_V")
@Immutable
public class EvidenceDocumentTypeLookupValue implements Serializable {

@EmbeddedId
private EvidenceDocumentTypeLookupValueId id;

@Column(name = "DESCRIPTION")
private String description;

@Column(name = "START_DATE_ACTIVE")
private LocalDateTime startDateActive;

@Column(name = "END_DATE_ACTIVE")
private LocalDateTime endDateActive;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package uk.gov.laa.ccms.data.entity;

import jakarta.persistence.Column;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.Immutable;


/**
* Represents the composite primary key for the {@link EvidenceDocumentTypeLookupValue} entity.
*
* <p>This class is used to uniquely identify each record in the associated evidence
* document type lookup value entity. The combination of the lookup value type and its code
* forms the composite key.</p>
*
* <p>The class is marked as immutable, ensuring the integrity and consistency of the identifier
* once it's created.</p>
*
* @see EvidenceDocumentTypeLookupValue
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Immutable
public class EvidenceDocumentTypeLookupValueId implements Serializable {

@Column(name = "LOV_TYPE")
private String type;

@Column(name = "CODE")
private String code;

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import uk.gov.laa.ccms.data.entity.CategoryOfLawLookupValue;
import uk.gov.laa.ccms.data.entity.CommonLookupValue;
import uk.gov.laa.ccms.data.entity.CountryLookupValue;
import uk.gov.laa.ccms.data.entity.EvidenceDocumentTypeLookupValue;
import uk.gov.laa.ccms.data.entity.LevelOfService;
import uk.gov.laa.ccms.data.entity.MatterType;
import uk.gov.laa.ccms.data.entity.OrganisationRelationshipToCaseLookupValue;
Expand All @@ -27,6 +28,8 @@
import uk.gov.laa.ccms.data.model.ClientInvolvementTypeLookupValueDetail;
import uk.gov.laa.ccms.data.model.CommonLookupDetail;
import uk.gov.laa.ccms.data.model.CommonLookupValueDetail;
import uk.gov.laa.ccms.data.model.EvidenceDocumentTypeLookupDetail;
import uk.gov.laa.ccms.data.model.EvidenceDocumentTypeLookupValueDetail;
import uk.gov.laa.ccms.data.model.LevelOfServiceLookupDetail;
import uk.gov.laa.ccms.data.model.LevelOfServiceLookupValueDetail;
import uk.gov.laa.ccms.data.model.MatterTypeLookupDetail;
Expand Down Expand Up @@ -131,4 +134,12 @@ CategoryOfLawLookupDetail toCategoryOfLawLookupDetail(
CategoryOfLawLookupValueDetail toCategoryOfLawLookupValueDetail(
CategoryOfLawLookupValue categoryOfLawLookupValue);

EvidenceDocumentTypeLookupDetail toEvidenceDocumentTypeLookupDetail(
Page<EvidenceDocumentTypeLookupValue> evidenceDocumentTypeLookupValues);

@Mapping(target = "type", source = "id.type")
@Mapping(target = "code", source = "id.code")
EvidenceDocumentTypeLookupValueDetail toEvidenceDocumentTypeLookupValueDetail(
EvidenceDocumentTypeLookupValue evidenceDocumentTypeLookupValue);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package uk.gov.laa.ccms.data.repository;

import org.springframework.stereotype.Repository;
import uk.gov.laa.ccms.data.entity.EvidenceDocumentTypeLookupValue;


/**
* This is a Spring repository for EvidenceDocumentTypeLookupValue entity operations.
* It extends ReadOnlyRepository interface for providing basic read-only operations on
* EvidenceDocumentTypeLookupValue entities. The primary key for EvidenceDocumentTypeLookupValue
* entity is CommonLookupValueId.
* It is annotated with @Repository, which makes it a part of the Spring framework's
* persistence layer.
*
* @Repository allows for exception translation into Spring's DataAccessException hierarchy.
*/
@Repository
public interface EvidenceDocumentTypeLookupValueRepository
extends ReadOnlyRepository<EvidenceDocumentTypeLookupValue, EvidenceDocumentTypeLookupValue> {

}
Loading
Loading