Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
3b05e121
Commit
3b05e121
authored
11 years ago
by
pkupczyk
Browse files
Options
Downloads
Patches
Plain Diff
SP-1118 / BIS-628 : iPad App for Aebersold Lab
SVN: 30400
parent
3f761ce4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
openbis-ipad/source/core-plugins/ipad-ui-tag-browser/1/dss/reporting-plugins/ipad-tag-browser-service/ipad_read.py
+146
-36
146 additions, 36 deletions
...s/reporting-plugins/ipad-tag-browser-service/ipad_read.py
with
146 additions
and
36 deletions
openbis-ipad/source/core-plugins/ipad-ui-tag-browser/1/dss/reporting-plugins/ipad-tag-browser-service/ipad_read.py
+
146
−
36
View file @
3b05e121
...
...
@@ -7,16 +7,30 @@ from ch.systemsx.cisd.openbis.generic.shared.basic.dto import MaterialIdentifier
from
com.fasterxml.jackson.databind
import
ObjectMapper
from
ch.systemsx.cisd.openbis.generic.shared.api.v1.dto
import
SearchCriteria
,
SearchSubCriteria
from
java.util
import
Date
from
java.util
import
HashMap
from
datetime
import
datetime
##########
# Request
##########
def
getEntitiesParameter
(
handler
):
entities
=
handler
.
getEntitiesParameter
();
for
entity
in
entities
:
refcon
=
entity
[
'
REFCON
'
]
if
type
(
refcon
)
==
str
or
type
(
refcon
)
==
unicode
:
refconMap
=
ObjectMapper
().
readValue
(
refcon
,
HashMap
().
getClass
())
entity
[
'
REFCON
'
]
=
refconMap
return
entities
###############
# Dictionaries
###############
def
createTagDictionary
(
name
,
children
):
dictionary
=
{}
dictionary
[
'
PERM_ID
'
]
=
'
TAG
#
'
+
name
.
upper
()
dictionary
[
'
PERM_ID
'
]
=
'
TAG
.
'
+
name
.
upper
()
dictionary
[
'
CATEGORY
'
]
=
'
Navigation
'
dictionary
[
'
SUMMARY_HEADER
'
]
=
name
dictionary
[
'
SUMMARY
'
]
=
None
...
...
@@ -29,41 +43,41 @@ def createTagDictionary(name, children):
return
dictionary
def
create
Material
Dictionary
(
material
):
def
create
Experiment
Dictionary
(
experiment
):
dictionary
=
{}
dictionary
[
'
PERM_ID
'
]
=
'
MATERIAL#
'
+
material
.
getMaterialIdentifier
()
dictionary
[
'
CATEGORY
'
]
=
'
Material
'
+
material
.
getMaterial
Type
()
dictionary
[
'
SUMMARY_HEADER
'
]
=
material
.
getCode
()
dictionary
[
'
SUMMARY
'
]
=
material
.
getPropertyValue
(
"
DESC
"
)
dictionary
[
'
IDENTIFIER
'
]
=
material
.
getMaterial
Identifier
()
dictionary
[
'
IMAGES
'
]
=
[]
dictionary
[
'
CHILDREN
'
]
=
[]
dictionary
[
'
PERM_ID
'
]
=
'
EXPERIMENT.
'
+
experiment
.
getPermId
()
dictionary
[
'
CATEGORY
'
]
=
'
Experiment
'
+
experiment
.
getExperiment
Type
()
dictionary
[
'
SUMMARY_HEADER
'
]
=
experiment
.
getExperimentIdentifier
()
dictionary
[
'
SUMMARY
'
]
=
None
dictionary
[
'
IDENTIFIER
'
]
=
experiment
.
getExperiment
Identifier
()
dictionary
[
'
IMAGES
'
]
=
IpadServiceUtilities
.
jsonEncodedValue
(
[]
)
dictionary
[
'
CHILDREN
'
]
=
IpadServiceUtilities
.
jsonEncodedValue
(
[]
)
dictionary
[
'
ROOT_LEVEL
'
]
=
None
refcon
=
{}
refcon
[
'
ENTITY_TYPE
'
]
=
'
MATERIAL
'
refcon
[
'
CODE
'
]
=
material
.
getCode
()
refcon
[
'
TYPE_CODE
'
]
=
material
.
getMaterialType
()
;
refcon
[
'
ENTITY_TYPE
'
]
=
'
EXPERIMENT
'
# there is no way to get an experiment by a permanent id
refcon
[
'
IDENTIFIER
'
]
=
experiment
.
getExperimentIdentifier
()
dictionary
[
'
REFCON
'
]
=
IpadServiceUtilities
.
jsonEncodedValue
(
refcon
)
return
dictionary
def
create
Material
DetailedDictionary
(
material
):
dictionary
=
create
Material
Dictionary
(
material
)
propertyDefinitions
=
getPropertyDefinitions
(
material
.
getMaterial
Type
(),
searchService
.
listPropertiesDefinitionsFor
Material
Type
)
properties
=
getProperties
(
material
,
propertyDefinitions
)
def
create
Experiment
DetailedDictionary
(
experiment
):
dictionary
=
create
Experiment
Dictionary
(
experiment
)
propertyDefinitions
=
getPropertyDefinitions
(
experiment
.
getExperiment
Type
(),
searchService
.
listPropertiesDefinitionsFor
Experiment
Type
)
properties
=
getProperties
(
experiment
,
propertyDefinitions
)
dictionary
[
'
PROPERTIES
'
]
=
IpadServiceUtilities
.
jsonEncodedValue
(
properties
)
return
dictionary
def
createSampleDictionary
(
sample
):
dictionary
=
{}
dictionary
[
'
PERM_ID
'
]
=
'
SAMPLE
#
'
+
sample
.
getPermId
()
dictionary
[
'
PERM_ID
'
]
=
'
SAMPLE
.
'
+
sample
.
getPermId
()
dictionary
[
'
CATEGORY
'
]
=
'
Sample
'
+
sample
.
getSampleType
()
dictionary
[
'
SUMMARY_HEADER
'
]
=
sample
.
get
Code
()
dictionary
[
'
SUMMARY
'
]
=
sample
.
getPropertyValue
(
"
DESC
"
)
dictionary
[
'
SUMMARY_HEADER
'
]
=
sample
.
get
SampleIdentifier
()
dictionary
[
'
SUMMARY
'
]
=
None
dictionary
[
'
IDENTIFIER
'
]
=
sample
.
getSampleIdentifier
()
dictionary
[
'
IMAGES
'
]
=
[]
dictionary
[
'
CHILDREN
'
]
=
[]
dictionary
[
'
IMAGES
'
]
=
IpadServiceUtilities
.
jsonEncodedValue
(
[]
)
dictionary
[
'
CHILDREN
'
]
=
IpadServiceUtilities
.
jsonEncodedValue
(
[]
)
dictionary
[
'
ROOT_LEVEL
'
]
=
None
refcon
=
{}
...
...
@@ -79,14 +93,67 @@ def createSampleDetailedDictionary(sample):
properties
=
getProperties
(
sample
,
propertyDefinitions
)
dictionary
[
'
PROPERTIES
'
]
=
IpadServiceUtilities
.
jsonEncodedValue
(
properties
)
return
dictionary
def
createDataSetDictionary
(
dataSet
):
dictionary
=
{}
dictionary
[
'
PERM_ID
'
]
=
'
DATA_SET.
'
+
dataSet
.
getDataSetCode
()
dictionary
[
'
CATEGORY
'
]
=
'
Data set
'
+
dataSet
.
getDataSetType
()
dictionary
[
'
SUMMARY_HEADER
'
]
=
dataSet
.
getDataSetCode
()
dictionary
[
'
SUMMARY
'
]
=
None
dictionary
[
'
IDENTIFIER
'
]
=
dataSet
.
getDataSetCode
()
dictionary
[
'
IMAGES
'
]
=
IpadServiceUtilities
.
jsonEncodedValue
([])
dictionary
[
'
CHILDREN
'
]
=
IpadServiceUtilities
.
jsonEncodedValue
([])
dictionary
[
'
ROOT_LEVEL
'
]
=
None
refcon
=
{}
refcon
[
'
ENTITY_TYPE
'
]
=
'
DATA_SET
'
refcon
[
'
CODE
'
]
=
dataSet
.
getDataSetCode
()
dictionary
[
'
REFCON
'
]
=
IpadServiceUtilities
.
jsonEncodedValue
(
refcon
)
return
dictionary
def
createDataSetDetailedDictionary
(
dataSet
):
dictionary
=
createDataSetDictionary
(
dataSet
)
propertyDefinitions
=
getPropertyDefinitions
(
dataSet
.
getDataSetType
(),
searchService
.
listPropertiesDefinitionsForDataSetType
)
properties
=
getProperties
(
dataSet
,
propertyDefinitions
)
dictionary
[
'
PROPERTIES
'
]
=
IpadServiceUtilities
.
jsonEncodedValue
(
properties
)
return
dictionary
def
createMaterialDictionary
(
material
):
dictionary
=
{}
dictionary
[
'
PERM_ID
'
]
=
'
MATERIAL.
'
+
material
.
getMaterialIdentifier
()
dictionary
[
'
CATEGORY
'
]
=
'
Material
'
+
material
.
getMaterialType
()
dictionary
[
'
SUMMARY_HEADER
'
]
=
material
.
getMaterialIdentifier
()
dictionary
[
'
SUMMARY
'
]
=
None
dictionary
[
'
IDENTIFIER
'
]
=
material
.
getMaterialIdentifier
()
dictionary
[
'
IMAGES
'
]
=
IpadServiceUtilities
.
jsonEncodedValue
([])
dictionary
[
'
CHILDREN
'
]
=
IpadServiceUtilities
.
jsonEncodedValue
([])
dictionary
[
'
ROOT_LEVEL
'
]
=
None
refcon
=
{}
refcon
[
'
ENTITY_TYPE
'
]
=
'
MATERIAL
'
refcon
[
'
CODE
'
]
=
material
.
getCode
()
refcon
[
'
TYPE_CODE
'
]
=
material
.
getMaterialType
();
dictionary
[
'
REFCON
'
]
=
IpadServiceUtilities
.
jsonEncodedValue
(
refcon
)
return
dictionary
def
createMaterialDetailedDictionary
(
material
):
dictionary
=
createMaterialDictionary
(
material
)
propertyDefinitions
=
getPropertyDefinitions
(
material
.
getMaterialType
(),
searchService
.
listPropertiesDefinitionsForMaterialType
)
properties
=
getProperties
(
material
,
propertyDefinitions
)
dictionary
[
'
PROPERTIES
'
]
=
IpadServiceUtilities
.
jsonEncodedValue
(
properties
)
return
dictionary
#########
# Entity
#########
def
getExperiment
(
permId
):
pass
def
getExperiment
(
identifier
):
# there is no way to get an experiment by a permanent id
return
searchService
.
getExperiment
(
identifier
)
def
getSample
(
permId
):
criteria
=
SearchCriteria
()
criteria
.
setOperator
(
criteria
.
SearchOperator
.
MATCH_ANY_CLAUSES
)
...
...
@@ -98,10 +165,17 @@ def getSample(permId):
return
None
def
getDataSet
(
code
):
pass
criteria
=
SearchCriteria
()
criteria
.
setOperator
(
criteria
.
SearchOperator
.
MATCH_ANY_CLAUSES
)
criteria
.
addMatchClause
(
criteria
.
MatchClause
.
createAttributeMatch
(
criteria
.
MatchClauseAttribute
.
CODE
,
code
))
datasets
=
searchService
.
searchForDataSets
(
criteria
)
if
datasets
:
return
datasets
[
0
]
else
:
return
None
def
getMaterial
(
code
,
typeCode
):
pass
return
searchService
.
getMaterial
(
code
,
typeCode
)
####################
# Entity Properties
...
...
@@ -115,11 +189,13 @@ def getPropertyDefinitions(typeCode, searchFunction):
def
getProperties
(
entity
,
propertyDefinitions
):
properties
=
[]
for
propertyDefinition
in
propertyDefinitions
:
properties
.
append
({
'
key
'
:
propertyDefinition
.
getPropertyTypeCode
(),
'
label
'
:
propertyDefinition
.
getPropertyTypeLabel
(),
'
value
'
:
entity
.
getPropertyValue
(
propertyDefinition
.
getPropertyTypeCode
())
})
propertyValue
=
entity
.
getPropertyValue
(
propertyDefinition
.
getPropertyTypeCode
())
if
propertyValue
:
properties
.
append
({
'
key
'
:
propertyDefinition
.
getPropertyTypeCode
(),
'
label
'
:
propertyDefinition
.
getPropertyTypeLabel
(),
'
value
'
:
propertyValue
})
return
properties
###################
...
...
@@ -137,13 +213,33 @@ class TagRootRequestHandler(RootRequestHandler):
"""
Handler for the ROOT request.
"""
def
addDataRows
(
self
):
tagsPermIdsAndRefcons
=
self
.
getEntitiesParameter
()
tagsPermIdsAndRefcons
=
getEntitiesParameter
(
self
)
if
tagsPermIdsAndRefcons
:
tagName
=
tagsPermIdsAndRefcons
[
0
][
'
REFCON
'
][
'
NAME
'
]
samples
=
self
.
searchService
.
getMetaprojectAssignments
(
tagName
).
getSamples
();
self
.
addRows
([
createTagDictionary
(
tagName
,
[
sample
.
getPermId
()
for
sample
in
samples
])])
tagAssignments
=
self
.
searchService
.
getMetaprojectAssignments
(
tagName
)
experiments
=
tagAssignments
.
getExperiments
();
samples
=
tagAssignments
.
getSamples
();
dataSets
=
tagAssignments
.
getDataSets
();
materials
=
tagAssignments
.
getMaterials
();
tagChildren
=
[]
for
experiment
in
experiments
:
tagChildren
.
append
(
'
EXPERIMENT.
'
+
experiment
.
getPermId
())
for
sample
in
samples
:
tagChildren
.
append
(
'
SAMPLE.
'
+
sample
.
getPermId
())
for
dataSet
in
dataSets
:
tagChildren
.
append
(
'
DATA_SET.
'
+
dataSet
.
getDataSetCode
())
for
material
in
materials
:
tagChildren
.
append
(
'
MATERIAL.
'
+
material
.
getMaterialIdentifier
())
self
.
addRows
([
createTagDictionary
(
tagName
,
tagChildren
)])
self
.
addRows
([
createExperimentDictionary
(
experiment
)
for
experiment
in
experiments
])
self
.
addRows
([
createSampleDictionary
(
sample
)
for
sample
in
samples
])
self
.
addRows
([
createDataSetDictionary
(
dataSet
)
for
dataSet
in
dataSets
])
self
.
addRows
([
createMaterialDictionary
(
material
)
for
material
in
materials
])
class
TagDrillRequestHandler
(
DrillRequestHandler
):
"""
Handler for the DRILL request.
"""
...
...
@@ -152,15 +248,24 @@ class TagDetailRequestHandler(DetailRequestHandler):
"""
Handler for the DETAIL request.
"""
def
addDataRows
(
self
):
entitiesPermIdsAndRefcons
=
self
.
getEntitiesParameter
()
entitiesPermIdsAndRefcons
=
getEntitiesParameter
(
self
)
if
entitiesPermIdsAndRefcons
:
entityRefcon
=
entitiesPermIdsAndRefcons
[
0
][
'
REFCON
'
]
entityType
=
entityRefcon
[
'
ENTITY_TYPE
'
];
if
'
EXPERIMENT
'
==
entityType
:
experiment
=
getExperiment
(
entityRefcon
[
'
IDENTIFIER
'
])
self
.
addRows
([
createExperimentDetailedDictionary
(
experiment
)])
if
'
SAMPLE
'
==
entityType
:
sample
=
getSample
(
entityRefcon
[
'
PERM_ID
'
])
self
.
addRows
([
createSampleDetailedDictionary
(
sample
)])
if
'
DATA_SET
'
==
entityType
:
dataSet
=
getDataSet
(
entityRefcon
[
'
CODE
'
])
self
.
addRows
([
createDataSetDetailedDictionary
(
dataSet
)])
if
'
MATERIAL
'
==
entityType
:
material
=
getMaterial
(
entityRefcon
[
'
CODE
'
],
entityRefcon
[
'
TYPE_CODE
'
])
self
.
addRows
([
createMaterialDetailedDictionary
(
material
)])
class
TagSearchRequestHandler
(
SearchRequestHandler
):
"""
Handler for the SEARCH request
"""
...
...
@@ -168,8 +273,13 @@ class TagSearchRequestHandler(SearchRequestHandler):
def
addDataRows
(
self
):
criteria
=
self
.
trySearchCriteria
()
if
criteria
:
# there is no way to search for experiments and materials
samples
=
self
.
searchService
.
searchForSamples
(
criteria
)
self
.
addRows
([
createSampleDictionary
(
sample
)
for
sample
in
samples
])
dataSets
=
self
.
searchService
.
searchForDataSets
(
criteria
)
self
.
addRows
([
createDataSetDictionary
(
dataSet
)
for
dataSet
in
dataSets
])
####################
# Request Factories
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment