Search in sources :

Example 1 with FilterSet

use of org.jmesa.limit.FilterSet in project OpenClinica by OpenClinica.

the class StudyAuditLogTableFactory method getAuditLogStudyFilter.

/**
     * A very custom way to filter the items. The AuditUserLoginFilter acts as a
     * command for the Hibernate criteria object. Take the Limit information and
     * filter the rows.
     *
     * @param limit
     *            The Limit to use.
     */
protected StudyAuditLogFilter getAuditLogStudyFilter(Limit limit) {
    StudyAuditLogFilter auditLogStudyFilter = new StudyAuditLogFilter(getDateFormat());
    FilterSet filterSet = limit.getFilterSet();
    Collection<Filter> filters = filterSet.getFilters();
    for (Filter filter : filters) {
        String property = filter.getProperty();
        String value = filter.getValue();
        if ("studySubject.status".equalsIgnoreCase(property)) {
            value = Status.getByName(value).getId() + "";
        }
        auditLogStudyFilter.addFilter(property, value);
    }
    return auditLogStudyFilter;
}
Also used : StudyAuditLogFilter(org.akaza.openclinica.dao.managestudy.StudyAuditLogFilter) FilterSet(org.jmesa.limit.FilterSet) StudyAuditLogFilter(org.akaza.openclinica.dao.managestudy.StudyAuditLogFilter) Filter(org.jmesa.limit.Filter)

Example 2 with FilterSet

use of org.jmesa.limit.FilterSet in project OpenClinica by OpenClinica.

the class ViewNotesFilterCriteria method buildFilterCriteria.

public static ViewNotesFilterCriteria buildFilterCriteria(Limit limit, String datePattern, Map<String, String> discrepancyNoteTypeDecoder, Map<String, String> resolutionTypeDecoder) {
    ViewNotesFilterCriteria criteria = new ViewNotesFilterCriteria();
    FilterSet filterSet = limit.getFilterSet();
    if (filterSet != null) {
        DateFormat df = new SimpleDateFormat(datePattern);
        for (Filter filter : filterSet.getFilters()) {
            String columnName = filter.getProperty();
            String filterName = FILTER_BY_TABLE_COLUMN.get(columnName);
            if (filterName == null) {
                throw new IllegalArgumentException("No query fragment available for column '" + columnName + "'");
            }
            String value = filter.getValue();
            if (filterName.equals("discrepancy_note_type_id")) {
                value = discrepancyNoteTypeDecoder.get(value);
            } else if (filterName.equals("resolution_status_id")) {
                value = resolutionTypeDecoder.get(value);
            }
            criteria.getFilters().put(filterName, processValue(filterName, value, df));
        }
    }
    RowSelect rowSelect = limit.getRowSelect();
    if (rowSelect != null) {
        criteria.pageNumber = rowSelect.getPage();
        criteria.pageSize = rowSelect.getMaxRows();
    }
    return criteria;
}
Also used : RowSelect(org.jmesa.limit.RowSelect) FilterSet(org.jmesa.limit.FilterSet) Filter(org.jmesa.limit.Filter) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat)

Example 3 with FilterSet

use of org.jmesa.limit.FilterSet in project OpenClinica by OpenClinica.

the class AuditUserLoginTableFactory method getAuditUserLoginFilter.

/**
     * A very custom way to filter the items. The AuditUserLoginFilter acts as a
     * command for the Hibernate criteria object. Take the Limit information and
     * filter the rows.
     * 
     * @param limit
     *            The Limit to use.
     */
protected AuditUserLoginFilter getAuditUserLoginFilter(Limit limit) {
    AuditUserLoginFilter auditUserLoginFilter = new AuditUserLoginFilter();
    FilterSet filterSet = limit.getFilterSet();
    if (filterSet != null) {
        Collection<Filter> filters = filterSet.getFilters();
        for (Filter filter : filters) {
            String property = filter.getProperty();
            String value = filter.getValue();
            auditUserLoginFilter.addFilter(property, value);
        }
    }
    return auditUserLoginFilter;
}
Also used : FilterSet(org.jmesa.limit.FilterSet) Filter(org.jmesa.limit.Filter) AuditUserLoginFilter(org.akaza.openclinica.dao.hibernate.AuditUserLoginFilter) AuditUserLoginFilter(org.akaza.openclinica.dao.hibernate.AuditUserLoginFilter)

Example 4 with FilterSet

use of org.jmesa.limit.FilterSet in project OpenClinica by OpenClinica.

the class ListEventsForSubjectTableFactory method getListEventsForSubjectFilter.

protected ListEventsForSubjectFilter getListEventsForSubjectFilter(Limit limit) {
    ListEventsForSubjectFilter listEventsForSubjectFilter = new ListEventsForSubjectFilter(selectedStudyEventDefinition.getId());
    FilterSet filterSet = limit.getFilterSet();
    Collection<Filter> filters = filterSet.getFilters();
    for (Filter filter : filters) {
        String property = filter.getProperty();
        String value = filter.getValue();
        if ("studySubject.status".equalsIgnoreCase(property)) {
            value = Status.getByName(value).getId() + "";
        } else if ("event.status".equalsIgnoreCase(property)) {
            value = SubjectEventStatus.getByName(value).getId() + "";
        } else if (property.startsWith("sgc_")) {
            int studyGroupClassId = property.endsWith("_") ? 0 : Integer.valueOf(property.split("_")[1]);
            value = studyGroupDAO.findByNameAndGroupClassID(value, studyGroupClassId).getId() + "";
        } else if (property.startsWith("crf_")) {
            value = DataEntryStage.getByName(value).getId() + "";
        }
        listEventsForSubjectFilter.addFilter(property, value);
    }
    return listEventsForSubjectFilter;
}
Also used : FilterSet(org.jmesa.limit.FilterSet) ListEventsForSubjectFilter(org.akaza.openclinica.dao.managestudy.ListEventsForSubjectFilter) Filter(org.jmesa.limit.Filter) ListEventsForSubjectFilter(org.akaza.openclinica.dao.managestudy.ListEventsForSubjectFilter)

Example 5 with FilterSet

use of org.jmesa.limit.FilterSet in project OpenClinica by OpenClinica.

the class ListNotesTableFactory method getListNoteFilter.

/**
     * A very custom way to filter the items. The AuditUserLoginFilter acts as a command for the Hibernate criteria object. Take the Limit information and
     * filter the rows.
     *
     * @param limit
     *            The Limit to use.
     */
public ListNotesFilter getListNoteFilter(Limit limit) {
    ListNotesFilter listNotesFilter = new ListNotesFilter();
    FilterSet filterSet = limit.getFilterSet();
    Collection<Filter> filters = filterSet.getFilters();
    for (Filter filter : filters) {
        String property = filter.getProperty();
        String value = filter.getValue();
        //Checking if the given date format is valid
        if ("discrepancyNoteBean.createdDate".equalsIgnoreCase(property) || "discrepancyNoteBean.updatedDate".equalsIgnoreCase(property)) {
            try {
                String date = formatDate(new Date(value));
                value = date;
            } catch (Exception ex) {
                value = "01-Jan-1700";
            }
        } else if ("discrepancyNoteBean.disType".equalsIgnoreCase(property)) {
            ResourceBundle reterm = ResourceBundleProvider.getTermsBundle();
            if (reterm.getString("Query_and_Failed_Validation_Check").equals(value)) {
                value = 31 + "";
            } else {
                value = DiscrepancyNoteType.getByName(value).getId() + "";
            }
        } else if ("discrepancyNoteBean.resolutionStatus".equalsIgnoreCase(property)) {
            ResourceBundle reterm = ResourceBundleProvider.getTermsBundle();
            if (reterm.getString("New_and_Updated").equalsIgnoreCase(value)) {
                value = 21 + "";
            } else {
                value = ResolutionStatus.getByName(value).getId() + "";
            }
        }
        //
        listNotesFilter.addFilter(property, value);
    }
    return listNotesFilter;
}
Also used : FilterSet(org.jmesa.limit.FilterSet) ListNotesFilter(org.akaza.openclinica.dao.managestudy.ListNotesFilter) DropdownFilter(org.akaza.openclinica.control.DropdownFilter) ListNotesFilter(org.akaza.openclinica.dao.managestudy.ListNotesFilter) Filter(org.jmesa.limit.Filter) ResourceBundle(java.util.ResourceBundle) Date(java.util.Date) MissingResourceException(java.util.MissingResourceException)

Aggregations

FilterSet (org.jmesa.limit.FilterSet)14 Filter (org.jmesa.limit.Filter)13 ListDiscNotesSubjectFilter (org.akaza.openclinica.dao.managestudy.ListDiscNotesSubjectFilter)2 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 MissingResourceException (java.util.MissingResourceException)1 ResourceBundle (java.util.ResourceBundle)1 DropdownFilter (org.akaza.openclinica.control.DropdownFilter)1 SubjectSDVContainer (org.akaza.openclinica.controller.helper.table.SubjectSDVContainer)1 EventCRFSDVFilter (org.akaza.openclinica.dao.EventCRFSDVFilter)1 StudySubjectSDVFilter (org.akaza.openclinica.dao.StudySubjectSDVFilter)1 AuditUserLoginFilter (org.akaza.openclinica.dao.hibernate.AuditUserLoginFilter)1 ViewRuleAssignmentFilter (org.akaza.openclinica.dao.hibernate.ViewRuleAssignmentFilter)1 FindSubjectsFilter (org.akaza.openclinica.dao.managestudy.FindSubjectsFilter)1 ListDiscNotesForCRFFilter (org.akaza.openclinica.dao.managestudy.ListDiscNotesForCRFFilter)1 ListEventsForSubjectFilter (org.akaza.openclinica.dao.managestudy.ListEventsForSubjectFilter)1 ListNotesFilter (org.akaza.openclinica.dao.managestudy.ListNotesFilter)1 StudyAuditLogFilter (org.akaza.openclinica.dao.managestudy.StudyAuditLogFilter)1 ListSubjectFilter (org.akaza.openclinica.dao.submit.ListSubjectFilter)1