diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/SearchCriteriaToDetailedSearchCriteriaTranslator.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/SearchCriteriaToDetailedSearchCriteriaTranslator.java index 1c5b222631b18a12ea04897becf5c0764d8e8305..e045d0c293517b68c75835c550e1339159cf5bc3 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/SearchCriteriaToDetailedSearchCriteriaTranslator.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/SearchCriteriaToDetailedSearchCriteriaTranslator.java @@ -17,6 +17,7 @@ package ch.systemsx.cisd.openbis.generic.server.api.v1; import java.util.ArrayList; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -25,6 +26,7 @@ import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.AttributeMatchClause; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.MatchClause; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.MatchClauseAttribute; +import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.MatchClauseFieldType; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.PropertyMatchClause; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchSubCriteria; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchableEntityKind; @@ -307,7 +309,11 @@ public class SearchCriteriaToDetailedSearchCriteriaTranslator private DetailedSearchCriterion convertMatchClauseToDetailedSearchCriterion( MatchClause matchClause) { - if (matchClause.getDesiredValue() == null) + + if (matchClause.getFieldType().equals(MatchClauseFieldType.ATTRIBUTE) + && (((AttributeMatchClause) matchClause).getAttribute().equals( + MatchClauseAttribute.REGISTRATION_DATE) || ((AttributeMatchClause) matchClause) + .getAttribute().equals(MatchClauseAttribute.MODIFICATION_DATE))) { CompareType t; switch (matchClause.getCompareMode()) @@ -325,7 +331,7 @@ public class SearchCriteriaToDetailedSearchCriteriaTranslator throw new IllegalArgumentException("" + matchClause.getCompareMode()); } return new DetailedSearchCriterion(extractDetailedSearchField(matchClause), t, - matchClause.getDate()); + new Date(Long.parseLong(matchClause.getDesiredValue()))); } else { return new DetailedSearchCriterion(extractDetailedSearchField(matchClause), diff --git a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/SearchCriteria.java b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/SearchCriteria.java index 9713a1ed8c31c06ed4e4f7566e32e00e93355526..be2579ea3dc28d6e4fbec7649aea6d5a552e64b7 100644 --- a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/SearchCriteria.java +++ b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/SearchCriteria.java @@ -125,8 +125,6 @@ public class SearchCriteria implements Serializable private String desiredValue; private CompareMode compareMode = CompareMode.EQUALS; - - private Date date; /** * Protected constructor. Use one of the factory methods to instantiate a MatchClause. @@ -135,13 +133,12 @@ public class SearchCriteria implements Serializable * @param fieldCode * @param desiredValue */ - protected MatchClause(MatchClauseFieldType fieldType, String fieldCode, String desiredValue, CompareMode compareMode, Date date) + protected MatchClause(MatchClauseFieldType fieldType, String fieldCode, String desiredValue, CompareMode compareMode) { this.fieldType = fieldType; this.fieldCode = fieldCode; this.desiredValue = desiredValue; this.compareMode = compareMode; - this.date = date; } /** @@ -195,11 +192,11 @@ public class SearchCriteria implements Serializable return desiredValue; } - public Date getDate() { - return date; - } public CompareMode getCompareMode() { + if (this.compareMode == null) { + return CompareMode.EQUALS; + } return this.compareMode; } @@ -221,7 +218,6 @@ public class SearchCriteria implements Serializable builder.append(getFieldCode(), other.getFieldCode()); builder.append(getDesiredValue(), other.getDesiredValue()); builder.append(getCompareMode(), other.getCompareMode()); - builder.append(getDate(), other.getDate()); return builder.isEquals(); } @@ -233,7 +229,6 @@ public class SearchCriteria implements Serializable builder.append(getFieldCode()); builder.append(getDesiredValue()); builder.append(getCompareMode()); - builder.append(getDate()); return builder.toHashCode(); } @@ -245,7 +240,6 @@ public class SearchCriteria implements Serializable builder.append(getFieldCode()); builder.append(getDesiredValue()); builder.append(getCompareMode()); - builder.append(getDate()); return builder.toString(); } @@ -273,9 +267,6 @@ public class SearchCriteria implements Serializable this.compareMode = mode; } - private void setDate(Date date) { - this.date = date; - } } /** @@ -298,7 +289,7 @@ public class SearchCriteria implements Serializable */ protected PropertyMatchClause(String propertyCode, String desiredValue) { - super(MatchClauseFieldType.PROPERTY, propertyCode, desiredValue, CompareMode.EQUALS, null); + super(MatchClauseFieldType.PROPERTY, propertyCode, desiredValue, CompareMode.EQUALS); this.propertyCode = propertyCode; assert null != propertyCode; assert null != desiredValue; @@ -346,13 +337,13 @@ public class SearchCriteria implements Serializable */ protected AttributeMatchClause(MatchClauseAttribute attribute, String desiredValue) { - super(MatchClauseFieldType.ATTRIBUTE, attribute.toString(), desiredValue, CompareMode.EQUALS, null); + super(MatchClauseFieldType.ATTRIBUTE, attribute.toString(), desiredValue, CompareMode.EQUALS); this.attribute = attribute; } - protected AttributeMatchClause(MatchClauseAttribute attribute, CompareMode mode, Date date) + protected AttributeMatchClause(MatchClauseAttribute attribute, CompareMode mode, Date desiredValue) { - super(MatchClauseFieldType.ATTRIBUTE, attribute.toString(), null, mode, date); + super(MatchClauseFieldType.ATTRIBUTE, attribute.toString(), Long.toString(desiredValue.getTime()), mode); this.attribute = attribute; }