From 710a40da784ffb8fe53e938df289ca69a47ee98f Mon Sep 17 00:00:00 2001 From: buczekp <buczekp> Date: Tue, 19 Jan 2010 08:50:15 +0000 Subject: [PATCH] [LMS-1341] fixed contained sample code indexing SVN: 14335 --- .../server/dataaccess/db/HibernateSearchDAO.java | 1 + .../cisd/openbis/generic/shared/dto/SamplePE.java | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/HibernateSearchDAO.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/HibernateSearchDAO.java index ce8477e358f..a9c8a0944a8 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/HibernateSearchDAO.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/HibernateSearchDAO.java @@ -317,6 +317,7 @@ final class HibernateSearchDAO extends HibernateDaoSupport implements IHibernate result.setTextFragment(matchingText); // IIdentifiable properties + // NOTE: for contained sample this code is full code with container code part result.setCode(getFieldValue(doc, SearchFieldConstants.CODE)); result.setId(Long.parseLong(getFieldValue(doc, SearchFieldConstants.ID))); result.setIdentifier(getFieldValue(doc, SearchFieldConstants.IDENTIFIER)); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/SamplePE.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/SamplePE.java index d8867ef81d5..4d544d44878 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/SamplePE.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/dto/SamplePE.java @@ -369,12 +369,21 @@ public class SamplePE extends AttachmentHolderPE implements IIdAndCodeHolder, Co @NotNull(message = ValidationMessages.CODE_NOT_NULL_MESSAGE) @Length(min = 1, max = Code.CODE_LENGTH_MAX, message = ValidationMessages.CODE_LENGTH_MESSAGE) @Pattern(regex = AbstractIdAndCodeHolder.CODE_PATTERN, flags = java.util.regex.Pattern.CASE_INSENSITIVE, message = ValidationMessages.CODE_PATTERN_MESSAGE) - @Field(index = Index.TOKENIZED, store = Store.YES, name = SearchFieldConstants.CODE) public String getCode() { return code; } + // used only by Hibernate Search + @SuppressWarnings("unused") + @Transient + @Field(index = Index.TOKENIZED, store = Store.YES, name = SearchFieldConstants.CODE) + private String getFullCode() + { + // full code of contained sample consists of <container code>:<contained sample code> + return (getContainer() != null ? getContainer().getCode() + ":" : "") + getCode(); + } + @Column(name = ColumnNames.REGISTRATION_TIMESTAMP_COLUMN, nullable = false, insertable = false, updatable = false) @Generated(GenerationTime.INSERT) public Date getRegistrationDate() -- GitLab