Skip to content

Commit

Permalink
Remove litho import (#1739)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lehats authored Dec 10, 2024
2 parents 18bf8a3 + a0a18b2 commit 8af87a1
Show file tree
Hide file tree
Showing 24 changed files with 21 additions and 747 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- Removed deduplication check when adding and detaching attachments.
- When copying a borehole, attachments won't be copied.
- Removed layers settings for anonymous users.
- Removed csv lithology import.

### 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.");
});
});
45 changes: 1 addition & 44 deletions src/client/docs/import.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ Zunächst sollte die CSV-Datei den Anforderungen und dem Format entsprechen, wie

1. Schaltfläche _Dateien hier ablegen oder klicken, um sie hochzuladen_ anklicken und die vorbereitete Datei(en) auswählen.

### Schritt 5: Lithologie CSV-Datei selektieren (optional)

1. Schaltfläche _Dateien hier ablegen oder klicken, um sie hochzuladen_ anklicken und die vorbereitete Lithologie CSV-Datei auswählen.

### Schritt 6: Dateien hochladen
### Schritt 5: Dateien hochladen

1. Import-Prozess mit einem Klick auf _Importieren_ starten.
2. Warten, bis der Upload abgeschlossen ist und die Daten in der Anwendung verfügbar sind.
Expand Down Expand Up @@ -94,45 +90,6 @@ Die zu importierenden Daten müssen gemäss obigen Anforderungen im CSV-Format v
| lithostratigraphy_id | ID (Codeliste) | Nein | Lithostratigraphie Top Fels |
| attachments | Text | Nein | Kommaseparierte Dateinamen der Anhänge mit Dateiendung z.B. anhang_1.pdf,anhang_2.zip |

## Lithologie Datei Format

Die zu importierenden Daten müssen gemäss obigen Anforderungen im CSV-Format vorliegen. Die erste Zeile wird als Spaltentitel/Spaltenname interpretiert, die restlichen Zeilen als Daten.

| Feldname | Datentyp | Pflichtfeld | Beschreibung |
| ------------------------ | -------------- | ----------- | ------------------------------------------------------------------------------------------------------------- |
| import_id | Zahl | Ja | Zufällig gewählte Zahl. Wird nicht gepeichert. Muss mit einer import_id aus der Bohrloch Datei übereinstimmen |
| strati_import_id | Zahl | Ja | Zufällig gewählte Zahl. Wird nicht gepeichert. Muss pro Stratigraphie identisch sein |
| strati_date | Datum | Nein | Datum der Stratigraphie. Muss pro Stratigraphie identisch sein |
| strati_name | Text | Nein | Name der Stratigraphie. Muss pro Stratigraphie identisch sein |
| from_depth | Zahl | Ja | Von Tiefe der Schicht |
| to_depth | Zahl | Ja | Bis Tiefe der Schicht |
| is_last | True/False | Nein | Ist die Schicht die letzte in der Stratigraphie? |
| description_quality_id | ID (Codeliste) | Nein | Qualität der Beschreibung |
| lithology_id | ID (Codeliste) | Nein | Lithologie |
| original_uscs | Text | Nein | USCS Originalklassifikation |
| uscs_determination_id | ID (Codeliste) | Nein | USCS Bestimmungsmethode |
| uscs_1_id | ID (Codeliste) | Nein | USCS 1 |
| grain_size_1_id | ID (Codeliste) | Nein | Korngrösse 1 |
| uscs_2_id | ID (Codeliste) | Nein | USCS 2 |
| grain_size_2_id | ID (Codeliste) | Nein | Korngrösse 2 |
| is_striae | True/False | Nein | Striemung |
| consistance_id | ID (Codeliste) | Nein | Konsistenz |
| plasticity_id | ID (Codeliste) | Nein | Plastizität |
| compactness_id | ID (Codeliste) | Nein | Lagerungsdichte |
| cohesion_id | ID (Codeliste) | Nein | Kohäsion |
| humidity_id | ID (Codeliste) | Nein | Feuchtigkeit |
| alteration_id | ID (Codeliste) | Nein | Verwitterung |
| notes | Text | Nein | Notizen |
| original_lithology | Text | Nein | Ursprüngliche Lithologie |
| uscs_3_ids | ID (Codeliste) | Nein | Kommaseparierte Codeliste IDs der USCS 3 |
| grain_shape_ids | ID (Codeliste) | Nein | Kommaseparierte Codeliste IDs der Korn Formen |
| grain_granularity_ids | ID (Codeliste) | Nein | Kommaseparierte Codeliste IDs der Kornrundungen |
| organic_component_ids | ID (Codeliste) | Nein | Kommaseparierte Codeliste IDs der Organischen Komponenten |
| debris_ids | ID (Codeliste) | Nein | Kommaseparierte Codeliste IDs der Grobbestandteile |
| color_ids | ID (Codeliste) | Nein | Kommaseparierte Codeliste IDs der Farben |
| gradation_id | ID (Codeliste) | Nein | Abstufung |
| lithology_top_bedrock_id | ID (Codeliste) | Nein | Lithologie Grobbestandteile |

## Validierung

### Fehlende Werte
Expand Down
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

0 comments on commit 8af87a1

Please sign in to comment.