Search in sources :

Example 1 with StudyAuditLogSort

use of org.akaza.openclinica.dao.managestudy.StudyAuditLogSort in project OpenClinica by OpenClinica.

the class StudyAuditLogTableFactory method setDataAndLimitVariables.

@Override
public void setDataAndLimitVariables(TableFacade tableFacade) {
    // initialize i18n
    resword = ResourceBundleProvider.getWordsBundle(getLocale());
    resformat = ResourceBundleProvider.getFormatBundle(getLocale());
    Limit limit = tableFacade.getLimit();
    StudyAuditLogFilter auditLogStudyFilter = getAuditLogStudyFilter(limit);
    if (!limit.isComplete()) {
        int totalRows = getStudySubjectDao().getCountWithFilter(auditLogStudyFilter, getCurrentStudy());
        tableFacade.setTotalRows(totalRows);
    }
    StudyAuditLogSort auditLogStudySort = getAuditLogStudySort(limit);
    /*
         * if (auditLogStudySort.getSorts().size() == 0) {
         * auditLogStudySort.addSort("loginAttemptDate", "desc"); }
         */
    int rowStart = limit.getRowSelect().getRowStart();
    int rowEnd = limit.getRowSelect().getRowEnd();
    Collection<StudySubjectBean> items = getStudySubjectDao().getWithFilterAndSort(getCurrentStudy(), auditLogStudyFilter, auditLogStudySort, rowStart, rowEnd);
    Collection<HashMap<Object, Object>> theItems = new ArrayList<HashMap<Object, Object>>();
    for (StudySubjectBean studySubjectBean : items) {
        SubjectBean subject = (SubjectBean) getSubjectDao().findByPK(studySubjectBean.getSubjectId());
        UserAccountBean owner = (UserAccountBean) getUserAccountDao().findByPK(studySubjectBean.getOwnerId());
        HashMap<Object, Object> h = new HashMap<Object, Object>();
        h.put("studySubject", studySubjectBean);
        h.put("studySubject.label", studySubjectBean.getLabel());
        h.put("studySubject.secondaryLabel", studySubjectBean.getSecondaryLabel());
        h.put("studySubject.oid", studySubjectBean.getOid());
        h.put("studySubject.owner", owner);
        h.put("studySubject.status", studySubjectBean.getStatus());
        h.put("subject", subject);
        h.put("subject.dateOfBirth", resolveBirthDay(subject.getDateOfBirth(), subject.isDobCollected(), getLocale()));
        h.put("subject.uniqueIdentifier", subject.getUniqueIdentifier());
        theItems.add(h);
    }
    tableFacade.setItems(theItems);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SubjectBean(org.akaza.openclinica.bean.submit.SubjectBean) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudyAuditLogFilter(org.akaza.openclinica.dao.managestudy.StudyAuditLogFilter) StudyAuditLogSort(org.akaza.openclinica.dao.managestudy.StudyAuditLogSort) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) Limit(org.jmesa.limit.Limit)

Example 2 with StudyAuditLogSort

use of org.akaza.openclinica.dao.managestudy.StudyAuditLogSort in project OpenClinica by OpenClinica.

the class StudyAuditLogTableFactory method getAuditLogStudySort.

/**
 * 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 StudyAuditLogSort getAuditLogStudySort(Limit limit) {
    StudyAuditLogSort auditLogStudySort = new StudyAuditLogSort();
    SortSet sortSet = limit.getSortSet();
    Collection<Sort> sorts = sortSet.getSorts();
    for (Sort sort : sorts) {
        String property = sort.getProperty();
        String order = sort.getOrder().toParam();
        auditLogStudySort.addSort(property, order);
    }
    return auditLogStudySort;
}
Also used : StudyAuditLogSort(org.akaza.openclinica.dao.managestudy.StudyAuditLogSort) Sort(org.jmesa.limit.Sort) StudyAuditLogSort(org.akaza.openclinica.dao.managestudy.StudyAuditLogSort) SortSet(org.jmesa.limit.SortSet)

Aggregations

StudyAuditLogSort (org.akaza.openclinica.dao.managestudy.StudyAuditLogSort)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)1 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)1 SubjectBean (org.akaza.openclinica.bean.submit.SubjectBean)1 StudyAuditLogFilter (org.akaza.openclinica.dao.managestudy.StudyAuditLogFilter)1 Limit (org.jmesa.limit.Limit)1 Sort (org.jmesa.limit.Sort)1 SortSet (org.jmesa.limit.SortSet)1