use of org.akaza.openclinica.dao.submit.ListSubjectSort 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.ListSubjectSort in project OpenClinica by OpenClinica.
the class ListSubjectTableFactory method getListSubjectSort.
/**
* A very custom way to sort the items. The AuditUserLoginSort acts as a
* command for the Hibernate criteria object. Take the Limit information and
* sort the rows.
*
* @param limit
* The Limit to use.
*/
protected ListSubjectSort getListSubjectSort(Limit limit) {
ListSubjectSort listSubjectSort = new ListSubjectSort();
SortSet sortSet = limit.getSortSet();
Collection<Sort> sorts = sortSet.getSorts();
for (Sort sort : sorts) {
String property = sort.getProperty();
String order = sort.getOrder().toParam();
listSubjectSort.addSort(property, order);
}
return listSubjectSort;
}
Aggregations