From d6551a20b8b08999bfc376e246313d40840d7b7e Mon Sep 17 00:00:00 2001
From: Martin Weise <martin.weise@tuwien.ac.at>
Date: Sat, 15 Mar 2025 20:51:11 +0100
Subject: [PATCH] WIP

Signed-off-by: Martin Weise <martin.weise@tuwien.ac.at>
---
 .docker/docker-compose.yml                  |  1 +
 dbrepo-metadata-db/migration/16/data.py     | 19 ++++++++++++-------
 dbrepo-ui/components/identifier/Summary.vue |  2 +-
 dbrepo-ui/composables/identifier-service.ts |  3 +++
 dbrepo-ui/nuxt.config.ts                    |  1 -
 5 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/.docker/docker-compose.yml b/.docker/docker-compose.yml
index 32ea20a0c3..a9c6dee086 100644
--- a/.docker/docker-compose.yml
+++ b/.docker/docker-compose.yml
@@ -417,6 +417,7 @@ services:
     hostname: metric-db
     image: docker.io/bitnami/prometheus:2.54.1-debian-12-r4
     volumes:
+      - ./config/prometheus.yml:/etc/prometheus/prometheus.yml
       - ./config/prometheus.yml:/etc/prometheus/prometheus.yml
       - metric-db-data:/opt/bitnami/prometheus/data
     healthcheck:
diff --git a/dbrepo-metadata-db/migration/16/data.py b/dbrepo-metadata-db/migration/16/data.py
index cd81ea5b4d..e321eb38b7 100644
--- a/dbrepo-metadata-db/migration/16/data.py
+++ b/dbrepo-metadata-db/migration/16/data.py
@@ -4,9 +4,9 @@ import uuid
 
 from dbrepo.RestClient import RestClient
 
-endpoint = os.getenv('METADATA_SERVICE_ENDPOINT', 'https://dbrepo1.ec.tuwien.ac.at')
+endpoint = os.getenv('METADATA_SERVICE_ENDPOINT', 'http://localhost')
 username = os.getenv('SYSTEM_USERNAME', 'admin')
-password = os.getenv('SYSTEM_PASSWORD', 'f24870437f82adf567c0b03179f15e21')
+password = os.getenv('SYSTEM_PASSWORD', 'admin')
 client = RestClient(endpoint=endpoint, username=username, password=password)
 
 plan: [str] = []
@@ -89,12 +89,17 @@ def update_databases() -> None:
         plan.append(f"UPDATE mdb_view SET vdbid = '{new_id}' WHERE vdbid = '{old_id}';")
         plan.append(f"UPDATE mdb_identifiers SET dbid = '{new_id}' WHERE dbid = '{old_id}';")
         plan.append(f"UPDATE mdb_access SET aDBID = '{new_id}' WHERE aDBID = '{old_id}';")
-        for view in database.views:
-            v_old_id: int = view.id
+        for _view in database.views:
+            v_old_id: int = _view.id
             v_new_id: uuid = uuid.uuid4()
+            view = client.get_view(database_id=_database.id, view_id=_view.id)
             plan.append(f"UPDATE mdb_view SET ID = '{v_new_id}' WHERE ID = '{v_old_id}';")
+            plan.append(f"UPDATE mdb_view_columns SET view_id = '{v_new_id}' WHERE view_id = '{v_old_id}';")
             plan.append(f"UPDATE mdb_identifiers SET vid = '{v_new_id}' WHERE vid = '{v_old_id}';")
-            plan.append(f"UPDATE mdb_view_columns SET id = UUID(), view_id = '{v_new_id}' WHERE id = '{v_old_id}';")
+            for column in view.columns:
+                vc_old_id: int = column.id
+                vc_new_id: uuid = uuid.uuid4()
+                plan.append(f"UPDATE mdb_view_columns SET id = '{vc_new_id}' WHERE id = '{vc_old_id}';")
         for table in database.tables:
             tbl_old_id: int = table.id
             tbl_new_id: uuid = uuid.uuid4()
@@ -192,8 +197,8 @@ def update_identifiers() -> None:
             f_old_id = funder.id
             f_new_id: uuid = uuid.uuid4()
             plan.append(f"UPDATE mdb_identifier_funders SET id = '{f_new_id}' WHERE id = '{f_old_id}';")
-        for funder in identifier.related:
-            r_old_id = funder.id
+        for related_identifier in identifier.related_identifiers:
+            r_old_id = related_identifier.id
             r_new_id: uuid = uuid.uuid4()
             plan.append(f"UPDATE mdb_identifier_related SET id = '{r_new_id}' WHERE id = '{r_old_id}';")
     plan.append("COMMIT;")
diff --git a/dbrepo-ui/components/identifier/Summary.vue b/dbrepo-ui/components/identifier/Summary.vue
index dcbe2f063d..a2df3f22c7 100644
--- a/dbrepo-ui/components/identifier/Summary.vue
+++ b/dbrepo-ui/components/identifier/Summary.vue
@@ -68,7 +68,7 @@
           </div>
         </v-list-item>
         <v-list-item
-          v-if="identifier.related_identifiers && identifier.related_identifiers.length > 0"
+          v-if="identifier.related_identifiers"
           :title="$t('pages.identifier.related-identifiers.title')"
           density="compact">
           <p
diff --git a/dbrepo-ui/composables/identifier-service.ts b/dbrepo-ui/composables/identifier-service.ts
index 585356994b..2e96a2e20d 100644
--- a/dbrepo-ui/composables/identifier-service.ts
+++ b/dbrepo-ui/composables/identifier-service.ts
@@ -273,6 +273,9 @@ export const useIdentifierService = (): any => {
       const regex: RegExp = /(10[.][0-9]{4,}[^\s"\/<>]*\/[^\s"<>]+)/g
       const matches: RegExpMatchArray | null = val.match(regex)
       if (matches && matches.length > 0) {
+        if (config.public.doi.endpoint) {
+          return `${config.public.doi.endpoint}/${matches[0]}`
+        }
         return `https://doi.org/${matches[0]}`
       }
       if (val.startsWith('http')) {
diff --git a/dbrepo-ui/nuxt.config.ts b/dbrepo-ui/nuxt.config.ts
index 4d9b769904..b3694d5b8b 100644
--- a/dbrepo-ui/nuxt.config.ts
+++ b/dbrepo-ui/nuxt.config.ts
@@ -98,7 +98,6 @@ export default defineNuxtConfig({
         }
       },
       doi: {
-        enabled: false,
         endpoint: 'https://doi.org'
       },
       links: {}
-- 
GitLab