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
411aee18
Commit
411aee18
authored
15 years ago
by
buczekp
Browse files
Options
Downloads
Patches
Plain Diff
[LMS-1176] fixed - changed NewSample equality
SVN: 14401
parent
4ee42179
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/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/NewSample.java
+30
-1
30 additions, 1 deletion
...emsx/cisd/openbis/generic/shared/basic/dto/NewSample.java
with
30 additions
and
1 deletion
openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/NewSample.java
+
30
−
1
View file @
411aee18
...
@@ -25,7 +25,7 @@ import ch.systemsx.cisd.common.annotation.BeanProperty;
...
@@ -25,7 +25,7 @@ import ch.systemsx.cisd.common.annotation.BeanProperty;
*
*
* @author Christian Ribeaud
* @author Christian Ribeaud
*/
*/
public
class
NewSample
extends
Identifier
<
NewSample
>
public
class
NewSample
extends
Identifier
<
NewSample
>
implements
Comparable
<
NewSample
>
{
{
private
static
final
long
serialVersionUID
=
ServiceVersionHolder
.
VERSION
;
private
static
final
long
serialVersionUID
=
ServiceVersionHolder
.
VERSION
;
...
@@ -157,4 +157,33 @@ public class NewSample extends Identifier<NewSample>
...
@@ -157,4 +157,33 @@ public class NewSample extends Identifier<NewSample>
{
{
return
getIdentifier
();
return
getIdentifier
();
}
}
// NOTE:
// Special equality check for NewSamples that is not complete but speeds up uniqueness check
// of new sample codes during import. The check on the DB level is complete.
//
// Here we compare a pair of container's identifier and new sample's identifier.
// 1. This comparison doesn't have the knowledge about home group so it will say that
// 'SAMPLE_1' != /HOME_GROUP/SAMPLE_1'.
// 2. We need to also use container identifier because when samples are registered container
// code is not required in its identifier.
//
// So this equals may return 'false' for NewSample objects that would in fact create
// samples with the same identifiers, but when it returns 'true' it is always correct.
@Override
public
final
boolean
equals
(
final
Object
obj
)
{
if
(
obj
==
this
)
{
return
true
;
}
if
(
obj
instanceof
NewSample
==
false
)
{
return
false
;
}
final
NewSample
that
=
(
NewSample
)
obj
;
final
String
thisCombinedIdentifier
=
this
.
getIdentifier
()
+
this
.
getContainerIdentifier
();
final
String
thatCombinedIdentifier
=
that
.
getIdentifier
()
+
that
.
getContainerIdentifier
();
return
thisCombinedIdentifier
.
equals
(
thatCombinedIdentifier
);
}
}
}
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