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

Remove litho import #1739

Merged
merged 9 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- Updated the layout of the borehole general tab.
- Removed deduplication check when adding and detaching attachments.
- When copying a borehole, attachments won't be copied.
- Remove csv lithology import.
Lehats marked this conversation as resolved.
Show resolved Hide resolved

### Fixed

Expand Down
252 changes: 1 addition & 251 deletions src/api/Controllers/UploadController.cs

Large diffs are not rendered by default.

70 changes: 0 additions & 70 deletions src/client/cypress/e2e/mainPage/import.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,6 @@ describe("Test for importing boreholes.", () => {
});
});

// Select lithology csv file
let lithologyFile = new DataTransfer();
getImportFileFromFixtures("lithology-single-valid.csv", null).then(fileContent => {
const file = new File([fileContent], "lithology-single-valid.csv", {
type: "text/csv",
});
lithologyFile.items.add(file);
});
cy.get('[data-cy="import-lithologyFile-input"]').within(() => {
cy.get("input[type=file]", { force: true }).then(input => {
input[0].files = lithologyFile.files;
input[0].dispatchEvent(new Event("change", { bubbles: true }));
});
});

// Intercept upload request
cy.intercept("/api/v2/upload?workgroupId=1").as("borehole-upload");

Expand Down Expand Up @@ -106,59 +91,4 @@ describe("Test for importing boreholes.", () => {
.should("contain", "Row5")
.should("contain", "Borehole with same Coordinates (+/- 2m) and same TotalDepth is provided multiple times.");
});

it("Displays lithology validation errors.", () => {
loginAsAdmin();
cy.get('[data-cy="import-borehole-button"]').click();

// Select borehole csv file
getImportFileFromFixtures("boreholes-multiple-valid.csv", null)
.then(fileContent => {
const file = new File([fileContent], "boreholes-multiple-valid.csv", {
type: "text/csv",
});
let boreholeFile = new DataTransfer();
boreholeFile.items.add(file);
return boreholeFile;
})
.then(boreholeFile => {
cy.get('[data-cy="import-boreholeFile-input"]').within(() => {
cy.get("input[type=file]", { force: true }).then(input => {
input[0].files = boreholeFile.files;
input[0].dispatchEvent(new Event("change", { bubbles: true }));
});
});
});

// Select lithology csv file
getImportFileFromFixtures("lithology-single-not-valid.csv", null, "invalid-lithology")
.then(fileContent => {
const file = new File([fileContent], "lithology-single-not-valid.csv", {
type: "text/csv",
});
let lithologyFile = new DataTransfer();
lithologyFile.items.add(file);
return lithologyFile;
})
.then(lithologyFile => {
cy.get('[data-cy="import-lithologyFile-input"]').within(() => {
cy.get("input[type=file]", { force: true }).then(input => {
input[0].files = lithologyFile.files;
input[0].dispatchEvent(new Event("change", { bubbles: true }));
});
});
});

cy.intercept("/api/v2/upload?workgroupId=1").as("borehole-upload");

cy.get('[data-cy="import-button"]').click();

cy.wait("@borehole-upload");

cy.get('[data-cy="borehole-import-error-modal-content"]')
.should("not.contain", "Row0")
.should("contain", "Row1")
.should("contain", "Field 'to_depth' is required.")
.should("contain", "Borehole with ImportId '123456' not found.");
});
});
3 changes: 0 additions & 3 deletions src/client/src/pages/overview/layout/mainSideNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ const MainSideNav = ({
const [validationErrorModal, setValidationErrorModal] = useState<boolean>(false);
const [selectedFile, setSelectedFile] = useState<Blob[] | null>(null);
const [selectedBoreholeAttachments, setSelectedBoreholeAttachments] = useState<Blob[] | null>(null);
const [selectedLithologyFile, setSelectedLithologyFile] = useState<Blob[] | null>(null);
const [errorsResponse, setErrorsResponse] = useState<ErrorResponse | null>(null);
const filterContext = useContext(FilterContext);

Expand Down Expand Up @@ -176,7 +175,6 @@ const MainSideNav = ({
setValidationErrorModal={setValidationErrorModal}
refresh={refresh}
setSelectedFile={setSelectedFile}
setSelectedLithologyFile={setSelectedLithologyFile}
setWorkgroup={setWorkgroupId}
enabledWorkgroups={enabledWorkgroups}
setSelectedBoreholeAttachments={setSelectedBoreholeAttachments}
Expand All @@ -185,7 +183,6 @@ const MainSideNav = ({
selectedBoreholeAttachments={selectedBoreholeAttachments}
modal={modal}
upload={upload}
selectedLithologyFile={selectedLithologyFile}
/>
<ImportErrorModal
setValidationErrorModal={setValidationErrorModal}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,11 @@ export interface ImportContentProps {
setSelectedBoreholeAttachments: React.Dispatch<React.SetStateAction<Blob[] | null>>;
selectedFile: Blob[] | null;
setSelectedFile: React.Dispatch<React.SetStateAction<Blob[] | null>>;
setSelectedLithologyFile: React.Dispatch<React.SetStateAction<Blob[] | null>>;
}

export interface ImportModalProps extends ImportContentProps {
modal: boolean;
creating: boolean;
selectedLithologyFile: Blob[] | null;
selectedBoreholeAttachments: Blob[] | null;
selectedFile: Blob[] | null;
upload: boolean;
Expand All @@ -43,6 +41,5 @@ export interface ImportModalProps extends ImportContentProps {
setErrorsResponse: React.Dispatch<React.SetStateAction<ErrorResponse | null>>;
setValidationErrorModal: React.Dispatch<React.SetStateAction<boolean>>;
setSelectedFile: React.Dispatch<React.SetStateAction<Blob[] | null>>;
setSelectedLithologyFile: React.Dispatch<React.SetStateAction<Blob[] | null>>;
refresh: () => void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ const ImportModal = ({
enabledWorkgroups,
workgroup,
setWorkgroup,
selectedLithologyFile,
setSelectedLithologyFile,
refresh,
}: ImportModalProps) => {
const { showAlert } = useContext(AlertContext);
Expand All @@ -43,11 +41,6 @@ const ImportModal = ({
combinedFormData.append("attachments", attachment);
});
}
if (selectedLithologyFile !== null) {
selectedLithologyFile.forEach((lithologyFile: string | Blob) => {
combinedFormData.append("lithologyFile", lithologyFile);
});
}
}
importBoreholes(workgroup, combinedFormData).then(response => {
setCreating(false);
Expand Down Expand Up @@ -107,7 +100,6 @@ const ImportModal = ({
<ImportModalContent
setSelectedBoreholeAttachments={setSelectedBoreholeAttachments}
setSelectedFile={setSelectedFile}
setSelectedLithologyFile={setSelectedLithologyFile}
selectedFile={selectedFile}
/>
<h3>{capitalizeFirstLetter(t("workgroup"))}</h3>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,7 @@ const ExampleHeadings = (headings: string) => {
);
};

const ImportModalContent = ({
setSelectedBoreholeAttachments,
setSelectedFile,
setSelectedLithologyFile,
selectedFile,
}: ImportContentProps) => {
const ImportModalContent = ({ setSelectedBoreholeAttachments, setSelectedFile, selectedFile }: ImportContentProps) => {
const { t } = useTranslation();

const handleBoreholeAttachmentChange = useCallback(
Expand All @@ -50,13 +45,6 @@ const ImportModalContent = ({
[setSelectedBoreholeAttachments],
);

const handleLithologyFileChange = useCallback(
(lithologyFileFromDropzone: Blob[]) => {
setSelectedLithologyFile(lithologyFileFromDropzone);
},
[setSelectedLithologyFile],
);

const handleBoreholeFileChange = useCallback(
(boreholeFileFromDropzone: Blob[]) => {
setSelectedFile(boreholeFileFromDropzone);
Expand Down Expand Up @@ -115,30 +103,6 @@ const ImportModalContent = ({
/>
</Stack>
{SeparatorLine()}
<h3>{capitalizeFirstLetter(t("lithology"))}</h3>
<Stack direction="row" alignItems="flex-start">
<StackHalfWidth>
{t("csvFormatExplanation")}
{ExampleHeadings(
"import_id;strati_import_id;strati_date;strati_name;from_depth;to_depth;" +
"is_last;description_quality_id;lithology_id;" +
"original_uscs;uscs_determination_id;uscs_1_id;grain_size_1_id;uscs_2_id;grain_size_2_id;" +
"is_striae;consistance_id;plasticity_id;compactness_id;cohesion_id;humidity_id;alteration_id;" +
"notes;original_lithology;uscs_3_ids;grain_shape_ids;grain_granularity_ids;organic_component_ids;" +
"debris_ids;color_ids;gradation_id;lithology_top_bedrock_id;",
)}
</StackHalfWidth>
<FileDropzone
onHandleFileChange={handleLithologyFileChange}
defaultText={"dropZoneLithologyText"}
restrictAcceptedFileTypeToCsv={true}
maxFilesToSelectAtOnce={1}
maxFilesToUpload={1}
isDisabled={selectedFile?.length === 0}
dataCy={"import-lithologyFile-input"}
/>
</Stack>
{SeparatorLine()}
</>
);
};
Expand Down
42 changes: 0 additions & 42 deletions tests/api/BDMS.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,45 +38,6 @@
<None Update="TestData\borehole_attachment_with_wrong_extension.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="TestData\data_sets\import_litho_with_invalid_code_list_ids\borehole.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="TestData\data_sets\import_litho_with_invalid_code_list_ids\litho.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="TestData\data_sets\import_litho_with_multi_code_list_properties\borehole.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="TestData\data_sets\import_litho_with_multi_code_list_properties\litho.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="TestData\data_sets\import_litho_diff_in_strati_attributes_for_same_starti_id\borehole.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="TestData\data_sets\import_litho_diff_in_strati_attributes_for_same_starti_id\litho.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="TestData\data_sets\import_litho_import_id_not_present_in_borehole_file\borehole.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="TestData\data_sets\import_litho_import_id_not_present_in_borehole_file\litho.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="TestData\data_sets\import_litho_missing_required_headers\borehole.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="TestData\data_sets\import_litho_missing_required_headers\litho.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="TestData\data_sets\import_litho_missing_required_fields\borehole.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="TestData\data_sets\import_litho_missing_required_fields\litho.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="TestData\data_sets\import_litho\litho.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="TestData\duplicateBoreholesInDbButDifferentWorkgroup.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -116,9 +77,6 @@
<None Update="TestData\duplicateBoreholesInFile.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="TestData\data_sets\import_litho\borehole.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="TestData\no_data_but_required_headers.csv">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
Loading
Loading