Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
LinkAhead Sample Management
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
LinkAhead Sample Management
Commits
2127218c
Commit
2127218c
authored
3 months ago
by
Florian Spreckelsen
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Make more rt and property names configurable
parent
67b31746
No related branches found
No related tags found
1 merge request
!1
F awi sams
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sample-management-custom/caosdb-server/scripting/bin/update_containers.py
+27
-31
27 additions, 31 deletions
...t-custom/caosdb-server/scripting/bin/update_containers.py
with
27 additions
and
31 deletions
sample-management-custom/caosdb-server/scripting/bin/update_containers.py
+
27
−
31
View file @
2127218c
...
...
@@ -211,64 +211,60 @@ def main():
logger
.
warning
(
f
"
There is no PI with ID or
{
get_entity_name
(
'
abbreviation_prop
'
)
}
{
pi
}
.
Skipping
.
"
)
# Collection(s)
if _value_in_row(
"
Collection
"
, row)
:
collection_rt
=
cached_get_entity_by
(
query
=
"
FIND RECORDTYPE Collection
"
)
if
not
"
;
"
in
str
(
row
[
"
Collection
"
])
:
collections
=
[
row
[
"
Collection
"
]]
if _value_in_row(
get_column_header_name(
"
Collection
"
)
, row)
:
collection_rt
=
cached_get_entity_by
(
query
=
f
"
FIND RECORDTYPE
'
{
get_entity_name
(
'
Collection
'
)
}
'
"
)
if not
"
;
"
in str(row[
get_column_header_name(
"
Collection
"
)
])
:
collections
=
[
row
[
get_column_header_name
(
"
Collection
"
)
]]
else
:
collections
=
[
coll
.
strip
()
for
coll
in
str
(
row
[
"
Collection
"
]).
split
(
'
;
'
)]
collections
=
[
coll
.
strip
()
for
coll
in
str
(
row
[
get_column_header_name
(
"
Collection
"
)
]).
split
(
'
;
'
)]
prop_val
=
[]
for
coll
in
collections
:
try
:
query
=
f
"
FIND
RECORD C
ollection WITH ID=
{
int
(
coll
)
}
"
query
=
f
"
FIND
'
{
c
ollection
_rt
.
name
}
'
WITH ID=
{
int
(
coll
)
}
"
except ValueError
:
query
=
f
"
FIND RECORD
C
ollection WITH name=
'
{
coll
}
'"
query
=
f
"
FIND RECORD
'
{
c
ollection
_rt
.
name
}
'
WITH name=
'
{
coll
}
'"
try
:
coll_rec
=
cached_get_entity_by
(
query
=
query
)
prop_val
.
append
(
coll_rec
.
id
)
except
db
.
EmptyUniqueQueryError
:
logger
.
warning
(
f
"
There is no collection with name or
BIS
ID
{
coll
}
.
Skipping
.
"
)
logger
.
warning
(
f
"
There is no
{
collection
_rt
.
name
}
with
name
or
ID
{
coll
}
.
Skipping
.
"
)
continue
if prop_val
:
if
child
.
get_property
(
"
C
ollection
"
)
is
not
None
:
child
.
get_property
(
"
C
ollection
"
).
datatype
=
db
.
LIST
(
"
C
ollection
"
)
child
.
get_property
(
"
C
ollection
"
).
value
=
prop_val
if
child
.
get_property
(
c
ollection
_rt
.
name
)
is
not
None
:
child
.
get_property
(
c
ollection
_rt
.
name
).
datatype
=
db
.
LIST
(
c
ollection
_rt
.
name
)
child
.
get_property
(
c
ollection
_rt
.
name
).
value
=
prop_val
else
:
child
.
add_property
(
id
=
collection_rt
.
id
,
name
=
collection_rt
.
name
,
datatype
=
db
.
LIST
(
"
C
ollection
"
),
value
=
prop_val
)
c
ollection
_rt
.
name
),
value
=
prop_val
)
# Treat Container Contents
if
_value_in_row
(
"
Container Contents
"
,
row
)
:
if
not
(
_value_in_row
(
"
PI
"
,
row
)
and
_value_in_row
(
"
Collection
"
,
row
))
:
logger
.
error
(
f
"
Container Contents are given for container
{
child
.
id
}
but
it
"
"
is
missing
PI
and
/
or
Collection
info
.
No
updates
have
been
performed
.
"
)
return 1
contents_prop = cached_get_entity_by(query=
"
FIND
PROPERTY
'
Container Contents
'"
)
if
_value_in_row
(
get_column_header_name
(
"
Container Contents
"
),
row
)
:
contents_prop
=
cached_get_entity_by
(
query
=
f
"
FIND PROPERTY
'
{
get_entity_name
(
'
Container Contents
'
)
}
'"
)
if child.get_property(contents_prop.name) is not None
:
child
.
get_property
(
contents_prop
.
name
).
value
=
row
[
"
Container Contents
"
]
child
.
get_property
(
contents_prop
.
name
).
value
=
row
[
get_column_header_name
(
"
Container Contents
"
)
]
else
:
child
.
add_property
(
id
=
contents_prop
.
id
,
name
=
contents_prop
.
name
,
value
=
row
[
"
Container Contents
"
])
value
=
row
[
get_column_header_name
(
"
Container Contents
"
)
])
# Treat PDF Report
if
_value_in_row
(
"
PDFReport
"
,
row
)
:
pdf_id
=
row
[
"
PDFReport
"
]
if
_value_in_row
(
get_column_header_name
(
"
PDFReport
"
)
,
row
)
:
pdf_id
=
row
[
get_column_header_name
(
"
PDFReport
"
)
]
try
:
pdf_id
=
int
(
pdf_id
)
pdf_rec
=
cached_query
(
f
"
FIND FILE PDFReport WITH ID=
{
pdf_id
}
"
)
pdf_rec
=
cached_query
(
f
"
FIND FILE
{
get_entity_name
(
'
PDFReport
'
)
}
WITH
ID
=
{
pdf_id
}
"
)
if not pdf_rec
:
logger
.
warning
(
f
"
There is no PDFReport with
Bis
ID
{
pdf_id
}
,
so
no
PDF
is
attached
to
container
{
child
.
id
}
.
"
)
f
"
There is no PDFReport with ID
{
pdf_id
}
,
so
no
PDF
is
attached
to
container
{
child
.
id
}
.
"
)
else
:
if
child
.
get_property
(
"
PDFReport
"
)
is
not
None
:
child
.
get_property
(
"
PDFReport
"
).
value
=
pdf_id
if
child
.
get_property
(
get_entity_name
(
"
PDFReport
"
)
)
is
not
None
:
child
.
get_property
(
get_property
(
"
PDFReport
"
)
)
.
value
=
pdf_id
else
:
child
.
add_property
(
id
=
pdf_rt
.
id
,
name
=
pdf_rt
.
name
,
value
=
pdf_id
)
except
ValueError
:
logger
.
warning
(
f
"
There is no valid
Bis
ID provided for container
{
child
.
id
}
.
"
f
"
There is no valid ID provided for container
{
child
.
id
}
.
"
f
"
Provided
was
{
pdf_id
}
.
Skipping
"
)
# This is a workaround for weird merging errors in the
...
...
@@ -276,13 +272,13 @@ def main():
# following release.
merged
=
[]
for
par
in
parent_containers
:
if
(
data
[
'
BIS ID
'
]
==
par
.
id
).
any
()
:
if
(
data
[
id_column_name
]
==
par
.
id
).
any
()
:
# A container to be updated is used as another containers parent
:
child
=
child_containers
.
get_entity_by_id
(
par
.
id
)
# All parents have a child sample property with a value (which may
# be empty). No child sample has this property, so the following is
# okay without checks
:
prop
=
par
.
get_property
(
"
C
hild
container
"
)
prop
=
par
.
get_property
(
c
hild
_
container
_prop
.
name
)
child
.
add_property
(
name
=
prop
.
name
,
id
=
prop
.
id
,
value
=
prop
.
value
)
merged
.
append
(
par
)
for
par
in
merged
:
...
...
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