Search in sources :

Example 11 with EntityBeanTable

use of org.akaza.openclinica.web.bean.EntityBeanTable in project OpenClinica by OpenClinica.

the class FormProcessor method getEntityBeanTable.

public EntityBeanTable getEntityBeanTable() {
    EntityBeanTable answer = new EntityBeanTable();
    String sortingColumn = request.getParameter(EBL_SORT_COLUMN);
    if (sortingColumn != null && !"".equals(sortingColumn)) {
        answer.setSortingColumnExplicitlySet(true);
    }
    answer.setCurrPageNumber(getInt(EBL_PAGE));
    answer.setSortingColumnInd(getInt(EBL_SORT_COLUMN));
    answer.setKeywordFilter(getString(EBL_FILTER_KEYWORD));
    // this code says that for each of the boolean properties of the table,
    // if no value was speified on the form or in the GET query, then
    // keep the default value for that bit
    // otherwise, the bits will just be forced to false
    String[] blnFields = { EBL_SORT_ORDER, EBL_FILTERED, EBL_PAGINATED };
    for (int i = 0; i < blnFields.length; i++) {
        String value = getString(blnFields[i]);
        boolean b = getBoolean(blnFields[i]);
        if (!"".equals(value)) {
            if (i == 0) {
                answer.setAscendingSort(b);
            } else if (i == 1) {
                answer.setFiltered(b);
            } else {
                answer.setPaginated(b);
            }
        }
    }
    return answer;
}
Also used : EntityBeanTable(org.akaza.openclinica.web.bean.EntityBeanTable)

Example 12 with EntityBeanTable

use of org.akaza.openclinica.web.bean.EntityBeanTable in project OpenClinica by OpenClinica.

the class RestoreDatasetServlet method getDatasetTable.

private EntityBeanTable getDatasetTable() {
    FormProcessor fp = new FormProcessor(request);
    EntityBeanTable table = fp.getEntityBeanTable();
    DatasetDAO dsdao = new DatasetDAO(sm.getDataSource());
    ArrayList datasets = new ArrayList();
    // if (ub.isSysAdmin()) {
    // datasets =
    // (ArrayList)dsdao.findAllByStudyIdAdmin(currentStudy.getId());
    // } else {
    datasets = dsdao.findAllByStudyId(currentStudy.getId());
    // }
    ArrayList datasetRows = DatasetRow.generateRowsFromBeans(datasets);
    String[] columns = { resword.getString("dataset_name"), resword.getString("description"), resword.getString("created_by"), resword.getString("created_date"), resword.getString("status"), resword.getString("actions") };
    table.setColumns(new ArrayList(Arrays.asList(columns)));
    table.hideColumnLink(5);
    table.addLink(resword.getString("show_only_my_datasets"), "ViewDatasets?action=owner&ownerId=" + ub.getId());
    table.addLink(resword.getString("create_dataset"), "CreateDataset");
    table.setQuery("ViewDatasets", new HashMap());
    table.setRows(datasetRows);
    table.computeDisplay();
    return table;
}
Also used : HashMap(java.util.HashMap) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) EntityBeanTable(org.akaza.openclinica.web.bean.EntityBeanTable) ArrayList(java.util.ArrayList) DatasetDAO(org.akaza.openclinica.dao.extract.DatasetDAO)

Example 13 with EntityBeanTable

use of org.akaza.openclinica.web.bean.EntityBeanTable in project OpenClinica by OpenClinica.

the class AddCRFToDefinitionServlet method processRequest.

@Override
public void processRequest() throws Exception {
    String actionName = request.getParameter("actionName");
    String submit = request.getParameter("Submit");
    CRFDAO cdao = new CRFDAO(sm.getDataSource());
    ArrayList crfs = (ArrayList) cdao.findAllByStatus(Status.AVAILABLE);
    ArrayList edcs = (ArrayList) session.getAttribute("eventDefinitionCRFs");
    if (edcs == null) {
        edcs = new ArrayList();
    }
    HashMap crfIds = new HashMap();
    for (int i = 0; i < edcs.size(); i++) {
        EventDefinitionCRFBean edc = (EventDefinitionCRFBean) edcs.get(i);
        Integer crfId = new Integer(edc.getCrfId());
        crfIds.put(crfId, edc);
    }
    for (int i = 0; i < crfs.size(); i++) {
        CRFBean crf = (CRFBean) crfs.get(i);
        if (crfIds.containsKey(new Integer(crf.getId()))) {
            crf.setSelected(true);
        }
    }
    session.setAttribute("crfsWithVersion", crfs);
    if (submit != null) {
        addCRF();
    } else {
        if (StringUtil.isBlank(actionName)) {
            FormProcessor fp = new FormProcessor(request);
            EntityBeanTable table = fp.getEntityBeanTable();
            ArrayList allRows = CRFRow.generateRowsFromBeans(crfs);
            String[] columns = { resword.getString("CRF_name"), resword.getString("date_created"), resword.getString("owner"), resword.getString("date_updated"), resword.getString("last_updated_by"), resword.getString("selected") };
            table.setColumns(new ArrayList(Arrays.asList(columns)));
            table.hideColumnLink(5);
            table.setQuery("AddCRFToDefinition", new HashMap());
            table.setRows(allRows);
            table.computeDisplay();
            request.setAttribute("table", table);
            forwardPage(Page.UPDATE_EVENT_DEFINITION2);
        } else if (actionName.equalsIgnoreCase("next")) {
            Integer pageNumber = Integer.valueOf(request.getParameter("pageNum"));
            if (pageNumber != null) {
                if (pageNumber.intValue() == 2) {
                    String nextListPage = request.getParameter("next_list_page");
                    if (nextListPage != null && nextListPage.equalsIgnoreCase("true")) {
                        confirmDefinition();
                    }
                } else {
                    confirmDefinition();
                }
            }
        }
    }
}
Also used : CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) HashMap(java.util.HashMap) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) EntityBeanTable(org.akaza.openclinica.web.bean.EntityBeanTable) ArrayList(java.util.ArrayList) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)

Example 14 with EntityBeanTable

use of org.akaza.openclinica.web.bean.EntityBeanTable in project OpenClinica by OpenClinica.

the class AssignUserToStudyServlet method processRequest.

@Override
public void processRequest() throws Exception {
    String action = request.getParameter("action");
    ArrayList users = findUsers();
    String nextListPage = request.getParameter("next_list_page");
    if (StringUtil.isBlank(action) || (nextListPage != null && nextListPage.equalsIgnoreCase("true"))) {
        FormProcessor fp = new FormProcessor(request);
        EntityBeanTable table = fp.getEntityBeanTable();
        ArrayList allRows = UserAccountRow.generateRowsFromBeans(users);
        if (nextListPage == null) {
            session.removeAttribute("tmpSelectedUsersMap");
        }
        /*
             * The tmpSelectedUsersMap will hold all the selected users in the
             * session when the user is navigating through the list. This has
             * been done so that when the user moves to the next page of Users
             * list, the selection made in the previous page doesn't get lost.
             */
        Map tmpSelectedUsersMap = (HashMap) session.getAttribute("tmpSelectedUsersMap");
        if (tmpSelectedUsersMap == null) {
            tmpSelectedUsersMap = new HashMap();
        }
        if (nextListPage != null && nextListPage.equalsIgnoreCase("true")) {
            for (int i = 0; i < users.size(); i++) {
                int id = fp.getInt("id" + i);
                int roleId = fp.getInt("activeStudyRoleId" + i);
                String checked = fp.getString("selected" + i);
                // logger.info("selected:" + checked);
                if (!StringUtil.isBlank(checked) && "yes".equalsIgnoreCase(checked.trim())) {
                    tmpSelectedUsersMap.put(id, roleId);
                } else {
                    // deselected.
                    if (tmpSelectedUsersMap.containsKey(id)) {
                        tmpSelectedUsersMap.remove(id);
                    }
                }
            }
            session.setAttribute("tmpSelectedUsersMap", tmpSelectedUsersMap);
        }
        String[] columns = { resword.getString("user_name"), resword.getString("first_name"), resword.getString("last_name"), resword.getString("role"), resword.getString("selected"), resword.getString("notes") };
        table.setColumns(new ArrayList(Arrays.asList(columns)));
        table.hideColumnLink(3);
        table.hideColumnLink(4);
        table.hideColumnLink(5);
        table.setQuery("AssignUserToStudy", new HashMap());
        table.setRows(allRows);
        table.computeDisplay();
        request.setAttribute("table", table);
        // request.setAttribute("studyUsers", users);
        ArrayList roles = Role.toArrayList();
        if (currentStudy.getParentStudyId() > 0) {
            roles.remove(Role.COORDINATOR);
            roles.remove(Role.STUDYDIRECTOR);
        }
        // admin is not a user role, only used
        roles.remove(Role.ADMIN);
        // for
        // tomcat
        request.setAttribute("roles", roles);
        forwardPage(Page.STUDY_USER_LIST);
    } else {
        if ("submit".equalsIgnoreCase(action)) {
            addUser(users);
        }
    }
}
Also used : HashMap(java.util.HashMap) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) EntityBeanTable(org.akaza.openclinica.web.bean.EntityBeanTable) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map)

Example 15 with EntityBeanTable

use of org.akaza.openclinica.web.bean.EntityBeanTable in project OpenClinica by OpenClinica.

the class ListSiteServlet method processRequest.

/**
     * Finds all the studies, processes the request
     */
@Override
public void processRequest() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    if (currentStudy.getParentStudyId() > 0) {
        addPageMessage(respage.getString("no_sites_available_study_is_a_site"));
        forwardPage(Page.MENU_SERVLET);
    } else {
        StudyDAO sdao = new StudyDAO(sm.getDataSource());
        ArrayList studies = (ArrayList) sdao.findAllByParent(currentStudy.getId());
        EntityBeanTable table = fp.getEntityBeanTable();
        ArrayList allStudyRows = StudyRow.generateRowsFromBeans(studies);
        String[] columns = { resword.getString("name"), resword.getString("unique_identifier"), resword.getString("OID"), resword.getString("principal_investigator"), resword.getString("facility_name"), resword.getString("date_created"), resword.getString("status"), resword.getString("actions") };
        table.setColumns(new ArrayList(Arrays.asList(columns)));
        table.hideColumnLink(2);
        table.hideColumnLink(6);
        table.setQuery("ListSite", new HashMap());
        // if (!currentStudy.getStatus().isLocked()) {
        // table.addLink(resword.getString("create_a_new_site"),
        // "CreateSubStudy");
        // }
        table.setRows(allStudyRows);
        table.computeDisplay();
        request.setAttribute("table", table);
        if (request.getParameter("read") != null && request.getParameter("read").equals("true")) {
            request.setAttribute("readOnly", true);
        }
        session.setAttribute("fromListSite", "yes");
        forwardPage(Page.SITE_LIST);
    }
}
Also used : HashMap(java.util.HashMap) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) EntityBeanTable(org.akaza.openclinica.web.bean.EntityBeanTable) ArrayList(java.util.ArrayList) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Aggregations

EntityBeanTable (org.akaza.openclinica.web.bean.EntityBeanTable)37 ArrayList (java.util.ArrayList)34 HashMap (java.util.HashMap)34 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)34 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)11 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)10 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)10 DatasetDAO (org.akaza.openclinica.dao.extract.DatasetDAO)9 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)9 FilterDAO (org.akaza.openclinica.dao.extract.FilterDAO)8 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)7 UserAccountDAO (org.akaza.openclinica.dao.login.UserAccountDAO)7 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)7 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)6 DatasetBean (org.akaza.openclinica.bean.extract.DatasetBean)6 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)6 Date (java.util.Date)5 Iterator (java.util.Iterator)5 Map (java.util.Map)5 FilterBean (org.akaza.openclinica.bean.extract.FilterBean)5