Search in sources :

Example 1 with StudyAuditLogFilter

use of org.akaza.openclinica.dao.managestudy.StudyAuditLogFilter 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 StudyAuditLogFilter

use of org.akaza.openclinica.dao.managestudy.StudyAuditLogFilter 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)

Aggregations

StudyAuditLogFilter (org.akaza.openclinica.dao.managestudy.StudyAuditLogFilter)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 StudyAuditLogSort (org.akaza.openclinica.dao.managestudy.StudyAuditLogSort)1 Filter (org.jmesa.limit.Filter)1 FilterSet (org.jmesa.limit.FilterSet)1 Limit (org.jmesa.limit.Limit)1