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

psp-7995 consolidation/subdivision restrictions. #3877

Merged
merged 3 commits into from
Mar 22, 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
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.DocumentReference, src => src.DocumentReference)
.Map(dest => dest.ResearchSummary, src => src.ResearchSummary)
.Map(dest => dest.Property, src => src.Property)
.Map(dest => dest.PropertyId, src => src.PropertyId)
.Map(dest => dest.File, src => src.ResearchFile)
.Map(dest => dest.FileId, src => src.ResearchFileId)
.Map(dest => dest.PurposeTypes, src => src.PimsPrfPropResearchPurposeTypes)
.Inherits<Entity.IBaseEntity, BaseConcurrentModel>();

config.NewConfig<ResearchFilePropertyModel, Entity.PimsPropertyResearchFile>()
.Map(dest => dest.PropertyResearchFileId, src => src.Id)
.Map(dest => dest.Property, src => src.Property)
.Map(dest => dest.PropertyId, src => src.Property.Id)
.Map(dest => dest.PropertyId, src => src.PropertyId)
.Map(dest => dest.ResearchFileId, src => src.FileId)
.Map(dest => dest.PropertyName, src => src.PropertyName)
.Map(dest => dest.DisplayOrder, src => src.DisplayOrder)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,20 @@ export const PropertySelectorPidSearchContainer: React.FunctionComponent<
try {
const result = await getPropertyByPidWrapper.execute(layerSearch?.pid);
if (result) {
setSelectProperty(result);
if (!result.isOwned || result.isRetired) {
toast.warn(
'Only properties that are part of the Core Inventory (owned) can be subdivided/consolidated. This property is not in core inventory within PIMS.',
);
} else {
setSelectProperty(result);
}
}
} catch (e) {
const axiosError = e as AxiosError<IApiError>;
if (axiosError?.response?.status === 404) {
toast.warn('The PID that you are searching for does not exist in the PIMS database.');
toast.warn(
'Only properties that are part of the Core Inventory (owned) can be subdivided/consolidated. This property is not in core inventory within PIMS.',
);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { ApiGen_Concepts_PropertyPurpose } from '@/models/api/generated/ApiGen_Concepts_PropertyPurpose';
import { ApiGen_Concepts_ResearchFile } from '@/models/api/generated/ApiGen_Concepts_ResearchFile';
import { ApiGen_Concepts_ResearchFileProperty } from '@/models/api/generated/ApiGen_Concepts_ResearchFileProperty';
import { exists } from '@/utils/utils';

import { getEmptyResearchFile } from './../../../../../../models/defaultInitializers';

export class PropertyResearchFilePurposeFormModel {
public id?: number;
public propertyPurposeTypeCode?: string;
Expand Down Expand Up @@ -48,7 +49,8 @@ export class UpdatePropertyFormModel {
public purposeTypes?: PropertyResearchFilePurposeFormModel[];
public rowVersion?: number;

public researchFile: ApiGen_Concepts_ResearchFile | null = null;
public researchFileRowVersion: number | null = null;
public researchFileId: number | null = null;

public static fromApi(base: ApiGen_Concepts_ResearchFileProperty): UpdatePropertyFormModel {
const model = new UpdatePropertyFormModel();
Expand All @@ -68,6 +70,8 @@ export class UpdatePropertyFormModel {
model.documentReference = base.documentReference ?? undefined;
model.researchSummary = base.researchSummary ?? undefined;
model.propertyId = base.property?.id;
model.researchFileRowVersion = base?.file?.rowVersion ?? null;
model.researchFileId = base?.fileId ?? null;

model.purposeTypes = base.purposeTypes?.map((x: ApiGen_Concepts_PropertyPurpose) =>
PropertyResearchFilePurposeFormModel.fromApi(x),
Expand Down Expand Up @@ -97,8 +101,8 @@ export class UpdatePropertyFormModel {
documentReference: this.documentReference ?? null,
researchSummary: this.researchSummary ?? null,
property: null,
fileId: this.researchFile?.id ?? 0,
file: this.researchFile,
fileId: this.researchFileId ?? 0,
file: { ...getEmptyResearchFile(), rowVersion: this.researchFileRowVersion },
purposeTypes: this.purposeTypes?.map(x => x.toApi()) ?? null,
rowVersion: this.rowVersion ?? null,
};
Expand Down
11 changes: 6 additions & 5 deletions source/frontend/src/hooks/layer-api/layerUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ export const toCqlFilterValue = (object: Record<string, string>, flags?: IWfsCql
const cql: string[] = [];
Object.keys(object).forEach((key: string) => {
if (object[key]) {
if (
(key === 'PID' || key === 'PID_PADDED' || key === 'PID_NUMBER') &&
(object[key]?.length === 9 || flags?.forceExactMatch)
if (key === 'PIN' && flags?.forceExactMatch) {
cql.push(`${key}='${object[key].replace(/[^0-9]/g, '')}'`);
} else if (
((key === 'PID' || key === 'PID_PADDED' || key === 'PID_NUMBER') &&
object[key]?.length === 9) ||
flags?.forceExactMatch
) {
cql.push(`${key} = '${object[key]}'`);
} else if (key === 'PIN' && flags?.forceExactMatch) {
cql.push(`${key}='${object[key].replace(/[^0-9]/g, '')}'`);
} else {
cql.push(`${key} ilike '%${object[key]}%'`);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AxiosError } from 'axios';
import { AxiosResponse } from 'axios';
import { useCallback, useMemo } from 'react';
import { toast } from 'react-toastify';

Expand Down Expand Up @@ -29,7 +30,9 @@ export const usePimsPropertyRepository = () => {
onError: useAxiosErrorHandler('Failed to retrieve property information from PIMS'),
});

const getPropertyByPidWrapper = useApiRequestWrapper({
const getPropertyByPidWrapper = useApiRequestWrapper<
(...args: any[]) => Promise<AxiosResponse<ApiGen_Concepts_Property, any>>
>({
requestFunction: useCallback(
async (pid: string) => await getPropertyConceptWithPidApi(pid),
[getPropertyConceptWithPidApi],
Expand Down
Loading