From c4c9cbb40e7896c188b123097ec24998a1268c1d Mon Sep 17 00:00:00 2001 From: "Kacper Kowalik (Xarthisius)" Date: Sat, 12 Feb 2022 08:54:54 -0600 Subject: [PATCH] [deriva] define getDatasetUID --- server/lib/deriva/provider.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/server/lib/deriva/provider.py b/server/lib/deriva/provider.py index 2d05e548..fd780802 100644 --- a/server/lib/deriva/provider.py +++ b/server/lib/deriva/provider.py @@ -1,6 +1,8 @@ import pathlib from urllib.parse import urlparse +from girder.models.folder import Folder +from girder.models.item import Item from girder.models.setting import Setting from ...constants import PluginSettings from ..data_map import DataMap @@ -28,3 +30,13 @@ def lookup(self, entity: Entity) -> DataMap: if 'name' in entity: name = entity['name'] return DataMap(entity.getValue(), size=sz, repository='DERIVA', name=name) + + def getDatasetUID(self, doc: object, user: object) -> str: + if "folderId" in doc: + path_to_root = Item().parentsToRoot(doc, user=user) + else: + path_to_root = Folder().parentsToRoot(doc, user=user) + # Collection{WT Catalog} / Folder{WT Catalog} / Folder{Deriva ds root} + if len(path_to_root) == 2: + return doc["meta"]["identifier"] + return path_to_root[2]["object"]["meta"]["identifier"]