Skip to content

Commit

Permalink
[deriva] define getDatasetUID
Browse files Browse the repository at this point in the history
  • Loading branch information
Xarthisius committed Feb 12, 2022
1 parent a1db594 commit c4c9cbb
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions server/lib/deriva/provider.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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"]

0 comments on commit c4c9cbb

Please # to comment.