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
cc63a403
Commit
cc63a403
authored
5 years ago
by
Swen Vermeul
Browse files
Options
Downloads
Patches
Plain Diff
added update vocabulary (work in progress)
parent
3816bc8e
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
pybis/src/python/pybis/vocabulary.py
+21
-16
21 additions, 16 deletions
pybis/src/python/pybis/vocabulary.py
with
21 additions
and
16 deletions
pybis/src/python/pybis/vocabulary.py
+
21
−
16
View file @
cc63a403
...
@@ -14,7 +14,9 @@ class Vocabulary(OpenBisObject):
...
@@ -14,7 +14,9 @@ class Vocabulary(OpenBisObject):
self
.
_set_data
(
data
)
self
.
_set_data
(
data
)
self
.
__dict__
[
'
terms
'
]
=
data
[
'
terms
'
]
self
.
__dict__
[
'
terms
'
]
=
data
[
'
terms
'
]
if
terms
is
not
None
:
if
terms
is
None
:
self
.
__dict__
[
'
terms
'
]
=
[]
else
:
self
.
__dict__
[
'
terms
'
]
=
terms
self
.
__dict__
[
'
terms
'
]
=
terms
if
self
.
is_new
:
if
self
.
is_new
:
...
@@ -37,29 +39,28 @@ class Vocabulary(OpenBisObject):
...
@@ -37,29 +39,28 @@ class Vocabulary(OpenBisObject):
"""
"""
return
self
.
openbis
.
get_terms
(
vocabulary
=
self
.
code
)
return
self
.
openbis
.
get_terms
(
vocabulary
=
self
.
code
)
def
add_term
(
self
,
code
,
label
=
None
,
description
=
None
):
def
add_term
(
self
,
code
,
label
=
None
,
description
=
None
):
"""
Adds a term to this Vocabulary.
"""
Adds a term to this Vocabulary.
If Vocabulary is already persistent, it is added by adding a new VocabularyTerm object.
If Vocabulary is already persistent, it is added by adding a new VocabularyTerm object.
If Vocabulary is new, the term is added to the list of terms
If Vocabulary is new, the term is added to the list of terms
"""
"""
if
self
.
is_new
:
self
.
__dict__
[
'
terms
'
].
append
({
self
.
__dict__
[
'
terms
'
].
append
({
"
code
"
:
code
,
"
code
"
:
code
,
"
label
"
:
label
,
"
label
"
:
label
,
"
description
"
:
description
"
description
"
:
description
})
})
else
:
pass
def
save
(
self
):
def
save
(
self
):
terms
=
self
.
__dict__
[
'
terms
'
]
for
term
in
terms
:
term
[
"
@type
"
]
=
"
as.dto.vocabulary.create.VocabularyTermCreation
"
if
self
.
is_new
:
if
self
.
is_new
:
request
=
self
.
_new_attrs
(
'
createVocabularies
'
)
request
=
self
.
_new_attrs
(
'
createVocabularies
'
)
# add the VocabularyTerm datatype
if
terms
:
terms
=
self
.
__dict__
[
'
terms
'
]
request
[
'
params
'
][
1
][
0
][
'
terms
'
]
=
terms
for
term
in
terms
:
term
[
"
@type
"
]
=
"
as.dto.vocabulary.create.VocabularyTermCreation
"
request
[
'
params
'
][
1
][
0
][
'
terms
'
]
=
terms
resp
=
self
.
openbis
.
_post_request
(
self
.
openbis
.
as_v3
,
request
)
resp
=
self
.
openbis
.
_post_request
(
self
.
openbis
.
as_v3
,
request
)
if
VERBOSE
:
print
(
"
Vocabulary successfully created.
"
)
if
VERBOSE
:
print
(
"
Vocabulary successfully created.
"
)
...
@@ -69,6 +70,12 @@ class Vocabulary(OpenBisObject):
...
@@ -69,6 +70,12 @@ class Vocabulary(OpenBisObject):
else
:
else
:
request
=
self
.
_up_attrs
(
'
updateVocabularies
'
)
request
=
self
.
_up_attrs
(
'
updateVocabularies
'
)
request
[
'
params
'
][
1
][
0
][
'
vocabularyId
'
]
=
{
"
@type
"
:
"
as.dto.vocabulary.id.IVocabularyId
"
,
"
vocabularyId
"
:
self
.
code
}
if
terms
:
request
[
'
params
'
][
1
][
0
][
'
terms
'
]
=
terms
self
.
openbis
.
_post_request
(
self
.
openbis
.
as_v3
,
request
)
self
.
openbis
.
_post_request
(
self
.
openbis
.
as_v3
,
request
)
if
VERBOSE
:
print
(
"
Vocabulary successfully updated.
"
)
if
VERBOSE
:
print
(
"
Vocabulary successfully updated.
"
)
data
=
self
.
openbis
.
get_vocabulary
(
self
.
permId
,
only_data
=
True
)
data
=
self
.
openbis
.
get_vocabulary
(
self
.
permId
,
only_data
=
True
)
...
@@ -81,7 +88,6 @@ class VocabularyTerm(OpenBisObject):
...
@@ -81,7 +88,6 @@ class VocabularyTerm(OpenBisObject):
self
.
__dict__
[
'
openbis
'
]
=
openbis_obj
self
.
__dict__
[
'
openbis
'
]
=
openbis_obj
self
.
__dict__
[
'
a
'
]
=
AttrHolder
(
openbis_obj
,
'
VocabularyTerm
'
)
self
.
__dict__
[
'
a
'
]
=
AttrHolder
(
openbis_obj
,
'
VocabularyTerm
'
)
if
data
is
not
None
:
if
data
is
not
None
:
self
.
_set_data
(
data
)
self
.
_set_data
(
data
)
...
@@ -89,7 +95,6 @@ class VocabularyTerm(OpenBisObject):
...
@@ -89,7 +95,6 @@ class VocabularyTerm(OpenBisObject):
for
key
in
kwargs
:
for
key
in
kwargs
:
setattr
(
self
,
key
,
kwargs
[
key
])
setattr
(
self
,
key
,
kwargs
[
key
])
@property
@property
def
vocabularyCode
(
self
):
def
vocabularyCode
(
self
):
if
self
.
is_new
:
if
self
.
is_new
:
...
...
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