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

Feature/3.6.0 #153

Merged
merged 18 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
d5f054b
PIM-1839: Updated endpoint, service method and factory for UwContract…
dpitk2222 Dec 14, 2024
179ee4a
PIM-1839: Added persistence layer for loading otherYearPolicies.
dpitk2222 Dec 17, 2024
953800b
Merge pull request #147 from bcgov/feature/3.6.0
dpitk2222 Dec 17, 2024
c05ccee
PIM-1839: Added persistence unit tests.
dpitk2222 Dec 18, 2024
ceb2a9c
Merge branch 'feature/PIM-1839-Policy-Year-Dropdown-api' of https://g…
dpitk2222 Dec 18, 2024
9a8dbe3
Update openshift-create-update-db.yml to manually install oc.
dpitk2222 Dec 18, 2024
27975a1
PIM-1831: Create Dropdown to select another year while in a specific …
vivid-esnauffer Dec 18, 2024
2cbd557
Update openshift-create-update-db.yml with run-name.
dpitk2222 Dec 18, 2024
db54d73
PIM-1842: Modify the New Seeded Crop Report - Align Top and Bottom Po…
vivid-esnauffer Dec 18, 2024
2a9ac22
PIM-1807: Implementing data load of verified yield summary
Dec 19, 2024
f7e949d
PIM-1839: Unit tests.
dpitk2222 Dec 19, 2024
e476b49
PIM-1807: Implementing data load of verified yield summary, unit tests
Dec 19, 2024
23bf4b3
Merge branch 'feature/PIM-1839-Policy-Year-Dropdown-api' into feature…
Dec 19, 2024
7049028
PIM-1831: Create Dropdown to select another year while in a specific …
vivid-esnauffer Dec 20, 2024
833443e
Merge pull request #150 from bcgov/feature/PIM-1839-Policy-Year-Dropd…
dpitk2222 Dec 20, 2024
29bc98a
Merge pull request #152 from bcgov/PIM-1831-Create-Dropdown-to-select…
vivid-esnauffer Dec 20, 2024
96d58c8
Merge pull request #151 from bcgov/feature/PIM-1807-Verified-Grain-Yi…
mhostett Dec 20, 2024
707f524
Merge pull request #149 from bcgov/feature/PIM-1842-Grain-Sdd-Crop-Re…
vivid-esnauffer Dec 20, 2024
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
5 changes: 5 additions & 0 deletions .github/workflows/openshift-create-update-db.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Openshift DB deploy/update
run-name: Deploy PostgresCluster to ${{ inputs.ENVIRONMENT_NAME}}

on:
workflow_dispatch:
Expand Down Expand Up @@ -59,6 +60,10 @@ jobs:
chmod 700 get_helm.sh
./get_helm.sh

#Explicit install of oc cli tool
- name: Install oc
uses: redhat-actions/oc-installer@v1

- name: Authenticate and set context
uses: redhat-actions/oc-login@v1
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ UwContractListRsrc getUwContractList(
Integer pageNumber,
Integer pageRowCount) throws CirrasUnderwritingServiceException;

UwContractRsrc getUwContract(UwContractRsrc resource, String loadLinkedPolicies) throws CirrasUnderwritingServiceException;
UwContractRsrc getUwContract(UwContractRsrc resource, String loadLinkedPolicies, String loadOtherYearPolicies, String screenType) throws CirrasUnderwritingServiceException;

//////////////////////////////////////////////////////
// Annual Fields
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,14 +297,16 @@ public UwContractListRsrc getUwContractList(
}

@Override
public UwContractRsrc getUwContract(UwContractRsrc resource, String loadLinkedPolicies) throws CirrasUnderwritingServiceException {
public UwContractRsrc getUwContract(UwContractRsrc resource, String loadLinkedPolicies, String loadOtherYearPolicies, String screenType) throws CirrasUnderwritingServiceException {

GenericRestDAO<UwContractRsrc> dao = this.getRestDAOFactory().getGenericRestDAO(UwContractRsrc.class);

try {

Map<String, String> queryParams = new HashMap<String, String>();
putQueryParam(queryParams, "loadLinkedPolicies", loadLinkedPolicies);
putQueryParam(queryParams, "loadOtherYearPolicies", loadOtherYearPolicies);
putQueryParam(queryParams, "screenType", screenType);

Response<UwContractRsrc> response = dao.Process(ResourceTypes.SELF, this.getTransformer(), resource, queryParams, getWebClient());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.fasterxml.jackson.annotation.JsonTypeInfo;

import ca.bc.gov.mal.cirras.underwriting.api.rest.v1.resource.types.ResourceTypes;
import ca.bc.gov.mal.cirras.underwriting.model.v1.OtherYearPolicy;
import ca.bc.gov.mal.cirras.underwriting.model.v1.UwContract;
import ca.bc.gov.nrs.common.wfone.rest.resource.BaseResource;

Expand Down Expand Up @@ -51,6 +52,8 @@ public class UwContractRsrc extends BaseResource implements UwContract<UwContrac

private List<UwContractRsrc> linkedPolicies = new ArrayList<UwContractRsrc>();

private List<OtherYearPolicy> otherYearPolicies = new ArrayList<OtherYearPolicy>();

public Integer getContractId() {
return contractId;
}
Expand Down Expand Up @@ -253,5 +256,13 @@ public List<UwContractRsrc> getLinkedPolicies() {
public void setLinkedPolicies(List<UwContractRsrc> linkedPolicies) {
this.linkedPolicies = linkedPolicies;
}

public List<OtherYearPolicy> getOtherYearPolicies() {
return otherYearPolicies;
}

public void setOtherYearPolicies(List<OtherYearPolicy> otherYearPolicies) {
this.otherYearPolicies = otherYearPolicies;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import ca.bc.gov.mal.cirras.underwriting.model.v1.VerifiedYieldAmendment;
import ca.bc.gov.mal.cirras.underwriting.model.v1.VerifiedYieldContract;
import ca.bc.gov.mal.cirras.underwriting.model.v1.VerifiedYieldContractCommodity;
import ca.bc.gov.mal.cirras.underwriting.model.v1.VerifiedYieldSummary;
import ca.bc.gov.nrs.common.wfone.rest.resource.BaseResource;
import ca.bc.gov.nrs.common.wfone.rest.resource.MessageRsrc;

Expand All @@ -38,6 +39,7 @@ public class VerifiedYieldContractRsrc extends BaseResource implements VerifiedY
private List<AnnualFieldRsrc> fields = new ArrayList<AnnualFieldRsrc>();
private List<VerifiedYieldContractCommodity> verifiedYieldContractCommodities = new ArrayList<VerifiedYieldContractCommodity>();
private List<VerifiedYieldAmendment> verifiedYieldAmendments = new ArrayList<VerifiedYieldAmendment>();
private List<VerifiedYieldSummary> verifiedYieldSummaries = new ArrayList<VerifiedYieldSummary>();
private List<MessageRsrc> productWarningMessages = new ArrayList<MessageRsrc>();

public String getVerifiedYieldContractGuid() {
Expand Down Expand Up @@ -132,6 +134,13 @@ public void setVerifiedYieldAmendments(List<VerifiedYieldAmendment> verifiedYiel
this.verifiedYieldAmendments = verifiedYieldAmendments;
}

public List<VerifiedYieldSummary> getVerifiedYieldSummaries() {
return verifiedYieldSummaries;
}
public void setVerifiedYieldSummaries(List<VerifiedYieldSummary> verifiedYieldSummaries) {
this.verifiedYieldSummaries = verifiedYieldSummaries;
}

public List<MessageRsrc> getProductWarningMessages() {
return productWarningMessages;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public interface UwContractEndpoint extends BaseEndpoints {
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
Response getUwContract(
@Parameter(description = "The Policy ID of the uw contract.") @PathParam("policyId") String policyId,
@Parameter(description = "True if linked policies should be included in the returned resource, False if not") @QueryParam("loadLinkedPolicies") String loadLinkedPolicies
@Parameter(description = "True if linked policies should be included in the returned resource, False if not") @QueryParam("loadLinkedPolicies") String loadLinkedPolicies,
@Parameter(description = "True if other year policies should be included in the returned resource, False if not") @QueryParam("loadOtherYearPolicies") String loadOtherYearPolicies,
@Parameter(description = "The screen type for which other year policies should be loaded: INVENTORY, DOP or VERIFIED") @QueryParam("screenType") String screenType
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class UwContractEndpointImpl extends BaseEndpointsImpl implements UwContr
private CirrasUnderwritingService cirrasUnderwritingService;

@Override
public Response getUwContract(final String policyId, String loadLinkedPolicies) {
public Response getUwContract(final String policyId, String loadLinkedPolicies, String loadOtherYearPolicies, String screenType) {

Response response = null;

Expand All @@ -43,6 +43,8 @@ public Response getUwContract(final String policyId, String loadLinkedPolicies)
UwContractRsrc result = (UwContractRsrc) cirrasUnderwritingService.getUwContract(
toInteger(policyId),
toBoolean(loadLinkedPolicies),
toBoolean(loadOtherYearPolicies),
toString(screenType),
getFactoryContext(),
getWebAdeAuthentication());
response = Response.ok(result).tag(result.getUnquotedETag()).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ static UnderwritingComment createUnderwritingComment(UnderwritingCommentDto dto,
model.setUnderwritingCommentTypeCode(dto.getUnderwritingCommentTypeCode());
model.setUnderwritingCommentTypeDesc(dto.getUnderwritingCommentTypeDesc());
model.setDeclaredYieldContractGuid(dto.getDeclaredYieldContractGuid());
model.setVerifiedYieldSummaryGuid(dto.getVerifiedYieldSummaryGuid());
model.setGrowerContractYearId(dto.getGrowerContractYearId());
model.setUpdateDate(dto.getUpdateDate());
model.setUpdateUser(dto.getUpdateUser());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import ca.bc.gov.mal.cirras.underwriting.model.v1.AnnualField;
import ca.bc.gov.mal.cirras.underwriting.model.v1.Field;
import ca.bc.gov.mal.cirras.underwriting.model.v1.LegalLand;
import ca.bc.gov.mal.cirras.underwriting.model.v1.OtherYearPolicy;
import ca.bc.gov.mal.cirras.underwriting.model.v1.PolicySimple;
import ca.bc.gov.mal.cirras.underwriting.model.v1.RemoveFieldValidation;
import ca.bc.gov.mal.cirras.underwriting.model.v1.RenameLegalValidation;
Expand All @@ -52,6 +53,7 @@
import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.PolicyDto;
import ca.bc.gov.mal.cirras.underwriting.service.api.v1.model.factory.UwContractFactory;
import ca.bc.gov.mal.cirras.underwriting.service.api.v1.util.InventoryServiceEnums;
import ca.bc.gov.mal.cirras.underwriting.service.api.v1.util.InventoryServiceEnums.ScreenType;

public class UwContractRsrcFactory extends BaseResourceFactory implements UwContractFactory {

Expand Down Expand Up @@ -87,7 +89,7 @@ public UwContractList<? extends UwContract<? extends UwContract<?>>> getUwContra

populateResource(resource, dto);

setSelfLink(dto.getPolicyId(), false, resource, baseUri);
setSelfLink(dto.getPolicyId(), false, false, null, resource, baseUri);
setLinks(resource, baseUri, authentication);

resources.add(resource);
Expand Down Expand Up @@ -146,7 +148,10 @@ public UwContractList<? extends UwContract<? extends UwContract<?>>> getUwContra
public UwContract<? extends UwContract<?>> getUwContract(
PolicyDto dto,
List<PolicyDto> linkedPolicyDtos,
List<PolicyDto> otherYearPolicyDtos,
Boolean loadLinkedPolicies,
Boolean loadOtherYearPolicies,
String screenType,
FactoryContext context,
WebAdeAuthentication authentication
) throws FactoryException {
Expand All @@ -165,20 +170,31 @@ public UwContract<? extends UwContract<?>> getUwContract(

UwContractRsrc linkedPolicyModel = new UwContractRsrc();
populateResource(linkedPolicyModel, lpDto);
setSelfLink(lpDto.getPolicyId(), false, linkedPolicyModel, baseUri);
setSelfLink(lpDto.getPolicyId(), false, false, null, linkedPolicyModel, baseUri);
setLinks(linkedPolicyModel, baseUri, authentication);

linkedPoliciesModel.add(linkedPolicyModel);
}

resource.setLinkedPolicies(linkedPoliciesModel);
}


// Other Year Policies
if ( otherYearPolicyDtos != null && !otherYearPolicyDtos.isEmpty() ) {
List<OtherYearPolicy> otherYearPoliciesModel = new ArrayList<OtherYearPolicy>();

for (PolicyDto pDto : otherYearPolicyDtos) {
OtherYearPolicy otherYearPolicyModel = createOtherYearPolicy(pDto, screenType);
otherYearPoliciesModel.add(otherYearPolicyModel);
}

resource.setOtherYearPolicies(otherYearPoliciesModel);
}

String eTag = getEtag(resource);
resource.setETag(eTag);

setSelfLink(dto.getPolicyId(), loadLinkedPolicies, resource, baseUri);
setSelfLink(dto.getPolicyId(), loadLinkedPolicies, loadOtherYearPolicies, screenType, resource, baseUri);
setLinks(resource, baseUri, authentication);

return resource;
Expand Down Expand Up @@ -214,19 +230,45 @@ private void populateResource(UwContractRsrc resource, PolicyDto dto) {
// growerProvince

}

private OtherYearPolicy createOtherYearPolicy(PolicyDto dto, String screenType) {

OtherYearPolicy model = new OtherYearPolicy();

model.setCropYear(dto.getCropYear());
model.setInsurancePlanId(dto.getInsurancePlanId());
model.setPolicyId(dto.getPolicyId());
model.setPolicyNumber(dto.getPolicyNumber());

if ( ScreenType.INVENTORY.name().equals(screenType) ) {
model.setScreenRecordGuid(dto.getInventoryContractGuid());
} else if ( ScreenType.DOP.name().equals(screenType) ) {
model.setScreenRecordGuid(dto.getDeclaredYieldContractGuid());
} else if ( ScreenType.VERIFIED.name().equals(screenType) ) {
model.setScreenRecordGuid(dto.getVerifiedYieldContractGuid());
} else {
throw new FactoryException("Invalid value for screenType: " + screenType);
}

model.setScreenType(screenType);

return model;
}

static void setSelfLink(Integer policyId, Boolean loadLinkedPolicies, UwContractRsrc resource, URI baseUri) {
static void setSelfLink(Integer policyId, Boolean loadLinkedPolicies, Boolean loadOtherYearPolicies, String screenType, UwContractRsrc resource, URI baseUri) {
if (policyId != null) {
String selfUri = getUwContractSelfUri(policyId, loadLinkedPolicies, baseUri);
String selfUri = getUwContractSelfUri(policyId, loadLinkedPolicies, loadOtherYearPolicies, screenType, baseUri);
resource.getLinks().add(new RelLink(ResourceTypes.SELF, selfUri, "GET"));
}
}

public static String getUwContractSelfUri(Integer policyId, Boolean loadLinkedPolicies, URI baseUri) {
public static String getUwContractSelfUri(Integer policyId, Boolean loadLinkedPolicies, Boolean loadOtherYearPolicies, String screenType, URI baseUri) {
String result = UriBuilder
.fromUri(baseUri)
.path(UwContractEndpoint.class)
.queryParam("loadLinkedPolicies", nvl(toString(loadLinkedPolicies), ""))
.queryParam("loadOtherYearPolicies", nvl(toString(loadOtherYearPolicies), ""))
.queryParam("screenType", nvl(screenType, ""))
.build(policyId).toString();
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
import ca.bc.gov.mal.cirras.underwriting.api.rest.v1.resource.VerifiedYieldContractRsrc;
import ca.bc.gov.mal.cirras.underwriting.api.rest.v1.resource.types.ResourceTypes;
import ca.bc.gov.mal.cirras.underwriting.model.v1.AnnualField;
import ca.bc.gov.mal.cirras.underwriting.model.v1.UnderwritingComment;
import ca.bc.gov.mal.cirras.underwriting.model.v1.VerifiableCommodity;
import ca.bc.gov.mal.cirras.underwriting.model.v1.VerifiedYieldAmendment;
import ca.bc.gov.mal.cirras.underwriting.model.v1.VerifiedYieldSummary;
import ca.bc.gov.mal.cirras.underwriting.model.v1.VerifiedYieldContract;
import ca.bc.gov.mal.cirras.underwriting.model.v1.VerifiedYieldContractCommodity;
import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.ContractedFieldDetailDto;
Expand All @@ -39,7 +41,9 @@
import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.InventorySeededGrainDto;
import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.PolicyDto;
import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.ProductDto;
import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.UnderwritingCommentDto;
import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.VerifiedYieldAmendmentDto;
import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.VerifiedYieldSummaryDto;
import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.VerifiedYieldContractCommodityDto;
import ca.bc.gov.mal.cirras.underwriting.persistence.v1.dto.VerifiedYieldContractDto;
import ca.bc.gov.mal.cirras.underwriting.service.api.v1.model.factory.VerifiedYieldContractFactory;
Expand Down Expand Up @@ -185,6 +189,18 @@ private VerifiedYieldContractCommodity createDefaultVerifiedYieldContractCommodi

resource.setVerifiedYieldAmendments(verifiedYieldAmendments);
}

// Verified Yield Summary
if (!dto.getVerifiedYieldSummaries().isEmpty()) {
List<VerifiedYieldSummary> verifiedYieldSummaries = new ArrayList<VerifiedYieldSummary>();

for (VerifiedYieldSummaryDto vysDto : dto.getVerifiedYieldSummaries()) {
VerifiedYieldSummary vysModel = createVerifiedYieldSummary(vysDto, authentication);
verifiedYieldSummaries.add(vysModel);
}

resource.setVerifiedYieldSummaries(verifiedYieldSummaries);
}

resource.setProductWarningMessages(productWarnings);

Expand Down Expand Up @@ -329,6 +345,38 @@ private VerifiedYieldAmendment createVerifiedYieldAmendment(VerifiedYieldAmendme

return model;
}

private VerifiedYieldSummary createVerifiedYieldSummary(VerifiedYieldSummaryDto dto, WebAdeAuthentication authentication) {
VerifiedYieldSummary model = new VerifiedYieldSummary();

model.setVerifiedYieldSummaryGuid(dto.getVerifiedYieldSummaryGuid());
model.setVerifiedYieldContractGuid(dto.getVerifiedYieldContractGuid());
model.setCropCommodityId(dto.getCropCommodityId());
model.setCropCommodityName(dto.getCropCommodityName());
model.setIsPedigreeInd(dto.getIsPedigreeInd());
model.setHarvestedYield(dto.getHarvestedYield());
model.setHarvestedYieldPerAcre(dto.getHarvestedYieldPerAcre());
model.setAppraisedYield(dto.getAppraisedYield());
model.setAssessedYield(dto.getAssessedYield());
model.setYieldToCount(dto.getYieldToCount());
model.setYieldPercentPy(dto.getYieldPercentPy());
model.setProductionGuarantee(dto.getProductionGuarantee());
model.setProbableYield(dto.getProbableYield());

// UnderwritingComment
if (!dto.getUwComments().isEmpty()) {
List<UnderwritingComment> uwComments = new ArrayList<UnderwritingComment>();

for (UnderwritingCommentDto ucDto : dto.getUwComments()) {
UnderwritingComment ucModel = InventoryContractRsrcFactory.createUnderwritingComment(ucDto, authentication);
uwComments.add(ucModel);
}

model.setUwComments(uwComments);
}

return model;
}

// Creates an AnnualFieldRsrc and populates its verifiableCommodities.
private AnnualFieldRsrc createAnnualField(ContractedFieldDetailDto dto, WebAdeAuthentication authentication) {
Expand Down
Loading
Loading