Search in sources :

Example 1 with ListSubjectFilter

use of org.akaza.openclinica.dao.submit.ListSubjectFilter in project OpenClinica by OpenClinica.

the class ListSubjectTableFactory method setDataAndLimitVariables.

@SuppressWarnings("unchecked")
@Override
public void setDataAndLimitVariables(TableFacade tableFacade) {
    // initialize i18n
    resword = ResourceBundleProvider.getWordsBundle(getLocale());
    resformat = ResourceBundleProvider.getFormatBundle(getLocale());
    Limit limit = tableFacade.getLimit();
    ListSubjectFilter listSubjectFilter = getListSubjectFilter(limit);
    if (!limit.isComplete()) {
        Integer totalRows = getSubjectDao().getCountWithFilter(listSubjectFilter, getCurrentStudy());
        if (totalRows == null) {
            totalRows = 0;
        }
        tableFacade.setTotalRows(totalRows.intValue());
    }
    ListSubjectSort listSubjectSort = getListSubjectSort(limit);
    int rowStart = limit.getRowSelect().getRowStart();
    int rowEnd = limit.getRowSelect().getRowEnd();
    Collection<SubjectBean> items = getSubjectDao().getWithFilterAndSort(getCurrentStudy(), listSubjectFilter, listSubjectSort, rowStart, rowEnd);
    Collection<HashMap<Object, Object>> theItems = new ArrayList<HashMap<Object, Object>>();
    for (SubjectBean subject : items) {
        UserAccountBean owner = (UserAccountBean) getUserAccountDao().findByPK(subject.getOwnerId());
        UserAccountBean updater = subject.getUpdaterId() == 0 ? null : (UserAccountBean) getUserAccountDao().findByPK(subject.getUpdaterId());
        HashMap<Object, Object> h = new HashMap<Object, Object>();
        String studySubjectIdAndStudy = "";
        List<StudySubjectBean> studySubjects = getStudySubjectDao().findAllBySubjectId(subject.getId());
        for (StudySubjectBean studySubjectBean : studySubjects) {
            StudyBean study = (StudyBean) getStudyDao().findByPK(studySubjectBean.getStudyId());
            studySubjectIdAndStudy += studySubjectIdAndStudy.length() == 0 ? "" : ",";
            studySubjectIdAndStudy += study.getIdentifier() + "-" + studySubjectBean.getLabel();
        }
        h.put("studySubjectIdAndStudy", studySubjectIdAndStudy);
        h.put("subject", subject);
        h.put("subject.uniqueIdentifier", subject.getUniqueIdentifier());
        h.put("subject.gender", subject.getGender());
        Date tempDate = subject.getCreatedDate();
        String tempDateStr = tempDate == null ? "" : I18nFormatUtil.getDateFormat(getLocale()).format(tempDate);
        h.put("subject.createdDate", tempDateStr);
        h.put("subject.owner", owner);
        tempDate = subject.getUpdatedDate();
        tempDateStr = tempDate == null ? "" : I18nFormatUtil.getDateFormat(getLocale()).format(tempDate);
        h.put("subject.updatedDate", tempDateStr);
        h.put("subject.updater", updater);
        h.put("subject.status", subject.getStatus());
        theItems.add(h);
    }
    tableFacade.setItems(theItems);
}
Also used : ListSubjectFilter(org.akaza.openclinica.dao.submit.ListSubjectFilter) HashMap(java.util.HashMap) ListSubjectSort(org.akaza.openclinica.dao.submit.ListSubjectSort) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) Date(java.util.Date) SubjectBean(org.akaza.openclinica.bean.submit.SubjectBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) Limit(org.jmesa.limit.Limit)

Example 2 with ListSubjectFilter

use of org.akaza.openclinica.dao.submit.ListSubjectFilter in project OpenClinica by OpenClinica.

the class ListSubjectTableFactory method getListSubjectFilter.

/**
 * 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 ListSubjectFilter getListSubjectFilter(Limit limit) {
    ListSubjectFilter listSubjectFilter = new ListSubjectFilter(getDateFormat());
    FilterSet filterSet = limit.getFilterSet();
    Collection<Filter> filters = filterSet.getFilters();
    for (Filter filter : filters) {
        String property = filter.getProperty();
        String value = filter.getValue();
        listSubjectFilter.addFilter(property, value);
    }
    return listSubjectFilter;
}
Also used : ListSubjectFilter(org.akaza.openclinica.dao.submit.ListSubjectFilter) FilterSet(org.jmesa.limit.FilterSet) ListSubjectFilter(org.akaza.openclinica.dao.submit.ListSubjectFilter) Filter(org.jmesa.limit.Filter)

Aggregations

ListSubjectFilter (org.akaza.openclinica.dao.submit.ListSubjectFilter)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)1 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)1 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)1 SubjectBean (org.akaza.openclinica.bean.submit.SubjectBean)1 ListSubjectSort (org.akaza.openclinica.dao.submit.ListSubjectSort)1 Filter (org.jmesa.limit.Filter)1 FilterSet (org.jmesa.limit.FilterSet)1 Limit (org.jmesa.limit.Limit)1