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 ce8477e358ff15fe9ebab765bd4cee17d8fdca38..a9c8a0944a82b18977c662404b9ae8aaf4f33ef4 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 d8867ef81d51bf56be880613f18ff052c7b9fa5b..4d544d4487821ef730ebcdf8336c2511b191f780 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()