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

SSDM-12929: removing dataSetSearchCriteriaExtender, add entity types to nodes

parent 84bf1655
No related branches found
No related tags found
1 merge request!40SSDM-13578 : 2PT : Database and V3 Implementation - include the new AFS "free"...
acceptor.hideDataSetType("MICROSCOPY_IMG_CONTAINER") acceptor.hideDataSetType("MICROSCOPY_IMG_CONTAINER")
acceptor.hideDataSetType("MICROSCOPY_IMG_OVERVIEW") acceptor.hideDataSetType("MICROSCOPY_IMG_OVERVIEW")
acceptor.hideDataSetType("MICROSCOPY_IMG_THUMBNAIL") acceptor.hideDataSetType("MICROSCOPY_IMG_THUMBNAIL")
acceptor.hideSampleType("MICROSCOPY_SAMPLE_TYPE")
acceptor.dataSetSearchCriteriaExtender.append(lambda c, id: extendDataSetSearchCriteriaForMicroscopy(c, id))
def extendDataSetSearchCriteriaForMicroscopy(dataSetSearchCriteria, samplePermId):
dataSetSearchCriteria.withOrOperator()
parentsSearchCriteria = dataSetSearchCriteria.withSample().withParents()
parentsSearchCriteria.withType().withCode().thatEquals("MICROSCOPY_EXPERIMENT")
parentsSearchCriteria.withPermId().thatEquals(samplePermId)
...@@ -17,6 +17,14 @@ from ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.search import DataSetSearc ...@@ -17,6 +17,14 @@ from ch.ethz.sis.openbis.generic.asapi.v3.dto.dataset.search import DataSetSearc
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.systemsx.cisd.openbis.dss.generic.server.ftp import Node from ch.systemsx.cisd.openbis.dss.generic.server.ftp import Node
class NodeWithEntityType(Node):
def __init__(self, type, permId, entityType):
super(NodeWithEntityType, self).__init__(type, permId)
self.entityType = entityType
def getEntityType(self):
return self.entityType
class Acceptor(object): class Acceptor(object):
def __init__(self, settings): def __init__(self, settings):
self.sections = ["Lab Notebook", "Inventory", "Stock"] self.sections = ["Lab Notebook", "Inventory", "Stock"]
...@@ -30,7 +38,6 @@ class Acceptor(object): ...@@ -30,7 +38,6 @@ class Acceptor(object):
self.hiddenExperimentTypes = {} self.hiddenExperimentTypes = {}
self.hiddenSampleTypes = {} self.hiddenSampleTypes = {}
self.hiddenDataSetTypes = {} self.hiddenDataSetTypes = {}
self.dataSetSearchCriteriaExtender = []
def assertValidSection(self, section): def assertValidSection(self, section):
if section not in self.sections: if section not in self.sections:
...@@ -217,7 +224,8 @@ def listExperimentContent(subPath, acceptor, context): ...@@ -217,7 +224,8 @@ def listExperimentContent(subPath, acceptor, context):
node = getNode(subPath, acceptor, context) node = getNode(subPath, acceptor, context)
response = context.createDirectoryResponse() response = context.createDirectoryResponse()
experimentPermId = node.getPermId() experimentPermId = node.getPermId()
addExperimentChildNodes(path, experimentPermId, response, acceptor, context) experimentType = node.getEntityType()
addExperimentChildNodes(path, experimentPermId, experimentType, response, acceptor, context)
return response return response
def listChildren(subPath, acceptor, context): def listChildren(subPath, acceptor, context):
...@@ -235,7 +243,7 @@ def listChildren(subPath, acceptor, context): ...@@ -235,7 +243,7 @@ def listChildren(subPath, acceptor, context):
return context.createFileResponse(contentNode, content) return context.createFileResponse(contentNode, content)
elif nodeType == "SAMPLE": elif nodeType == "SAMPLE":
response = context.createDirectoryResponse() response = context.createDirectoryResponse()
addSampleChildNodes(path, permId, response, acceptor, context) addSampleChildNodes(path, permId, node.getEntityType(), response, acceptor, context)
return response return response
def getNode(subPath, acceptor, context): def getNode(subPath, acceptor, context):
...@@ -249,10 +257,12 @@ def getNode(subPath, acceptor, context): ...@@ -249,10 +257,12 @@ def getNode(subPath, acceptor, context):
parentNode = getNode(parentPath, acceptor, context) parentNode = getNode(parentPath, acceptor, context)
parentPathString = "/".join(parentPath) parentPathString = "/".join(parentPath)
nodeType = parentNode.getType() nodeType = parentNode.getType()
entityType = parentNode.getEntityType()
permId = parentNode.getPermId()
if nodeType == "EXPERIMENT": if nodeType == "EXPERIMENT":
addExperimentChildNodes(parentPathString, parentNode.getPermId(), None, acceptor, context) addExperimentChildNodes(parentPathString, permId, entityType, None, acceptor, context)
elif nodeType == "SAMPLE": elif nodeType == "SAMPLE":
addSampleChildNodes(parentPathString, parentNode.getPermId(), None, acceptor, context) addSampleChildNodes(parentPathString, permId, entityType, None, acceptor, context)
elif nodeType == "DATASET": elif nodeType == "DATASET":
dataSetCode, contentNode, _ = getContentNode(parentNode.getPermId(), context) dataSetCode, contentNode, _ = getContentNode(parentNode.getPermId(), context)
addDataSetFileNodes(parentPathString, dataSetCode, contentNode, None, acceptor, context) addDataSetFileNodes(parentPathString, dataSetCode, contentNode, None, acceptor, context)
...@@ -277,7 +287,7 @@ def addExperimentNodes(section, space, project, response, acceptor, context): ...@@ -277,7 +287,7 @@ def addExperimentNodes(section, space, project, response, acceptor, context):
gatherEntity(entitiesByName, experiment) gatherEntity(entitiesByName, experiment)
addNodes("EXPERIMENT", entitiesByName, "%s/%s/%s" % (section, space, project), response, context) addNodes("EXPERIMENT", entitiesByName, "%s/%s/%s" % (section, space, project), response, context)
def addExperimentChildNodes(path, experimentPermId, 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) listDataSets(path, dataSetSearchCriteria, False, response, acceptor, context)
...@@ -296,10 +306,9 @@ def addExperimentChildNodes(path, experimentPermId, response, acceptor, context) ...@@ -296,10 +306,9 @@ def addExperimentChildNodes(path, experimentPermId, response, acceptor, context)
gatherEntity(entitiesByName, sample) gatherEntity(entitiesByName, sample)
addNodes("SAMPLE", entitiesByName, path, response, context) addNodes("SAMPLE", entitiesByName, path, response, context)
def addSampleChildNodes(path, samplePermId, response, acceptor, context): def addSampleChildNodes(path, samplePermId, sampleType, response, acceptor, context):
dataSetSearchCriteria = DataSetSearchCriteria() dataSetSearchCriteria = DataSetSearchCriteria()
dataSetSearchCriteria.withSample().withPermId().thatEquals(samplePermId) dataSetSearchCriteria.withSample().withPermId().thatEquals(samplePermId)
acceptor.extendDataSetSearchCriteria(dataSetSearchCriteria, samplePermId)
listDataSets(path, dataSetSearchCriteria, True, response, acceptor, context) listDataSets(path, dataSetSearchCriteria, True, response, acceptor, context)
...@@ -326,7 +335,7 @@ def addDataSetFileNodes(path, dataSetCode, contentNode, response, acceptor, cont ...@@ -326,7 +335,7 @@ def addDataSetFileNodes(path, dataSetCode, contentNode, response, acceptor, cont
nodeName = childNode.getName() nodeName = childNode.getName()
filePath = "%s/%s" % (path, nodeName) filePath = "%s/%s" % (path, nodeName)
filePermId = "%s::%s" % (dataSetCode, childNode.getRelativePath()) filePermId = "%s::%s" % (dataSetCode, childNode.getRelativePath())
context.getCache().putNode(Node("DATASET", filePermId), filePath) context.getCache().putNode(NodeWithEntityType("DATASET", filePermId, None), filePath)
if response is not None: if response is not None:
if childNode.isDirectory(): if childNode.isDirectory():
response.addDirectory(nodeName, childNode.getLastModified()) response.addDirectory(nodeName, childNode.getLastModified())
...@@ -346,8 +355,6 @@ def listDataSets(path, dataSetSearchCriteria, assignedToSample, response, accept ...@@ -346,8 +355,6 @@ def listDataSets(path, dataSetSearchCriteria, assignedToSample, response, accept
fetchOptions.withProperties() fetchOptions.withProperties()
fetchOptions.withSample() fetchOptions.withSample()
dataSets = context.getApi().searchDataSets(context.getSessionToken(), dataSetSearchCriteria, fetchOptions).getObjects() dataSets = context.getApi().searchDataSets(context.getSessionToken(), dataSetSearchCriteria, fetchOptions).getObjects()
print(">>>> data set search criteria: %s" % dataSetSearchCriteria)
print(">>>> data sets: %s" % dataSets)
entitiesByName = {} entitiesByName = {}
for dataSet in dataSets: for dataSet in dataSets:
sample = dataSet.getSample() sample = dataSet.getSample()
...@@ -376,7 +383,9 @@ def addNodes(nodeType, entitiesByName, parentPath, response, context): ...@@ -376,7 +383,9 @@ def addNodes(nodeType, entitiesByName, parentPath, response, context):
for entity in entities: for entity in entities:
nodeName = name if len(entities) == 1 else "%s [%s]" % (name, entity.getCode()) nodeName = name if len(entities) == 1 else "%s [%s]" % (name, entity.getCode())
path = "%s/%s" % (parentPath, nodeName) path = "%s/%s" % (parentPath, nodeName)
context.getCache().putNode(Node(nodeType, entity.getPermId().getPermId()), path) entityTypeCode = entity.getType().getCode()
entityPermId = entity.getPermId().getPermId()
context.getCache().putNode(NodeWithEntityType(nodeType, entityPermId, entityTypeCode), path)
if response is not None: if response is not None:
response.addDirectory(nodeName, entity.getModificationDate()) response.addDirectory(nodeName, entity.getModificationDate())
......
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