diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/search/DetailedSearchCriterionWidget.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/search/DetailedSearchCriterionWidget.java index 32d128cd6f2b0ed84f8f7f299f6d8f4e65428296..8327883e3f75cb3d43b8123dc891092f1a1545b5 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/search/DetailedSearchCriterionWidget.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/search/DetailedSearchCriterionWidget.java @@ -16,6 +16,9 @@ package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.search; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; import java.util.List; import com.extjs.gxt.ui.client.Style.HorizontalAlignment; @@ -36,6 +39,7 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.GenericCon import ch.systemsx.cisd.openbis.generic.client.web.client.application.IViewContext; import ch.systemsx.cisd.openbis.generic.client.web.client.application.model.DetailedSearchFieldComboModel; import ch.systemsx.cisd.openbis.generic.shared.basic.AttributeSearchFieldKindProvider; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.CompareType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DetailedSearchCriterion; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DetailedSearchField; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityKind; @@ -168,8 +172,8 @@ public class DetailedSearchCriterionWidget extends HorizontalPanel { DetailedSearchCriterionWidget newCriterion = new DetailedSearchCriterionWidget(parent, getChildId(), - new DetailedSearchFieldsSelectionWidget(nameField, getChildId(), nameField - .getEntityKind())); + new DetailedSearchFieldsSelectionWidget(nameField, getChildId(), + nameField.getEntityKind())); parent.addCriterion(newCriterion); generatedChildren++; } @@ -204,9 +208,47 @@ public class DetailedSearchCriterionWidget extends HorizontalPanel final String selectedValue = valueField.getValue(); final DetailedSearchField selectedFieldName = nameField.tryGetSelectedField(); + if (selectedFieldName != null && StringUtils.isBlank(selectedValue) == false) { - return new DetailedSearchCriterion(selectedFieldName, selectedValue); + String aCode = selectedFieldName.getAttributeCode(); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Date date; + try + { + date = sdf.parse(selectedValue); + } catch (ParseException ex) + { + return new DetailedSearchCriterion(selectedFieldName, selectedValue); + } + + CompareType compareType; + if ("REGISTRATION_DATE_BEFORE".equals(aCode)) + { + compareType = CompareType.LESS_THAN_OR_EQUAL; + } else if ("REGISTRATION_DATE".equals(aCode)) + { + compareType = CompareType.EQUALS; + } else if ("REGISTRATION_DATE_AFTER".equals(aCode)) + { + compareType = CompareType.MORE_THAN_OR_EQUAL; + } else if ("MODIFICATION_DATE_BEFORE".equals(aCode)) + { + compareType = CompareType.LESS_THAN_OR_EQUAL; + } else if ("MODIFICATION_DATE".equals(aCode)) + { + compareType = CompareType.EQUALS; + } else if ("MODIFICATION_DATE_AFTER".equals(aCode)) + { + compareType = CompareType.MORE_THAN_OR_EQUAL; + } else + { + return new DetailedSearchCriterion(selectedFieldName, selectedValue); + } + + return new DetailedSearchCriterion(selectedFieldName, compareType, date); + } return null; @@ -221,7 +263,14 @@ public class DetailedSearchCriterionWidget extends HorizontalPanel return null; } - return name + " = " + criterion.getValue(); + if (criterion.getValue() == null && criterion.getDate() != null) + { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + return name + " = " + sdf.format(criterion.getDate()); + } else + { + return name + " = " + criterion.getValue(); + } } public List<PropertyType> getAvailablePropertyTypes() diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/search/detailed/IndexFieldNameHelper.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/search/detailed/IndexFieldNameHelper.java index 258676665709ccbf4bf9af3ab560c181b60d4313..efe131e367a7955888d5d59ae106b720be5ad720 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/search/detailed/IndexFieldNameHelper.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/db/search/detailed/IndexFieldNameHelper.java @@ -131,8 +131,12 @@ class IndexFieldNameHelper case FILE_TYPE: return SearchFieldConstants.PREFIX_FILE_FORMAT_TYPE + CODE; case REGISTRATION_DATE: + case REGISTRATION_DATE_BEFORE: + case REGISTRATION_DATE_AFTER: return SearchFieldConstants.REGISTRATION_DATE; case MODIFICATION_DATE: + case MODIFICATION_DATE_BEFORE: + case MODIFICATION_DATE_AFTER: return SearchFieldConstants.MODIFICATION_DATE; } throw new IllegalArgumentException(attributeKind.toString()); @@ -180,8 +184,12 @@ class IndexFieldNameHelper case SPACE: return SearchFieldConstants.PREFIX_SPACE + CODE; case REGISTRATION_DATE: + case REGISTRATION_DATE_BEFORE: + case REGISTRATION_DATE_AFTER: return SearchFieldConstants.REGISTRATION_DATE; case MODIFICATION_DATE: + case MODIFICATION_DATE_BEFORE: + case MODIFICATION_DATE_AFTER: return SearchFieldConstants.MODIFICATION_DATE; } throw new IllegalArgumentException(attributeKind.toString()); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/DataSetAttributeSearchFieldKind.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/DataSetAttributeSearchFieldKind.java index 706b16b6ae300d91a91cdf06f1715464a442685e..5cf052034cf4aaccd59a2f68cad3ed7867b13dfe 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/DataSetAttributeSearchFieldKind.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/DataSetAttributeSearchFieldKind.java @@ -31,9 +31,17 @@ public enum DataSetAttributeSearchFieldKind implements Serializable, IAttributeS FILE_TYPE("File Type"), - REGISTRATION_DATE("Registration date"), + REGISTRATION_DATE("Registration date equals"), - MODIFICATION_DATE("Modification date"); + MODIFICATION_DATE("Modification date equals"), + + REGISTRATION_DATE_BEFORE("Registration date before"), + + MODIFICATION_DATE_BEFORE("Modification date before"), + + REGISTRATION_DATE_AFTER("Registration date after"), + + MODIFICATION_DATE_AFTER("Modification date after"); private final String description; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/SampleAttributeSearchFieldKind.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/SampleAttributeSearchFieldKind.java index 8d5d8320a9b1d551df91410af370a44fc7197541..3fe63044e937346c9236181d9093007c82cde6c4 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/SampleAttributeSearchFieldKind.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/SampleAttributeSearchFieldKind.java @@ -31,9 +31,17 @@ public enum SampleAttributeSearchFieldKind implements Serializable, IAttributeSe SPACE("Space"), - REGISTRATION_DATE("Registration date"), + REGISTRATION_DATE("Registration date equals"), - MODIFICATION_DATE("Modification date"); + MODIFICATION_DATE("Modification date equals"), + + REGISTRATION_DATE_BEFORE("Registration date before"), + + MODIFICATION_DATE_BEFORE("Modification date before"), + + REGISTRATION_DATE_AFTER("Registration date after"), + + MODIFICATION_DATE_AFTER("Modification date after"); private final String description;