Skip to content

Commit

Permalink
story(ccls-2012) general request types endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilDigitalJustice committed Oct 16, 2024
1 parent eb99575 commit dd72610
Show file tree
Hide file tree
Showing 12 changed files with 371 additions and 4 deletions.
64 changes: 64 additions & 0 deletions data-api/open-api-specification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,41 @@ paths:
description: 'Not found'
'500':
description: 'Internal server error'
/lookup/provider-request-types:
get:
tags:
- lookup
summary: 'Get a provider request type lookup values'
description: Get a provider request type lookup values
operationId: 'getProviderRequestTypeLookupValues'
x-spring-paginated: true
parameters:
- name: 'is-case-related'
in: 'query'
schema:
type: 'boolean'
example: 'true'
- name: 'type'
in: 'query'
schema:
type: 'String'
responses:
'200':
description: 'Successful operation'
content:
application/json:
schema:
$ref: "#/components/schemas/providerRequestTypeLookupDetail"
'400':
description: 'Bad request'
'401':
description: 'Unauthorized'
'403':
description: 'Forbidden'
'404':
description: 'Not found'
'500':
description: 'Internal server error'
/lookup/common:
get:
tags:
Expand Down Expand Up @@ -1426,6 +1461,35 @@ components:
default: [ ]
items:
$ref: "#/components/schemas/declarationLookupValueDetail"
providerRequestTypeLookupValueDetail:
type: 'object'
properties:
type:
type: 'string'
name:
type: 'string'
is_case_related:
type: 'boolean'
additional_information_prompt:
type: 'string'
task_type_id:
type: 'string'
is_file_upload_enabled:
type: 'boolean'
access_function_code:
type: 'string'
file_upload_prompt:
type: 'string'
providerRequestTypeLookupDetail:
allOf:
- $ref: "#/components/schemas/page"
type: 'object'
properties:
content:
type: 'array'
default: [ ]
items:
$ref: "#/components/schemas/providerRequestTypeLookupValueDetail"
page:
type: 'object'
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
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.ProviderRequestTypeLookupDetail;
import uk.gov.laa.ccms.data.model.RelationshipToCaseLookupDetail;
import uk.gov.laa.ccms.data.model.StageEndLookupDetail;

Expand Down Expand Up @@ -365,6 +366,48 @@ public void testGetAssessmentSummaryAttributes(String summaryType, Integer expec
assertEquals(expectedElements, result.getTotalElements());
}

@ParameterizedTest
@Sql(statements = {
"INSERT INTO XXCCMS_PROVIDER_REQTYPES_V (REQUEST_TYPE, REQUEST_NAME, CASE_RELATED_FLAG, ADDITIONAL_INFO_PROMPT, TASK_TYPE_ID, FILE_UPLD_ENABLED, ACCESS_FUNC_CODE, FILE_UPLD_PROMPT) " +
"VALUES ('TYPE1', 'Provider Type 1', 'Y', 'Prompt 1', '101', 'Y', 'ACC1', 'Upload Prompt 1');",
"INSERT INTO XXCCMS_PROVIDER_REQTYPES_V (REQUEST_TYPE, REQUEST_NAME, CASE_RELATED_FLAG, ADDITIONAL_INFO_PROMPT, TASK_TYPE_ID, FILE_UPLD_ENABLED, ACCESS_FUNC_CODE, FILE_UPLD_PROMPT) " +
"VALUES ('TYPE2', 'Provider Type 2', 'N', 'Prompt 2', '102', 'N', 'ACC2', 'Upload Prompt 2');"
})
@CsvSource({
"true, 1",
"false, 1"
})
public void testGetProviderRequestTypeLookupValues(Boolean isCaseRelated, Integer expectedResults) {
Pageable pageable = PageRequest.of(0, 10);

ProviderRequestTypeLookupDetail result = lookupService.getProviderRequestTypeLookupValues(isCaseRelated, null, pageable);

assertNotNull(result);
assertEquals(expectedResults, result.getTotalElements());
}

@ParameterizedTest
@Sql(statements = {
"INSERT INTO XXCCMS_PROVIDER_REQTYPES_V (REQUEST_TYPE, REQUEST_NAME, CASE_RELATED_FLAG, ADDITIONAL_INFO_PROMPT, TASK_TYPE_ID, FILE_UPLD_ENABLED, ACCESS_FUNC_CODE, FILE_UPLD_PROMPT) " +
"VALUES ('TYPE1', 'Provider Type 1', 'Y', 'Prompt 1', '101', 'Y', 'ACC1', 'Upload Prompt 1');",
"INSERT INTO XXCCMS_PROVIDER_REQTYPES_V (REQUEST_TYPE, REQUEST_NAME, CASE_RELATED_FLAG, ADDITIONAL_INFO_PROMPT, TASK_TYPE_ID, FILE_UPLD_ENABLED, ACCESS_FUNC_CODE, FILE_UPLD_PROMPT) " +
"VALUES ('TYPE2', 'Provider Type 2', 'N', 'Prompt 2', '102', 'N', 'ACC2', 'Upload Prompt 2');"
})
@CsvSource({
"TYPE1, Provider Type 1",
"TYPE2, Provider Type 2"
})
public void testGetProviderRequestTypeLookupValuesByType(String type, String expectedName) {
Pageable pageable = PageRequest.of(0, 10);

ProviderRequestTypeLookupDetail
result = lookupService.getProviderRequestTypeLookupValues(null, type, pageable);

assertNotNull(result);
assertEquals(1, result.getTotalElements());
assertEquals(expectedName, result.getContent().get(0).getName());
}




Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,14 @@ CREATE TABLE XXCCMS_PUI_OPA_ATTRIBUTE_V (
SUMMARY_DISPLAY_FLAG VARCHAR(1)
);

CREATE TABLE XXCCMS_PROVIDER_REQTYPES_V (
REQUEST_TYPE VARCHAR(50) PRIMARY KEY,
REQUEST_NAME VARCHAR(100),
CASE_RELATED_FLAG CHAR(1),
ADDITIONAL_INFO_PROMPT VARCHAR(255),
TASK_TYPE_ID VARCHAR(150),
FILE_UPLD_ENABLED CHAR(1),
ACCESS_FUNC_CODE VARCHAR(50),
FILE_UPLD_PROMPT VARCHAR(255)
);

Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ DROP TABLE XXCCMS_CATEGORY_OF_LAW_V;
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;



Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import uk.gov.laa.ccms.data.model.LevelOfServiceLookupDetail;
import uk.gov.laa.ccms.data.model.MatterTypeLookupDetail;
import uk.gov.laa.ccms.data.model.OutcomeResultLookupDetail;
import uk.gov.laa.ccms.data.model.ProviderRequestTypeLookupDetail;
import uk.gov.laa.ccms.data.model.RelationshipToCaseLookupDetail;
import uk.gov.laa.ccms.data.model.StageEndLookupDetail;
import uk.gov.laa.ccms.data.service.LookupService;
Expand Down Expand Up @@ -160,6 +161,24 @@ public ResponseEntity<MatterTypeLookupDetail> getMatterTypeLookupValues(
pageable));
}

/**
* GET provider request type lookup values.
*
* @param isCaseRelated the isCaseRelated flag
* @param type the type of the provider request type
* @param pageable pagination information
* @return the ResponseEntity with status 200 (OK) and the list of provider request type lookup
* values in the body
*/
@Override
public ResponseEntity<ProviderRequestTypeLookupDetail> getProviderRequestTypeLookupValues(
final Boolean isCaseRelated, final String type, final Pageable pageable) {
return ResponseEntity.ok(lookupService.getProviderRequestTypeLookupValues(
isCaseRelated,
type,
pageable));
}


/**
* GET amendment type lookup values by application type.
Expand All @@ -178,8 +197,6 @@ public ResponseEntity<AmendmentTypeLookupDetail> getAmendmentTypeLookupValues(
return ResponseEntity.ok(lookupService.getAmendmentTypeLookupValues(applicationType, pageable));
}



/**
* Retrieves assessment summary attributes based on the given summary type and pageable.
*
Expand Down Expand Up @@ -244,8 +261,6 @@ public ResponseEntity<RelationshipToCaseLookupDetail> getPersonToCaseRelationshi
code, description, pageable));
}



/**
* GET organisation to case relationship lookup values.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
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.hibernate.annotations.Immutable;

/**
* Represents a provider request type entity, mapped to the database view
* XXCCMS_PROVIDER_REQTYPES_V. This class is immutable and uses
* SnakeCaseStrategy for JSON serialization.
*/
@Entity
@Data
@NoArgsConstructor
@Table(name = "XXCCMS_PROVIDER_REQTYPES_V")
@Immutable
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public class ProviderRequestType {


@Id
@Column(name = "REQUEST_TYPE")
private String type;

@Column(name = "REQUEST_NAME")
private String name;

@Column(name = "CASE_RELATED_FLAG")
private Boolean caseRelated;

@Column(name = "ADDITIONAL_INFO_PROMPT")
private String additionalInformationPrompt;

@Column(name = "TASK_TYPE_ID")
private String taskTypeId;

@Column(name = "FILE_UPLD_ENABLED")
private Boolean fileUploadEnabled;

@Column(name = "ACCESS_FUNC_CODE")
private String accessFunctionCode;

@Column(name = "FILE_UPLD_PROMPT")
private String fileUploadPrompt;


}
Original file line number Diff line number Diff line change
Expand Up @@ -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.ProviderRequestType;
import uk.gov.laa.ccms.data.entity.StageEndLookupValue;
import uk.gov.laa.ccms.data.model.AmendmentTypeLookupDetail;
import uk.gov.laa.ccms.data.model.AmendmentTypeLookupValueDetail;
Expand All @@ -43,6 +44,8 @@
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.ProviderRequestTypeLookupDetail;
import uk.gov.laa.ccms.data.model.ProviderRequestTypeLookupValueDetail;
import uk.gov.laa.ccms.data.model.RelationshipToCaseLookupDetail;
import uk.gov.laa.ccms.data.model.RelationshipToCaseLookupValueDetail;
import uk.gov.laa.ccms.data.model.StageEndLookupDetail;
Expand Down Expand Up @@ -172,4 +175,15 @@ DeclarationLookupDetail toDeclarationLookupDetail(
DeclarationLookupValueDetail toDeclarationLookupValueDetail(
Declaration declaration);

ProviderRequestTypeLookupDetail toProviderRequestTypeLookupDetail(
Page<ProviderRequestType> providerRequestTypes);

@Mapping(source = "caseRelated", target = "isCaseRelated")
@Mapping(source = "additionalInformationPrompt", target = "additionalInformationPrompt")
@Mapping(source = "fileUploadEnabled", target = "isFileUploadEnabled")
ProviderRequestTypeLookupValueDetail toProviderRequestTypeLookupValueDetail(
ProviderRequestType providerRequestType);



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

import uk.gov.laa.ccms.data.entity.ProviderRequestType;

/**
* Repository interface for accessing {@link ProviderRequestType} entities.
* Extends {@link ReadOnlyRepository} for read-only operations.
*/

public interface ProviderRequestTypeRepository
extends ReadOnlyRepository<ProviderRequestType, String> {

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import uk.gov.laa.ccms.data.entity.PersonRelationshipToCaseLookupValue;
import uk.gov.laa.ccms.data.entity.ProceedingClientInvolvementType;
import uk.gov.laa.ccms.data.entity.ProceedingClientInvolvementTypeId;
import uk.gov.laa.ccms.data.entity.ProviderRequestType;
import uk.gov.laa.ccms.data.entity.StageEndLookupValue;
import uk.gov.laa.ccms.data.entity.StageEndLookupValueId;
import uk.gov.laa.ccms.data.mapper.LookupMapper;
Expand All @@ -47,6 +48,7 @@
import uk.gov.laa.ccms.data.model.LevelOfServiceLookupDetail;
import uk.gov.laa.ccms.data.model.MatterTypeLookupDetail;
import uk.gov.laa.ccms.data.model.OutcomeResultLookupDetail;
import uk.gov.laa.ccms.data.model.ProviderRequestTypeLookupDetail;
import uk.gov.laa.ccms.data.model.RelationshipToCaseLookupDetail;
import uk.gov.laa.ccms.data.model.StageEndLookupDetail;
import uk.gov.laa.ccms.data.repository.AmendmentTypeLookupValueRepository;
Expand All @@ -64,6 +66,7 @@
import uk.gov.laa.ccms.data.repository.OutcomeResultLookupValueRepository;
import uk.gov.laa.ccms.data.repository.PersonRelationshipToCaseLookupValueRepository;
import uk.gov.laa.ccms.data.repository.ProceedingClientInvolvementTypeRepository;
import uk.gov.laa.ccms.data.repository.ProviderRequestTypeRepository;
import uk.gov.laa.ccms.data.repository.StageEndLookupValueRepository;

/**
Expand Down Expand Up @@ -110,6 +113,7 @@ public class LookupService extends AbstractEbsDataService {

private final DeclarationRepository declarationRepository;

private final ProviderRequestTypeRepository providerRequestTypeRepository;

/**
* Retrieves a page of common values based on the provided
Expand Down Expand Up @@ -502,4 +506,24 @@ protected Specification<AssessmentSummaryEntity> buildQuerySpecification(
};
}

/**
* Retrieves a page of provider request type values based on the provided search criteria.
*
* @param isCaseRelated the case related flag
* @param type the type of provider request
* @param pageable pagination information
* @return a ProviderRequestTypeLookupDetail containing a page of provider request type values
*/
public ProviderRequestTypeLookupDetail getProviderRequestTypeLookupValues(
final Boolean isCaseRelated,
final String type,
final Pageable pageable) {
ProviderRequestType example = new ProviderRequestType();
example.setCaseRelated(isCaseRelated);
example.setType(type);

return lookupMapper.toProviderRequestTypeLookupDetail(
providerRequestTypeRepository.findAll(Example.of(example), pageable));
}

}
Loading

0 comments on commit dd72610

Please sign in to comment.