-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into adapt-export-ui
- Loading branch information
Showing
15 changed files
with
107 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using BDMS.Models; | ||
using CsvHelper; | ||
using CsvHelper.Configuration; | ||
using Humanizer; | ||
using NetTopologySuite.Mathematics; | ||
using NetTopologySuite.Utilities; | ||
using System.Globalization; | ||
|
||
namespace BDMS.BoreholeGeometry; | ||
|
||
public static class CsvConfigHelper | ||
{ | ||
internal static readonly CsvConfiguration CsvConfig = new(new CultureInfo("de-CH")) | ||
{ | ||
Delimiter = ";", | ||
IgnoreReferences = true, | ||
PrepareHeaderForMatch = args => args.Header.Humanize(LetterCasing.Title), | ||
MissingFieldFound = null, | ||
}; | ||
|
||
/// <summary> | ||
/// Get the CSV header <see cref="CsvHelper"/> for a class of type <typeparamref name="T"/>. | ||
/// Uses the map generated by <see cref="CsvHelper.CsvContext.AutoMap{T}()"/>. | ||
/// If a property has multiple possible column names only the first is considered. | ||
/// </summary> | ||
/// <typeparam name="T">The class to get the header for.</typeparam> | ||
internal static string GetCsvHeader<T>() | ||
{ | ||
var context = new CsvContext(CsvConfig); | ||
var map = context.AutoMap<T>(); | ||
return string.Join("; ", map.MemberMaps | ||
.Select(m => | ||
{ | ||
var name = m.Data.Names.FirstOrDefault(m.Data.Member.Name); | ||
return m.Data.IsOptional ? $"[{name}]" : name; | ||
})); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/client/cypress/fixtures/import/boreholes-missing-fields-and-duplicates.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/client/cypress/fixtures/import/boreholes-multiple-valid.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
src/client/cypress/fixtures/import/data-sets/invalid-lithology/borehole-valid.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import_id;alternate_name;original_name;location_x;location_y; | ||
344;BH-1001;Wellington 1;2156784;1154321; | ||
33;BH-1002;Wellington 2;2367999;1276543; | ||
2;BH-1003;Wellington 3;2189456;1334567; | ||
55;BH-1004;Wellington 4;2312345;1200987; | ||
name;original_name;location_x;location_y; | ||
BH-1001;Wellington 1;2156784;1154321; | ||
BH-1002;Wellington 2;2367999;1276543; | ||
BH-1003;Wellington 3;2189456;1334567; | ||
BH-1004;Wellington 4;2312345;1200987; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters