Skip to content

Commit

Permalink
Story/ccls 1849 cat of law (#51)
Browse files Browse the repository at this point in the history
* story(ccls-1878): add /users endpoint

* story(ccls-1849): add category of law endpoint
  • Loading branch information
porritta authored Oct 13, 2023
1 parent c59f400 commit 7a74018
Show file tree
Hide file tree
Showing 12 changed files with 341 additions and 24 deletions.
104 changes: 80 additions & 24 deletions data-api/open-api-specification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -475,40 +475,31 @@ paths:
description: 'Not found'
'500':
description: 'Internal server error'
/lookup/common:
/lookup/person-to-case-relationships:
get:
tags:
- lookup
summary: 'Get a list of common lookup values'
description: Get a list of common lookup values which match the provided type, code and
description.
Include a '*' at the beginning and/or end of query params to perform a wildcard
search.
operationId: 'getCommonLookupValues'
summary: 'Get person to case relationship lookup values'
operationId: 'getPersonToCaseRelationshipLookupValues'
x-spring-paginated: true
parameters:
- name: 'type'
in: 'query'
schema:
type: 'string'
example: 'CONTACT_TITLE'
- name: 'code'
in: 'query'
schema:
type: 'string'
example: 'D'
example: 'AGENT'
- name: 'description'
in: 'query'
schema:
type: 'string'
example: 'abc'
example: 'Agent'
responses:
'200':
description: 'Successful operation'
content:
application/json:
schema:
$ref: "#/components/schemas/commonLookupDetail"
$ref: "#/components/schemas/relationshipToCaseLookupDetail"
'400':
description: 'Bad request'
'401':
Expand All @@ -517,12 +508,12 @@ paths:
description: 'Not found'
'500':
description: 'Internal server error'
/lookup/person-to-case-relationships:
/lookup/organisation-to-case-relationships:
get:
tags:
- lookup
summary: 'Get person to case relationship lookup values'
operationId: 'getPersonToCaseRelationshipLookupValues'
summary: 'Get organisation to case relationship lookup values'
operationId: 'getOrganisationToCaseRelationshipLookupValues'
x-spring-paginated: true
parameters:
- name: 'code'
Expand Down Expand Up @@ -550,31 +541,78 @@ paths:
description: 'Not found'
'500':
description: 'Internal server error'
/lookup/organisation-to-case-relationships:
/lookup/categories-of-law:
get:
tags:
- lookup
summary: 'Get organisation to case relationship lookup values'
operationId: 'getOrganisationToCaseRelationshipLookupValues'
summary: 'Get Category Of Law Lookup Values'
operationId: 'getCategoryOfLawLookupValues'
x-spring-paginated: true
parameters:
- name: 'code'
in: 'query'
schema:
type: 'string'
example: 'AGENT'
example: 'ABC'
- name: 'matter-type-description'
in: 'query'
schema:
type: 'string'
example: 'ABC'
- name: 'copy-cost-limit'
in: 'query'
schema:
type: 'boolean'
example: 'true'
responses:
'200':
description: 'Successful operation'
content:
application/json:
schema:
$ref: "#/components/schemas/categoryOfLawLookupDetail"
'400':
description: 'Bad request'
'401':
description: 'Unauthorized'
'404':
description: 'Not found'
'500':
description: 'Internal server error'
/lookup/common:
get:
tags:
- lookup
summary: 'Get a list of common lookup values'
description: Get a list of common lookup values which match the provided type, code and
description.
Include a '*' at the beginning and/or end of query params to perform a wildcard
search.
operationId: 'getCommonLookupValues'
x-spring-paginated: true
parameters:
- name: 'type'
in: 'query'
schema:
type: 'string'
example: 'CONTACT_TITLE'
- name: 'code'
in: 'query'
schema:
type: 'string'
example: 'D'
- name: 'description'
in: 'query'
schema:
type: 'string'
example: 'Agent'
example: 'abc'
responses:
'200':
description: 'Successful operation'
content:
application/json:
schema:
$ref: "#/components/schemas/relationshipToCaseLookupDetail"
$ref: "#/components/schemas/commonLookupDetail"
'400':
description: 'Bad request'
'401':
Expand Down Expand Up @@ -815,6 +853,24 @@ components:
type: 'string'
enabled:
type: 'boolean'
categoryOfLawLookupDetail:
allOf:
- $ref: "#/components/schemas/page"
type: 'object'
properties:
content:
type: 'array'
items:
$ref: '#/components/schemas/categoryOfLawLookupValueDetail'
categoryOfLawLookupValueDetail:
type: 'object'
properties:
code:
type: 'string'
matter_type_description:
type: 'string'
copy_cost_limit:
type: 'boolean'
scopeLimitationDetails:
allOf:
- $ref: "#/components/schemas/page"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import uk.gov.laa.ccms.data.AbstractIntegrationTest;
import uk.gov.laa.ccms.data.model.AwardTypeLookupDetail;
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.OutcomeResultLookupDetail;
import uk.gov.laa.ccms.data.model.RelationshipToCaseLookupDetail;
Expand Down Expand Up @@ -285,4 +286,31 @@ public void testGetAwardTypes(String code, String awardType, Integer expectedEle
assertNotNull(result);
assertEquals(expectedElements, result.getTotalElements());
}

@ParameterizedTest
@Sql(statements = {
"INSERT INTO XXCCMS_CATEGORY_OF_LAW_V (CATEGORY_OF_LAW_CODE, MATTER_TYPE_DESCRIPTION, COPY_COST_LIMIT_IND) " +
"VALUES ('CAT1', 'Mat 1', 'Y')",
"INSERT INTO XXCCMS_CATEGORY_OF_LAW_V (CATEGORY_OF_LAW_CODE, MATTER_TYPE_DESCRIPTION, COPY_COST_LIMIT_IND) " +
"VALUES ('CAT2', 'Mat 1', 'N')",
"INSERT INTO XXCCMS_CATEGORY_OF_LAW_V (CATEGORY_OF_LAW_CODE, MATTER_TYPE_DESCRIPTION, COPY_COST_LIMIT_IND) " +
"VALUES ('CAT3', 'Mat 2', 'Y')",
})
@CsvSource(value= {
"CAT1, null, null, 1",
"null, Mat 1, null, 2",
"null, null, false, 1"},
nullValues={"null"})
public void testGetCategoriesOfLaw(String code, String desc, Boolean copyCostLimit, Integer expectedElements) {
// Create a pageable object
Pageable pageable = PageRequest.of(0, 10);

// Call the repository method
CategoryOfLawLookupDetail result = lookupService.getCategoryOfLawLookupValues(
code, desc, copyCostLimit, pageable);

// Assert the result
assertNotNull(result);
assertEquals(expectedElements, result.getTotalElements());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,10 @@ CREATE TABLE XXCCMS_AWARD_TYPE_V (
START_DATE_ACTIVE DATE,
END_DATE_ACTIVE DATE,
ENABLED_FLAG VARCHAR2(1)
);

CREATE TABLE XXCCMS_CATEGORY_OF_LAW_V (
CATEGORY_OF_LAW_CODE VARCHAR2(30),
MATTER_TYPE_DESCRIPTION VARCHAR2(80),
COPY_COST_LIMIT_IND VARCHAR2(150)
);
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ DROP TABLE XXCCMS_STAGE_END_V;
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;
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import uk.gov.laa.ccms.data.model.AmendmentTypeLookupDetail;
import uk.gov.laa.ccms.data.model.AwardTypeLookupDetail;
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.OutcomeResultLookupDetail;
import uk.gov.laa.ccms.data.model.RelationshipToCaseLookupDetail;
Expand Down Expand Up @@ -179,4 +180,22 @@ public ResponseEntity<AwardTypeLookupDetail> getAwardTypeLookupValues(
return ResponseEntity.ok(lookupService.getAwardTypeLookupValues(
code, awardType, pageable));
}

/**
* GET category of law lookup values by code, matter type description, and
* copy cost limit value.
*
* @param code the category of law code
* @param matterTypeDescription the matter type description
* @param copyCostLimit the copy cost limit value
* @param pageable pagination information
* @return the ResponseEntity with status 200 (OK) and the list of category of law
* values in the body
*/
@Override
public ResponseEntity<CategoryOfLawLookupDetail> getCategoryOfLawLookupValues(
String code, String matterTypeDescription, Boolean copyCostLimit, Pageable pageable) {
return ResponseEntity.ok(lookupService.getCategoryOfLawLookupValues(
code, matterTypeDescription, copyCostLimit, pageable));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
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.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Immutable;

/**
* Represents a lookup value for category of law.
*
* <p>This entity corresponds to the "XXCCMS_CATEGORY_OF_LAW_V" table in the database.
* The JSON representation of this entity uses the snake case naming strategy.</p>
*
* <p>It's an immutable entity, meaning its state cannot be changed once it's created. The primary
* attributes of this entity include a code, its corresponding matter type description, and an
* indicator whether copying the cost limit is allowed for this particular category of law.</p>
*
* @see PropertyNamingStrategies.SnakeCaseStrategy
*/
@Data
@Entity
@NoArgsConstructor
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
@Table(name = "XXCCMS_CATEGORY_OF_LAW_V")
@Immutable
public class CategoryOfLawLookupValue {

@Id
@Column(name = "CATEGORY_OF_LAW_CODE")
private String code;

@Column(name = "MATTER_TYPE_DESCRIPTION")
private String matterTypeDescription;

@Column(name = "COPY_COST_LIMIT_IND")
private Boolean copyCostLimit;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import uk.gov.laa.ccms.data.entity.AmendmentTypeLookupValue;
import uk.gov.laa.ccms.data.entity.AwardTypeLookupValue;
import uk.gov.laa.ccms.data.entity.CaseStatusLookupValue;
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.OrganisationRelationshipToCaseLookupValue;
Expand All @@ -17,6 +18,8 @@
import uk.gov.laa.ccms.data.model.AwardTypeLookupDetail;
import uk.gov.laa.ccms.data.model.AwardTypeLookupValueDetail;
import uk.gov.laa.ccms.data.model.CaseStatusLookupDetail;
import uk.gov.laa.ccms.data.model.CategoryOfLawLookupDetail;
import uk.gov.laa.ccms.data.model.CategoryOfLawLookupValueDetail;
import uk.gov.laa.ccms.data.model.CommonLookupDetail;
import uk.gov.laa.ccms.data.model.CommonLookupValueDetail;
import uk.gov.laa.ccms.data.model.OutcomeResultLookupDetail;
Expand Down Expand Up @@ -96,4 +99,10 @@ AwardTypeLookupDetail toAwardTypeLookupDetail(
AwardTypeLookupValueDetail toAwardTypeLookupValueDetail(
AwardTypeLookupValue awardTypeLookupValue);

CategoryOfLawLookupDetail toCategoryOfLawLookupDetail(
Page<CategoryOfLawLookupValue> categoryOfLawLookupValues);

CategoryOfLawLookupValueDetail toCategoryOfLawLookupValueDetail(
CategoryOfLawLookupValue categoryOfLawLookupValue);

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

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

/**
* Repository interface for accessing {@link CategoryOfLawLookupValue} entities.
*
* <p>This repository extends the {@link ReadOnlyRepository} interface, it supports
* read-only operations for the {@code CategoryOfLawLookupValue} entity, identified by a
* primary key of type {@code String}.</p>
*
* @see CategoryOfLawLookupValue
* @see ReadOnlyRepository
*/
@Repository
public interface CategoryOfLawLookupValueRepository extends
ReadOnlyRepository<CategoryOfLawLookupValue, String> {

}
Loading

0 comments on commit 7a74018

Please sign in to comment.