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
4c533c3f
Commit
4c533c3f
authored
14 years ago
by
buczekp
Browse files
Options
Downloads
Patches
Plain Diff
[LMS-2145] improved scripts (added actions for yeast parents, strip input)
SVN: 20392
parent
aa9d500b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
plasmid/resource/jython-scripts/MP-plasmid_parents.py
+13
-12
13 additions, 12 deletions
plasmid/resource/jython-scripts/MP-plasmid_parents.py
plasmid/resource/jython-scripts/MP-yeast_parents.py
+88
-2
88 additions, 2 deletions
plasmid/resource/jython-scripts/MP-yeast_parents.py
with
101 additions
and
14 deletions
plasmid/resource/jython-scripts/MP-plasmid_parents.py
+
13
−
12
View file @
4c533c3f
...
...
@@ -227,7 +227,7 @@ def configureUI():
"""
Define and add actions with input fields used to:
1. specify attributes of new
log entry
,
1. specify attributes of new
plasmid relationship
,
"""
addAction
=
uiDescription
.
addTableAction
(
ADD_ACTION_LABEL
)
\
.
setDescription
(
'
Add new plasmid relationship:
'
)
...
...
@@ -246,7 +246,7 @@ def configureUI():
addAction
.
addInputWidgets
(
widgets
)
"""
2. modify attributes of a selected
log entry
,
2. modify attributes of a selected
plasmid relationship
,
"""
editAction
=
uiDescription
.
addTableAction
(
EDIT_ACTION_LABEL
)
\
.
setDescription
(
'
Edit selected plasmid relationship:
'
)
...
...
@@ -269,7 +269,7 @@ def configureUI():
editAction
.
addBinding
(
ANNOTATION_LABEL
,
ANNOTATION_LABEL
)
"""
3. delete selected
log entrie
s.
3. delete selected
plasmid relationship
s.
"""
deleteAction
=
uiDescription
.
addTableAction
(
DELETE_ACTION_LABEL
)
\
.
setDescription
(
'
Are you sure you want to delete selected plasmid relationships?
'
)
...
...
@@ -285,31 +285,32 @@ def updateFromUI(action):
"""
Implement behaviour of user actions.
"""
if
action
.
name
==
ADD_ACTION_LABEL
:
"""
For
'
add
'
action create new plasmid
entry
element with values from input fields
For
'
add
'
action create new plasmid
relationship
element with values from input fields
and add it to existing elements.
"""
code
=
action
.
getInputValue
(
CODE_LABEL
)
relationshipLabel
=
action
.
getInputValue
(
RELATIONSHIP_LABEL
)
code
=
action
.
getInputValue
(
CODE_LABEL
)
.
strip
()
relationshipLabel
=
action
.
getInputValue
(
RELATIONSHIP_LABEL
)
.
strip
()
relationship
=
_translateFromLabel
(
relationshipLabel
)
annotation
=
action
.
getInputValue
(
ANNOTATION_LABEL
)
annotation
=
action
.
getInputValue
(
ANNOTATION_LABEL
)
.
strip
()
sampleLink
=
_createSampleLink
(
code
,
relationship
,
annotation
)
elements
.
append
(
sampleLink
)
elif
action
.
name
==
EDIT_ACTION_LABEL
:
"""
For
'
edit
'
action find the plasmid
entry
element corresponding to selected row
For
'
edit
'
action find the plasmid
relationship
element corresponding to selected row
and replace it with an element with values from input fields.
"""
code
=
action
.
getInputValue
(
CODE_LABEL
)
relationshipLabel
=
action
.
getInputValue
(
RELATIONSHIP_LABEL
)
code
=
action
.
getInputValue
(
CODE_LABEL
)
.
strip
()
relationshipLabel
=
action
.
getInputValue
(
RELATIONSHIP_LABEL
)
.
strip
()
relationship
=
_translateFromLabel
(
relationshipLabel
)
annotation
=
action
.
getInputValue
(
ANNOTATION_LABEL
)
annotation
=
action
.
getInputValue
(
ANNOTATION_LABEL
)
.
strip
()
sampleLink
=
_createSampleLink
(
code
,
relationship
,
annotation
)
selectedRowId
=
action
.
getSelectedRows
()[
0
]
elements
[
selectedRowId
]
=
sampleLink
elif
action
.
name
==
DELETE_ACTION_LABEL
:
"""
For
'
delete
'
action delete the
entrie
s that correspond to selected rows.
For
'
delete
'
action delete the
relationship
s that correspond to selected rows.
NOTE: As many rows can be deleted at once it is easier to delete them in reversed order.
"""
rowIds
=
list
(
action
.
getSelectedRows
())
...
...
This diff is collapsed.
Click to expand it.
plasmid/resource/jython-scripts/MP-yeast_parents.py
+
88
−
2
View file @
4c533c3f
...
...
@@ -16,6 +16,13 @@ ATR_CODE = "code"
LINK_LABEL
=
"
link
"
CODE_LABEL
=
"
code
"
"""
action labels
"""
ADD_ACTION_LABEL
=
"
Add
"
EDIT_ACTION_LABEL
=
"
Edit
"
DELETE_ACTION_LABEL
=
"
Delete
"
"""
helper functions
"""
def
_createSampleLink
(
code
):
"""
...
...
@@ -68,5 +75,84 @@ def configureUI():
"""
Specify that the property should be shown in a tab and set the table output.
"""
property
.
setOwnTab
(
True
)
uiDesc
=
property
.
getUiDescription
()
uiDesc
.
useTableOutput
(
tableBuilder
.
getTableModel
())
\ No newline at end of file
uiDescription
=
property
.
getUiDescription
()
uiDescription
.
useTableOutput
(
tableBuilder
.
getTableModel
())
"""
Define and add actions with input fields used to:
1. specify attributes of new yeast parent,
"""
addAction
=
uiDescription
.
addTableAction
(
ADD_ACTION_LABEL
)
\
.
setDescription
(
'
Add new plasmid relationship:
'
)
widgets
=
[
inputWidgetFactory
().
createTextInputField
(
CODE_LABEL
)
\
.
setMandatory
(
True
)
\
.
setValue
(
'
FRY
'
)
\
.
setDescription
(
'
Code of yeast parent sample, e.g.
"
FRY1
"'
)
]
addAction
.
addInputWidgets
(
widgets
)
"""
2. modify attributes of a selected yeast parent,
"""
editAction
=
uiDescription
.
addTableAction
(
EDIT_ACTION_LABEL
)
\
.
setDescription
(
'
Edit selected plasmid relationship:
'
)
# Exactly 1 row needs to be selected to enable action.
editAction
.
setRowSelectionRequiredSingle
()
widgets
=
[
inputWidgetFactory
().
createTextInputField
(
CODE_LABEL
)
\
.
setMandatory
(
True
)
\
.
setDescription
(
'
Code of yeast parent sample, e.g.
"
FRY1
"'
),
]
editAction
.
addInputWidgets
(
widgets
)
# Bind field name with column name.
editAction
.
addBinding
(
CODE_LABEL
,
CODE_LABEL
)
"""
3. delete selected yeast parents.
"""
deleteAction
=
uiDescription
.
addTableAction
(
DELETE_ACTION_LABEL
)
\
.
setDescription
(
'
Are you sure you want to delete selected yeast parent relationships?
'
)
# Delete is enabled when at least 1 row is selected.
deleteAction
.
setRowSelectionRequired
()
def
updateFromUI
(
action
):
"""
Extract list of elements from old value of the property.
"""
converter
=
propertyConverter
()
elements
=
list
(
converter
.
convertToElements
(
property
))
"""
Implement behaviour of user actions.
"""
if
action
.
name
==
ADD_ACTION_LABEL
:
"""
For
'
add
'
action create new yeast parent element with values from input fields
and add it to existing elements.
"""
code
=
action
.
getInputValue
(
CODE_LABEL
).
strip
()
sampleLink
=
_createSampleLink
(
code
)
elements
.
append
(
sampleLink
)
elif
action
.
name
==
EDIT_ACTION_LABEL
:
"""
For
'
edit
'
action find the yeast parent element corresponding to selected row
and replace it with an element with values from input fields.
"""
code
=
action
.
getInputValue
(
CODE_LABEL
).
strip
()
sampleLink
=
_createSampleLink
(
code
)
selectedRowId
=
action
.
getSelectedRows
()[
0
]
elements
[
selectedRowId
]
=
sampleLink
elif
action
.
name
==
DELETE_ACTION_LABEL
:
"""
For
'
delete
'
action delete yeast parents that correspond to selected rows.
NOTE: As many rows can be deleted at once it is easier to delete them in reversed order.
"""
rowIds
=
list
(
action
.
getSelectedRows
())
rowIds
.
reverse
()
for
rowId
in
rowIds
:
elements
.
pop
(
rowId
)
else
:
raise
ValidationException
(
'
action not supported
'
)
"""
Update value of the managed property to XML string created from modified list of elements.
"""
property
.
value
=
converter
.
convertToString
(
elements
)
\ No newline at end of file
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