Skip to content
Snippets Groups Projects
Commit 65456eb4 authored by felmer's avatar felmer
Browse files

SSDM-13489: improvments: (i) For cases with many data sets belonging also to a...

SSDM-13489: improvments: (i) For cases with many data sets belonging also to a sample, (2) caching GENERAL_ELN_SETTINGS for 1 minute
parent 2dc7fdcf
No related branches found
No related tags found
1 merge request!40SSDM-13578 : 2PT : Database and V3 Implementation - include the new AFS "free"...
import json import json
import os import os
import time
from java.nio.file import NoSuchFileException from java.nio.file import NoSuchFileException
from ch.ethz.sis.openbis.generic.asapi.v3.dto.space.id import SpacePermId from ch.ethz.sis.openbis.generic.asapi.v3.dto.space.id import SpacePermId
...@@ -123,6 +124,9 @@ class Settings(object): ...@@ -123,6 +124,9 @@ class Settings(object):
self.mainMenues = mainMenues self.mainMenues = mainMenues
self.sampleTypeViewAttributes = sampleTypeViewAttributes self.sampleTypeViewAttributes = sampleTypeViewAttributes
settings = None
settingsExpirationTimestamp = None
acceptor = Acceptor() acceptor = Acceptor()
pluginsFolder = "%s/resolver-plugins" % os.path.dirname(__file__) pluginsFolder = "%s/resolver-plugins" % os.path.dirname(__file__)
for pluginFileName in os.listdir(pluginsFolder): for pluginFileName in os.listdir(pluginsFolder):
...@@ -130,7 +134,12 @@ for pluginFileName in os.listdir(pluginsFolder): ...@@ -130,7 +134,12 @@ for pluginFileName in os.listdir(pluginsFolder):
execfile(file, {"acceptor":acceptor}) execfile(file, {"acceptor":acceptor})
def resolve(subPath, context): def resolve(subPath, context):
acceptor.configure(getAllSettings(context)) global settings, settingsExpirationTimestamp
if settings is None or time.time() > settingsExpirationTimestamp:
settings = getAllSettings(context)
settingsExpirationTimestamp = time.time() + 60
acceptor.configure(settings)
if len(subPath) == 0: if len(subPath) == 0:
return listSections(acceptor, context) return listSections(acceptor, context)
...@@ -295,7 +304,8 @@ def addExperimentNodes(section, space, project, response, acceptor, context): ...@@ -295,7 +304,8 @@ def addExperimentNodes(section, space, project, response, acceptor, context):
def addExperimentChildNodes(path, experimentPermId, experimentType, response, acceptor, context): def addExperimentChildNodes(path, experimentPermId, experimentType, response, acceptor, context):
dataSetSearchCriteria = DataSetSearchCriteria() dataSetSearchCriteria = DataSetSearchCriteria()
dataSetSearchCriteria.withExperiment().withPermId().thatEquals(experimentPermId) dataSetSearchCriteria.withExperiment().withPermId().thatEquals(experimentPermId)
listDataSets(path, dataSetSearchCriteria, False, response, acceptor, context) dataSetSearchCriteria.withoutSample()
listDataSets(path, dataSetSearchCriteria, response, acceptor, context)
sampleSearchCriteria = SampleSearchCriteria() sampleSearchCriteria = SampleSearchCriteria()
sampleSearchCriteria.withExperiment().withPermId().thatEquals(experimentPermId) sampleSearchCriteria.withExperiment().withPermId().thatEquals(experimentPermId)
...@@ -318,7 +328,7 @@ def addSampleChildNodes(path, samplePermId, sampleType, response, acceptor, cont ...@@ -318,7 +328,7 @@ def addSampleChildNodes(path, samplePermId, sampleType, response, acceptor, cont
dataSetSearchCriteria = DataSetSearchCriteria() dataSetSearchCriteria = DataSetSearchCriteria()
dataSetSearchCriteria.withSample().withPermId().thatEquals(samplePermId) dataSetSearchCriteria.withSample().withPermId().thatEquals(samplePermId)
listDataSets(path, dataSetSearchCriteria, True, response, acceptor, context) listDataSets(path, dataSetSearchCriteria, response, acceptor, context)
addSampleSampleChildNodes(path, samplePermId, response, acceptor, context) addSampleSampleChildNodes(path, samplePermId, response, acceptor, context)
def addSampleSampleChildNodes(path, samplePermId, response, acceptor, context): def addSampleSampleChildNodes(path, samplePermId, response, acceptor, context):
...@@ -423,7 +433,7 @@ def getDataSets(dataSetSearchCriteria, context): ...@@ -423,7 +433,7 @@ def getDataSets(dataSetSearchCriteria, context):
fetchOptions.withSample().withType() fetchOptions.withSample().withType()
return context.getApi().searchDataSets(context.getSessionToken(), dataSetSearchCriteria, fetchOptions).getObjects() return context.getApi().searchDataSets(context.getSessionToken(), dataSetSearchCriteria, fetchOptions).getObjects()
def listDataSets(path, dataSetSearchCriteria, assignedToSample, response, acceptor, context): def listDataSets(path, dataSetSearchCriteria, response, acceptor, context):
fetchOptions = DataSetFetchOptions() fetchOptions = DataSetFetchOptions()
fetchOptions.withType() fetchOptions.withType()
fetchOptions.withProperties() fetchOptions.withProperties()
...@@ -431,9 +441,7 @@ def listDataSets(path, dataSetSearchCriteria, assignedToSample, response, accept ...@@ -431,9 +441,7 @@ def listDataSets(path, dataSetSearchCriteria, assignedToSample, response, accept
dataSets = context.getApi().searchDataSets(context.getSessionToken(), dataSetSearchCriteria, fetchOptions).getObjects() dataSets = context.getApi().searchDataSets(context.getSessionToken(), dataSetSearchCriteria, fetchOptions).getObjects()
entitiesByName = {} entitiesByName = {}
for dataSet in dataSets: for dataSet in dataSets:
sample = dataSet.getSample() if acceptor.acceptDataSet(dataSet):
if ((assignedToSample and sample is not None) or (not assignedToSample and sample is None)) \
and acceptor.acceptDataSet(dataSet):
gatherEntity(entitiesByName, dataSet) gatherEntity(entitiesByName, dataSet)
addNodes("DATASET", entitiesByName, path, response, context) addNodes("DATASET", entitiesByName, path, response, context)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment