@@ -0,0 +1,2554 @@
+/**%0A * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.%0A * If a copy of the MPL was not distributed with this file, You can obtain one at%0A * http://mozilla.org/MPL/2.0/.%0A *%0A * This Source Code Form is also subject to the terms of the Health-Related Additional%0A * Disclaimer of Warranty and Limitation of Liability available at%0A * http://www.carewebframework.org/licensing/disclaimer.%0A */%0Apackage org.carewebframework.api.query;%0A%0Aimport java.util.Date;%0A%0Aimport org.carewebframework.common.DateRange;%0Aimport org.carewebframework.common.DateUtil;%0A%0Apublic class DateQueryFilter%3CT%3E extends AbstractQueryFilter%3CT%3E %7B%0A    %0A    public interface IDateTypeExtractor%3CT%3E %7B%0A        %0A        Date getDateByType(T result, DateType dateType);%0A    %7D%0A    %0A    /**%0A     * Type of date to be considered in a query.%0A     */%0A    public enum DateType %7B%0A        MEASURED, // When the entity was measured%0A        UPDATED, // When the entity was last updated%0A        CREATED; // When the entity was first created%0A    %7D%0A    %0A    private DateType dateType = DateType.MEASURED;%0A    %0A    private DateRange dateRange;%0A    %0A    private final IDateTypeExtractor%3CT%3E dateTypeExtractor;%0A    %0A    public DateQueryFilter(IDateTypeExtractor%3CT%3E dateTypeExtractor) %7B%0A        this.dateTypeExtractor = dateTypeExtractor;%0A    %7D%0A    %0A    /**%0A     * Filter result based on selected date range.%0A     */%0A    @Override%0A    public boolean include(T result) %7B%0A        return getDateRange().inRange(DateUtil.stripTime(dateTypeExtractor.getDateByType(result, dateType)), true, true);%0A    %7D%0A    %0A    @Override%0A    public boolean updateContext(IQueryContext context) %7B%0A        context.setParam(%22dateType%22, dateType);%0A        DateRange oldDateRange = (DateRange) context.getParam(%22dateRange%22);%0A        %0A        if (dateRange == null %7C%7C oldDateRange == null %7C%7C !oldDateRange.inRange(dateRange)) %7B%0A            context.setParam(%22dateRange%22, dateRange);%0A        %7D%0A        %0A        return context.hasChanged();%0A    %7D%0A    %0A    public DateType getDateType() %7B%0A        return dateType;%0A    %7D%0A    %0A    public void setDateType(DateType dateType) %7B%0A        if (this.dateType != dateType) %7B%0A            this.dateType = dateType;%0A            notifyListeners();%0A        %7D%0A    %7D%0A    %0A    public DateRange getDateRange() %7B%0A        return dateRange;%0A    %7D%0A    %0A    public void setDateRange(DateRange dateRange) %7B%0A        if (this.dateRange != dateRange) %7B%0A            this.dateRange = dateRange == null ? null : new DateRange(dateRange);%0A            notifyListeners();%0A        %7D%0A    %7D%0A    %0A%7D%0A

Add DateQueryFilter.