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
c0ad8070
Commit
c0ad8070
authored
2 years ago
by
juanf
Browse files
Options
Downloads
Patches
Plain Diff
SSDM-12864 : Updated parents/children delete behaviour
parent
3596c422
No related branches found
Branches containing commit
Tags
20.10.4
Tags containing commit
1 merge request
!54
20.10.10.1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
openbis/source/java/ch/ethz/sis/openbis/generic/server/xls/importer/helper/SampleImportHelper.java
+52
-30
52 additions, 30 deletions
...eneric/server/xls/importer/helper/SampleImportHelper.java
with
52 additions
and
30 deletions
openbis/source/java/ch/ethz/sis/openbis/generic/server/xls/importer/helper/SampleImportHelper.java
+
52
−
30
View file @
c0ad8070
...
...
@@ -276,53 +276,75 @@ public class SampleImportHelper extends BasicImportHelper
// Start - Special case -> Remove parents / children & Special case -> Sample Variables
Sample
originSample
=
delayedExecutor
.
getSample
(
sampleId
,
fetchOptions
);
Set
<
SampleIdentifier
>
parentIds
=
new
HashSet
<>();
if
(
parents
!
=
null
&&
!
parents
.
isEmpty
())
if
(
parents
=
=
null
||
parents
.
isEmpty
())
{
for
(
String
parent
:
parents
.
split
(
"\n"
))
// Skip empty values to avoid deleting by mistake
}
else
{
Set
<
SampleIdentifier
>
parentIds
=
new
HashSet
<>();
if
(
parents
.
equals
(
"--DELETE--"
)
||
parents
.
equals
(
"__DELETE__"
))
{
if
(
parent
.
startsWith
(
VARIABLE_PREFIX
))
{
update
.
getParentIds
().
add
(
new
IdentifierVariable
(
parent
));
}
else
// Delete missing = all
}
else
// Delete missing
{
for
(
String
parent
:
parents
.
split
(
"\n"
))
{
SampleIdentifier
parentId
=
new
SampleIdentifier
(
parent
);
update
.
getParentIds
().
add
(
parentId
);
parentIds
.
add
(
parentId
);
if
(
parent
.
startsWith
(
VARIABLE_PREFIX
))
{
update
.
getParentIds
().
add
(
new
IdentifierVariable
(
parent
));
}
else
{
SampleIdentifier
parentId
=
new
SampleIdentifier
(
parent
);
update
.
getParentIds
().
add
(
parentId
);
parentIds
.
add
(
parentId
);
}
}
}
}
for
(
Sample
parent
:
originSample
.
getParents
())
{
if
(!
parentIds
.
contains
(
parent
.
getIdentifier
()))
for
(
Sample
parent
:
originSample
.
getParents
())
{
update
.
getParentIds
().
remove
(
parent
.
getIdentifier
());
if
(!
parentIds
.
contains
(
parent
.
getIdentifier
()))
{
update
.
getParentIds
().
remove
(
parent
.
getIdentifier
());
}
}
}
Set
<
SampleIdentifier
>
childrenIds
=
new
HashSet
<>();
if
(
children
!=
null
&&
!
children
.
isEmpty
())
if
(
children
==
null
||
children
.
isEmpty
())
{
for
(
String
child
:
children
.
split
(
"\n"
))
// Skip empty values to avoid deleting by mistake
}
else
{
Set
<
SampleIdentifier
>
childrenIds
=
new
HashSet
<>();
if
(
children
.
equals
(
"--DELETE--"
)
||
children
.
equals
(
"__DELETE__"
))
{
if
(
child
.
startsWith
(
VARIABLE_PREFIX
))
{
update
.
getChildIds
().
add
(
new
IdentifierVariable
(
child
));
}
else
// Delete missing = all
}
else
// Delete missing
{
for
(
String
child
:
children
.
split
(
"\n"
))
{
SampleIdentifier
childId
=
new
SampleIdentifier
(
child
);
update
.
getChildIds
().
add
(
childId
);
childrenIds
.
add
(
childId
);
if
(
child
.
startsWith
(
VARIABLE_PREFIX
))
{
update
.
getChildIds
().
add
(
new
IdentifierVariable
(
child
));
}
else
{
SampleIdentifier
childId
=
new
SampleIdentifier
(
child
);
update
.
getChildIds
().
add
(
childId
);
childrenIds
.
add
(
childId
);
}
}
}
}
for
(
Sample
child
:
originSample
.
getChildren
())
{
if
(!
childrenIds
.
contains
(
child
.
getIdentifier
()))
for
(
Sample
child
:
originSample
.
getChildren
())
{
update
.
getChildIds
().
remove
(
child
.
getIdentifier
());
if
(!
childrenIds
.
contains
(
child
.
getIdentifier
()))
{
update
.
getChildIds
().
remove
(
child
.
getIdentifier
());
}
}
}
// End - Special case -> Remove parents / children & Special case -> Sample Variables
for
(
String
key
:
header
.
keySet
())
...
...
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