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);
}
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;
}
Aggregations