From d71bc3b2e8782bcce5a82acc572eb7a7032c4a4b Mon Sep 17 00:00:00 2001 From: Markus Lumme Date: Tue, 8 Oct 2024 08:10:50 +0300 Subject: [PATCH 1/4] Insert namedPlace coordinates to column maps after they are received from api validaton. --- .../importer/importer.component.ts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/projects/laji/src/app/shared-modules/spreadsheet/importer/importer.component.ts b/projects/laji/src/app/shared-modules/spreadsheet/importer/importer.component.ts index d71a0f9e53..618066710f 100644 --- a/projects/laji/src/app/shared-modules/spreadsheet/importer/importer.component.ts +++ b/projects/laji/src/app/shared-modules/spreadsheet/importer/importer.component.ts @@ -131,6 +131,7 @@ export class ImporterComponent implements OnInit, OnDestroy { vm$: Observable; + private coordinateField = 'gatherings[*].geometry'; private externalLabel = [ 'editors[*]', 'gatheringEvent.leg[*]' @@ -379,6 +380,26 @@ export class ImporterComponent implements OnInit, OnDestroy { return path.replace(/\[[0-9]+]/g, '[*]'); } + addMissingGeometryToMapping(data) { + let coordinateCol; + Object.keys(this.colMap).forEach(col => { + if (this.colMap[col] === this.coordinateField) { + coordinateCol = col; + } + }); + + const geometry = data.source?.document?.gatherings[0]?.geometry + + Object.keys(data.source.rows).forEach(key => { + if (!this.mappedData[key][coordinateCol] && geometry) { + this.mappedData[key] = { + ...this.mappedData[key], + [coordinateCol]: geometry + }; + } + }); + } + removeInvalidFromUserMapping(errors) { const userMappings = this.mappingService.getUserMappings(); @@ -451,6 +472,8 @@ export class ImporterComponent implements OnInit, OnDestroy { }); this.removeInvalidFromUserMapping(data.result._error); + } else { + this.addMissingGeometryToMapping(data); } } this.mappedData = [...this.mappedData]; From ad95160ed792b73adf9a18e8b95c46ab50f244cb Mon Sep 17 00:00:00 2001 From: Markus Lumme Date: Tue, 8 Oct 2024 08:12:29 +0300 Subject: [PATCH 2/4] Lint fix. --- .../shared-modules/spreadsheet/importer/importer.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/laji/src/app/shared-modules/spreadsheet/importer/importer.component.ts b/projects/laji/src/app/shared-modules/spreadsheet/importer/importer.component.ts index 618066710f..fbd77ddb88 100644 --- a/projects/laji/src/app/shared-modules/spreadsheet/importer/importer.component.ts +++ b/projects/laji/src/app/shared-modules/spreadsheet/importer/importer.component.ts @@ -388,7 +388,7 @@ export class ImporterComponent implements OnInit, OnDestroy { } }); - const geometry = data.source?.document?.gatherings[0]?.geometry + const geometry = data.source?.document?.gatherings[0]?.geometry; Object.keys(data.source.rows).forEach(key => { if (!this.mappedData[key][coordinateCol] && geometry) { From ca28f4e4b34e36ce12ed9c60dbd31857b147f0fd Mon Sep 17 00:00:00 2001 From: Markus Lumme Date: Tue, 8 Oct 2024 09:44:28 +0300 Subject: [PATCH 3/4] Accounted for merging multiple documents together to one multi-gathering doc. --- .../importer/importer.component.ts | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/projects/laji/src/app/shared-modules/spreadsheet/importer/importer.component.ts b/projects/laji/src/app/shared-modules/spreadsheet/importer/importer.component.ts index fbd77ddb88..db6fbe2d6f 100644 --- a/projects/laji/src/app/shared-modules/spreadsheet/importer/importer.component.ts +++ b/projects/laji/src/app/shared-modules/spreadsheet/importer/importer.component.ts @@ -132,6 +132,7 @@ export class ImporterComponent implements OnInit, OnDestroy { vm$: Observable; private coordinateField = 'gatherings[*].geometry'; + private namedPlaceField = 'gatherings[*].namedPlaceID'; private externalLabel = [ 'editors[*]', 'gatheringEvent.leg[*]' @@ -380,21 +381,33 @@ export class ImporterComponent implements OnInit, OnDestroy { return path.replace(/\[[0-9]+]/g, '[*]'); } - addMissingGeometryToMapping(data) { + addMissingNamedPlaceGeometryToMapping(data) { let coordinateCol; + let namedPlaceCol; + Object.keys(this.colMap).forEach(col => { if (this.colMap[col] === this.coordinateField) { coordinateCol = col; } + + if (this.colMap[col] === this.namedPlaceField) { + namedPlaceCol = col; + } }); - const geometry = data.source?.document?.gatherings[0]?.geometry; + const geometry = {}; + + data.source?.document?.gatherings?.forEach(gathering => { + if (gathering.namedPlaceID && gathering.geometry) { + geometry[gathering.namedPlaceID] = gathering.geometry; + } + }); Object.keys(data.source.rows).forEach(key => { - if (!this.mappedData[key][coordinateCol] && geometry) { + if (!this.mappedData[key][coordinateCol] && geometry[this.mappedData[key][namedPlaceCol]]) { this.mappedData[key] = { ...this.mappedData[key], - [coordinateCol]: geometry + [coordinateCol]: geometry[this.mappedData[key][namedPlaceCol]] }; } }); @@ -473,7 +486,7 @@ export class ImporterComponent implements OnInit, OnDestroy { this.removeInvalidFromUserMapping(data.result._error); } else { - this.addMissingGeometryToMapping(data); + this.addMissingNamedPlaceGeometryToMapping(data); } } this.mappedData = [...this.mappedData]; From aff05f7bcbc0eecfcf0412f0bdf53c35d47d6710 Mon Sep 17 00:00:00 2001 From: Markus Lumme Date: Wed, 20 Nov 2024 16:42:08 +0200 Subject: [PATCH 4/4] Fixed configs for new test auth server. --- projects/iucn/src/environments/environment.ts | 6 +++--- projects/kerttu-global/src/environments/environment.dev.ts | 4 ++-- projects/kerttu-global/src/environments/environment.ts | 4 ++-- projects/laji/src/environments/environment.beta.ts | 6 +++--- projects/laji/src/environments/environment.dev-embedded.ts | 6 +++--- projects/laji/src/environments/environment.local-beta.ts | 6 +++--- projects/laji/src/environments/environment.local.ts | 6 +++--- projects/laji/src/environments/environment.ts | 6 +++--- projects/vir/src/environments/environment.ts | 4 ++-- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/projects/iucn/src/environments/environment.ts b/projects/iucn/src/environments/environment.ts index 47d9c973e1..44393e1419 100644 --- a/projects/iucn/src/environments/environment.ts +++ b/projects/iucn/src/environments/environment.ts @@ -15,9 +15,9 @@ export const environment = { sourceKotka: 'KE.3', systemID: 'KE.389', apiBase: 'https://dev.laji.fi/api', - loginCheck: 'https://fmnh-ws-test.it.helsinki.fi/laji-auth/loginInfo', - loginUrl: 'https://fmnh-ws-test.it.helsinki.fi/laji-auth/login', - selfPage: 'https://fmnh-ws-test.it.helsinki.fi/laji-auth/self', + loginCheck: 'https://fmnh-ws-test-24.it.helsinki.fi/laji-auth/loginInfo', + loginUrl: 'https://fmnh-ws-test-24.it.helsinki.fi/laji-auth/login', + selfPage: 'https://fmnh-ws-test-24.it.helsinki.fi/laji-auth/self', kerttuApi: 'https://staging-kerttu-backend.laji.fi', protaxApi: 'https://protax-api-protax-api-staging.rahtiapp.fi', geoserver: 'https://geoserver-dev.laji.fi/geoserver', diff --git a/projects/kerttu-global/src/environments/environment.dev.ts b/projects/kerttu-global/src/environments/environment.dev.ts index 8286a628ad..b946c46f31 100644 --- a/projects/kerttu-global/src/environments/environment.dev.ts +++ b/projects/kerttu-global/src/environments/environment.dev.ts @@ -11,8 +11,8 @@ export const environment = { systemID: 'KE.1181', apiBase: '/api', loginCheck: '', - loginUrl: 'https://fmnh-ws-test.it.helsinki.fi/laji-auth/login', - selfPage: 'https://fmnh-ws-test.it.helsinki.fi/laji-auth/self', + loginUrl: 'https://fmnh-ws-test-24.it.helsinki.fi/laji-auth/login', + selfPage: 'https://fmnh-ws-test-24.it.helsinki.fi/laji-auth/self', kerttuApi: 'https://staging-kerttu-backend.laji.fi', protaxApi: 'https://protax-api-protax-api-staging.rahtiapp.fi', geoserver: 'https://geoserver-dev.laji.fi/geoserver', diff --git a/projects/kerttu-global/src/environments/environment.ts b/projects/kerttu-global/src/environments/environment.ts index 0da2558e83..df90613251 100644 --- a/projects/kerttu-global/src/environments/environment.ts +++ b/projects/kerttu-global/src/environments/environment.ts @@ -15,8 +15,8 @@ export const environment = { systemID: 'KE.542', apiBase: 'https://dev.laji.fi/api', loginCheck: '', - loginUrl: 'https://fmnh-ws-test.it.helsinki.fi/laji-auth/login', - selfPage: 'https://fmnh-ws-test.it.helsinki.fi/laji-auth/self', + loginUrl: 'https://fmnh-ws-test-24.it.helsinki.fi/laji-auth/login', + selfPage: 'https://fmnh-ws-test-24.it.helsinki.fi/laji-auth/self', // kerttuApi: 'http://localhost:5000', kerttuApi: 'https://staging-kerttu-backend.laji.fi', protaxApi: 'https://protax-api-protax-api-staging.rahtiapp.fi', diff --git a/projects/laji/src/environments/environment.beta.ts b/projects/laji/src/environments/environment.beta.ts index aae74e91c8..58a810ded4 100644 --- a/projects/laji/src/environments/environment.beta.ts +++ b/projects/laji/src/environments/environment.beta.ts @@ -15,9 +15,9 @@ export const environment = { sourceKotka: 'KE.3', systemID: 'KE.841', apiBase: 'https://beta.laji.fi/api', - loginCheck: 'https://fmnh-ws-test.it.helsinki.fi/laji-auth/loginInfo', - loginUrl: 'https://fmnh-ws-test.it.helsinki.fi/laji-auth/login', - selfPage: 'https://fmnh-ws-test.it.helsinki.fi/laji-auth/self', + loginCheck: 'https://fmnh-ws-test-24.it.helsinki.fi/laji-auth/loginInfo', + loginUrl: 'https://fmnh-ws-test-24.it.helsinki.fi/laji-auth/login', + selfPage: 'https://fmnh-ws-test-24.it.helsinki.fi/laji-auth/self', kerttuApi: 'https://staging-kerttu-backend.laji.fi', protaxApi: 'https://protax-api-protax-api-staging.rahtiapp.fi', geoserver: 'https://geoserver-dev.laji.fi/geoserver', diff --git a/projects/laji/src/environments/environment.dev-embedded.ts b/projects/laji/src/environments/environment.dev-embedded.ts index 3abef0dd45..bce98fb6fe 100644 --- a/projects/laji/src/environments/environment.dev-embedded.ts +++ b/projects/laji/src/environments/environment.dev-embedded.ts @@ -10,9 +10,9 @@ export const environment = { sourceKotka: 'KE.3', systemID: 'KE.389', apiBase: 'https://dev-embedded.laji.fi/api', - loginCheck: 'https://fmnh-ws-test.it.helsinki.fi/laji-auth/loginInfo', - loginUrl: 'https://fmnh-ws-test.it.helsinki.fi/laji-auth/login', - selfPage: 'https://fmnh-ws-test.it.helsinki.fi/laji-auth/self', + loginCheck: 'https://fmnh-ws-test-24.it.helsinki.fi/laji-auth/loginInfo', + loginUrl: 'https://fmnh-ws-test-24.it.helsinki.fi/laji-auth/login', + selfPage: 'https://fmnh-ws-test-24.it.helsinki.fi/laji-auth/self', kerttuApi: 'https://staging-kerttu-backend.laji.fi', protaxApi: 'https://protax-api-protax-api-staging.rahtiapp.fi', geoserver: 'https://geoserver-dev.laji.fi/geoserver', diff --git a/projects/laji/src/environments/environment.local-beta.ts b/projects/laji/src/environments/environment.local-beta.ts index d50f1da0aa..99e5b294c7 100644 --- a/projects/laji/src/environments/environment.local-beta.ts +++ b/projects/laji/src/environments/environment.local-beta.ts @@ -9,9 +9,9 @@ export const environment = { sourceKotka: 'KE.3', systemID: 'KE.542', apiBase: 'https://beta.laji.fi/api', - loginCheck: 'https://fmnh-ws-test.it.helsinki.fi/laji-auth/loginInfo', - loginUrl: 'https://fmnh-ws-test.it.helsinki.fi/laji-auth/login', - selfPage: 'https://fmnh-ws-test.it.helsinki.fi/laji-auth/self', + loginCheck: 'https://fmnh-ws-test-24.it.helsinki.fi/laji-auth/loginInfo', + loginUrl: 'https://fmnh-ws-test-24.it.helsinki.fi/laji-auth/login', + selfPage: 'https://fmnh-ws-test-24.it.helsinki.fi/laji-auth/self', kerttuApi: 'https://staging-kerttu-backend.laji.fi', protaxApi: 'https://protax-api-protax-api-staging.rahtiapp.fi', geoserver: 'https://geoserver-dev.laji.fi/geoserver', diff --git a/projects/laji/src/environments/environment.local.ts b/projects/laji/src/environments/environment.local.ts index dc3cd81709..a5c97292f3 100644 --- a/projects/laji/src/environments/environment.local.ts +++ b/projects/laji/src/environments/environment.local.ts @@ -14,9 +14,9 @@ export const environment = { disableAnalytics: true, systemID: 'KE.542', apiBase: '/api', - loginCheck: 'https://fmnh-ws-test.it.helsinki.fi/laji-auth/loginInfo', - loginUrl: 'https://fmnh-ws-test.it.helsinki.fi/laji-auth/login', - selfPage: 'https://fmnh-ws-test.it.helsinki.fi/laji-auth/self', + loginCheck: 'https://fmnh-ws-test-24.it.helsinki.fi/laji-auth/loginInfo', + loginUrl: 'https://fmnh-ws-test-24.it.helsinki.fi/laji-auth/login', + selfPage: 'https://fmnh-ws-test-24.it.helsinki.fi/laji-auth/self', // kerttuApi: 'http://localhost:5000', kerttuApi: 'https://staging-kerttu-backend.laji.fi', protaxApi: 'https://protax-api-protax-api-staging.rahtiapp.fi', diff --git a/projects/laji/src/environments/environment.ts b/projects/laji/src/environments/environment.ts index 7804c4646c..d401f58a68 100644 --- a/projects/laji/src/environments/environment.ts +++ b/projects/laji/src/environments/environment.ts @@ -15,9 +15,9 @@ export const environment = { sourceKotka: 'KE.3', systemID: 'KE.389', apiBase: 'https://dev.laji.fi/api', - loginCheck: 'https://fmnh-ws-test.it.helsinki.fi/laji-auth/loginInfo', - loginUrl: 'https://fmnh-ws-test.it.helsinki.fi/laji-auth/login', - selfPage: 'https://fmnh-ws-test.it.helsinki.fi/laji-auth/self', + loginCheck: 'https://fmnh-ws-test-24.it.helsinki.fi/laji-auth/loginInfo', + loginUrl: 'https://fmnh-ws-test-24.it.helsinki.fi/laji-auth/login', + selfPage: 'https://fmnh-ws-test-24.it.helsinki.fi/laji-auth/self', kerttuApi: 'https://staging-kerttu-backend.laji.fi', protaxApi: 'https://protax-api-protax-api-staging.rahtiapp.fi', geoserver: 'https://geoserver-dev.laji.fi/geoserver', diff --git a/projects/vir/src/environments/environment.ts b/projects/vir/src/environments/environment.ts index f3b8493e34..42f2b74bd7 100644 --- a/projects/vir/src/environments/environment.ts +++ b/projects/vir/src/environments/environment.ts @@ -16,8 +16,8 @@ export const environment = { systemID: 'KE.542', rootCollections: ['HR.128'], apiBase: 'https://dev.laji.fi/api', - loginUrl: 'https://fmnh-ws-test.it.helsinki.fi/laji-auth/login', - selfPage: 'https://fmnh-ws-test.it.helsinki.fi/laji-auth/self', + loginUrl: 'https://fmnh-ws-test-24.it.helsinki.fi/laji-auth/login', + selfPage: 'https://fmnh-ws-test-24.it.helsinki.fi/laji-auth/self', kerttuApi: 'https://staging-kerttu-backend.laji.fi', globalMessageIds: { '\/observation.*': {