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

SSDM-13489: wrapping data sets in hierarchical content: instead of calling AS...

SSDM-13489: wrapping data sets in hierarchical content: instead of calling AS for each data set only one call for all data sets is invoked
parent c17ca9df
No related branches found
No related tags found
1 merge request!40SSDM-13578 : 2PT : Database and V3 Implementation - include the new AFS "free"...
...@@ -2,22 +2,20 @@ import script ...@@ -2,22 +2,20 @@ import script
def addSampleChildNodes(path, samplePermId, sampleType, response, acceptor, context): def addSampleChildNodes(path, samplePermId, sampleType, response, acceptor, context):
dataSets = script.getDataSetsOfSampleAndItsChildren(samplePermId, context) dataSets = script.getDataSetsOfSampleAndItsChildren(samplePermId, context)
filteredDataSets = []
for dataSet in dataSets: for dataSet in dataSets:
if acceptor.acceptDataSet(dataSet): if acceptor.acceptDataSet(dataSet):
dataSetCode = dataSet.getCode() filteredDataSets.append(dataSet)
content = context.getContentProvider().asContent(dataSetCode) script.addDataSetFileNodesFor(path, filteredDataSets, response, acceptor, context)
contentNode = content.getRootNode()
script.addDataSetFileNodes(path, dataSetCode, contentNode, response, acceptor, context)
def addSampleChildNodesWithPlates(path, samplePermId, sampleType, response, acceptor, context): def addSampleChildNodesWithPlates(path, samplePermId, sampleType, response, acceptor, context):
dataSets = script.getDataSetsOfSampleAndItsChildren(samplePermId, context) dataSets = script.getDataSetsOfSampleAndItsChildren(samplePermId, context)
filteredDataSets = []
for dataSet in dataSets: for dataSet in dataSets:
sampleTypeCode = dataSet.getSample().getType().getCode() sampleTypeCode = dataSet.getSample().getType().getCode()
if not sampleTypeCode.endswith("_WELL"): if not sampleTypeCode.endswith("_WELL"):
dataSetCode = dataSet.getCode() filteredDataSets.append(dataSet)
content = context.getContentProvider().asContent(dataSetCode) script.addDataSetFileNodesFor(path, filteredDataSets, response, acceptor, context)
contentNode = content.getRootNode()
script.addDataSetFileNodes(path, dataSetCode, contentNode, response, acceptor, context)
script.addSampleSampleChildNodes(path, samplePermId, response, acceptor, context) script.addSampleSampleChildNodes(path, samplePermId, response, acceptor, context)
for t in ["FACS_ARIA", "INFLUX", "MOFLO_XDP", "S3E", "SONY_SH800S", "SONY_MA900"]: for t in ["FACS_ARIA", "INFLUX", "MOFLO_XDP", "S3E", "SONY_SH800S", "SONY_MA900"]:
......
...@@ -7,11 +7,10 @@ acceptor.hideDataSetType("MICROSCOPY_IMG_THUMBNAIL") ...@@ -7,11 +7,10 @@ acceptor.hideDataSetType("MICROSCOPY_IMG_THUMBNAIL")
def addSampleChildNodes(path, samplePermId, sampleType, response, acceptor, context): def addSampleChildNodes(path, samplePermId, sampleType, response, acceptor, context):
dataSets = script.getDataSetsOfSampleAndItsChildren(samplePermId, context) dataSets = script.getDataSetsOfSampleAndItsChildren(samplePermId, context)
filteredDataSets = []
for dataSet in dataSets: for dataSet in dataSets:
if acceptor.acceptDataSet(dataSet): if acceptor.acceptDataSet(dataSet):
dataSetCode = dataSet.getCode() filteredDataSets.append(dataSet)
content = context.getContentProvider().asContent(dataSetCode) script.addDataSetFileNodesFor(path, filteredDataSets, response, acceptor, context)
contentNode = content.getRootNode()
script.addDataSetFileNodes(path, dataSetCode, contentNode, response, acceptor, context)
acceptor.sampleChildrenHandlers["MICROSCOPY_EXPERIMENT"] = addSampleChildNodes acceptor.sampleChildrenHandlers["MICROSCOPY_EXPERIMENT"] = addSampleChildNodes
...@@ -15,6 +15,10 @@ from ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.search import SampleSearchC ...@@ -15,6 +15,10 @@ from ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.search import SampleSearchC
from ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.fetchoptions import SampleFetchOptions from ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.fetchoptions import SampleFetchOptions
from ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.search import DataSetSearchCriteria from ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.search import DataSetSearchCriteria
from ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.fetchoptions import DataSetFetchOptions from ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.fetchoptions import DataSetFetchOptions
from ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.id import DataSetPermId
from ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset import DataSetKind
from ch.systemsx.cisd.openbis.generic.shared.basic.dto import PhysicalDataSet
from ch.systemsx.cisd.openbis.generic.shared.basic.dto import DataStore
from ch.systemsx.cisd.openbis.dss.generic.server.ftp import Node from ch.systemsx.cisd.openbis.dss.generic.server.ftp import Node
class NodeWithEntityType(Node): class NodeWithEntityType(Node):
...@@ -233,8 +237,8 @@ def listChildren(subPath, acceptor, context): ...@@ -233,8 +237,8 @@ def listChildren(subPath, acceptor, context):
permId = node.getPermId() permId = node.getPermId()
if nodeType == "DATASET": if nodeType == "DATASET":
response = None response = None
for permId in node.permIds: contentNodes = getContentNodes(node.permIds, context)
dataSetCode, contentNode, content = getContentNode(permId, context) for dataSetCode, contentNode, content in contentNodes:
if contentNode.isDirectory(): if contentNode.isDirectory():
if response is None: if response is None:
response = context.createDirectoryResponse() response = context.createDirectoryResponse()
...@@ -352,6 +356,49 @@ def addDataSetFileNodes(path, dataSetCode, contentNode, response, acceptor, cont ...@@ -352,6 +356,49 @@ def addDataSetFileNodes(path, dataSetCode, contentNode, response, acceptor, cont
else: else:
response.addFile(nodeName, childNode) response.addFile(nodeName, childNode)
def addDataSetFileNodesFor(path, dataSets, response, acceptor, context):
contentNodes = asContentNodes(dataSets, context)
for dataSetCode, contentNode, _ in contentNodes:
addDataSetFileNodes(path, dataSetCode, contentNode, response, acceptor, context)
def getContentNodes(permIds, context):
ids = []
paths = []
for permId in permIds:
splittedId = permId.split("::")
ids.append(DataSetPermId(splittedId[0]))
paths.append(splittedId[1] if len(splittedId) > 1 else None)
fetchOptions = DataSetFetchOptions()
fetchOptions.withDataStore()
fetchOptions.withPhysicalData()
dataSets = context.getApi().getDataSets(context.getSessionToken(), ids, fetchOptions).values()
return asContentNodes(dataSets, context, paths)
def asContentNodes(dataSets, context, paths=None):
result = []
contentProvider = context.getContentProvider()
for i in range(len(dataSets)):
dataSet = dataSets[i]
dataSetCode = dataSet.getCode()
dataStore = DataStore()
dataStore.setCode(dataSet.getDataStore().getCode())
dataStore.setHostUrl(dataSet.getDataStore().getDownloadUrl())
kind = dataSet.getKind()
if kind == DataSetKind.PHYSICAL:
physicalData = dataSet.getPhysicalData()
physicalDataSet = PhysicalDataSet()
physicalDataSet.setCode(dataSetCode)
physicalDataSet.setLocation(physicalData.getLocation())
physicalDataSet.setDataStore(dataStore)
physicalDataSet.setShareId(physicalData.getShareId())
content = contentProvider.asContentWithoutModifyingAccessTimestamp(physicalDataSet)
contentNode = content.getRootNode() if paths is None or paths[i] is None else content.tryGetNode(paths[i])
result.append((dataSetCode, contentNode, content))
else:
raise Exception("Not supported data set kind: %s" % kind)
return result
def getContentNode(permId, context): def getContentNode(permId, context):
splittedId = permId.split("::") splittedId = permId.split("::")
dataSetCode = splittedId[0] dataSetCode = splittedId[0]
...@@ -366,6 +413,8 @@ def getDataSetsOfSampleAndItsChildren(samplePermId, context): ...@@ -366,6 +413,8 @@ def getDataSetsOfSampleAndItsChildren(samplePermId, context):
parentsSearchCriteria = dataSetSearchCriteria.withSample().withParents() parentsSearchCriteria = dataSetSearchCriteria.withSample().withParents()
parentsSearchCriteria.withPermId().thatEquals(samplePermId) parentsSearchCriteria.withPermId().thatEquals(samplePermId)
fetchOptions = DataSetFetchOptions() fetchOptions = DataSetFetchOptions()
fetchOptions.withDataStore()
fetchOptions.withPhysicalData()
fetchOptions.withType() fetchOptions.withType()
fetchOptions.withProperties() fetchOptions.withProperties()
fetchOptions.withSample().withType() fetchOptions.withSample().withType()
......
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