Search in sources :

Example 36 with EntityBeanTable

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

the class ExportDatasetServlet method loadList.

public void loadList(DatasetBean db, ArchivedDatasetFileDAO asdfdao, int datasetId, FormProcessor fp, ExtractBean eb) {
    logger.info("action is blank");
    request.setAttribute("dataset", db);
    logger.info("just set dataset to request");
    request.setAttribute("extractProperties", CoreResources.getExtractProperties());
    // find out if there are any files here:
    File currentDir = new File(DATASET_DIR + db.getId() + File.separator);
    //JN: Commenting out this, as its creating directories without any reason. TODO: Check why was this added.
    // if (!currentDir.isDirectory()) {
    //      currentDir.mkdirs();
    //  }
    ArrayList fileListRaw = new ArrayList();
    fileListRaw = asdfdao.findByDatasetId(datasetId);
    fileList = new ArrayList();
    Iterator fileIterator = fileListRaw.iterator();
    while (fileIterator.hasNext()) {
        ArchivedDatasetFileBean asdfBean = (ArchivedDatasetFileBean) fileIterator.next();
        // set the correct webPath in each bean here
        // changed here, tbh, 4-18
        // asdfBean.setWebPath(WEB_DIR+db.getId()+"/"+asdfBean.getName());
        // asdfBean.setWebPath(DATASET_DIR+db.getId()+File.separator+
        // asdfBean.getName());
        asdfBean.setWebPath(asdfBean.getFileReference());
        if (new File(asdfBean.getFileReference()).isFile()) {
            // logger.warn(asdfBean.getFileReference()+" is a
            // file!");
            fileList.add(asdfBean);
        } else {
            logger.warn(asdfBean.getFileReference() + " is NOT a file!");
        }
    }
    logger.warn("");
    logger.warn("file list length: " + fileList.size());
    request.setAttribute("filelist", fileList);
    ArrayList filterRows = ArchivedDatasetFileRow.generateRowsFromBeans(fileList);
    EntityBeanTable table = fp.getEntityBeanTable();
    // sort by date
    table.setSortingIfNotExplicitlySet(3, false);
    String[] columns = { resword.getString("file_name"), resword.getString("run_time"), resword.getString("file_size"), resword.getString("created_date"), resword.getString("created_by"), resword.getString("action") };
    table.setColumns(new ArrayList(Arrays.asList(columns)));
    table.hideColumnLink(0);
    table.hideColumnLink(1);
    table.hideColumnLink(2);
    table.hideColumnLink(3);
    table.hideColumnLink(4);
    table.hideColumnLink(5);
    table.setQuery("ExportDataset?datasetId=" + db.getId(), new HashMap());
    // trying to continue...
    session.setAttribute("newDataset", db);
    table.setRows(filterRows);
    table.computeDisplay();
    request.setAttribute("table", table);
    // for the side info bar
    TabReportBean answer = new TabReportBean();
    resetPanel();
    panel.setStudyInfoShown(false);
    setToPanel(resword.getString("study_name"), eb.getStudy().getName());
    setToPanel(resword.getString("protocol_ID"), eb.getStudy().getIdentifier());
    setToPanel(resword.getString("dataset_name"), db.getName());
    setToPanel(resword.getString("created_date"), local_df.format(db.getCreatedDate()));
    setToPanel(resword.getString("dataset_owner"), db.getOwner().getName());
    try {
        // do we not set this or is it null b/c we come to the page with no session?
        setToPanel(resword.getString("date_last_run"), local_df.format(db.getDateLastRun()));
    } catch (NullPointerException npe) {
        logger.error("exception: " + npe.getMessage());
    }
    logger.warn("just set file list to request, sending to page");
}
Also used : HashMap(java.util.HashMap) EntityBeanTable(org.akaza.openclinica.web.bean.EntityBeanTable) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) TabReportBean(org.akaza.openclinica.bean.extract.TabReportBean) ZipFile(java.util.zip.ZipFile) File(java.io.File) ArchivedDatasetFileBean(org.akaza.openclinica.bean.extract.ArchivedDatasetFileBean)

Example 37 with EntityBeanTable

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

the class EditFilterServlet method processRequest.

@Override
public void processRequest() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    String action = request.getParameter("action");
    if ("validate".equalsIgnoreCase(action)) {
        // check name, description, status for right now
        Validator v = new Validator(request);
        v.addValidation("fName", Validator.NO_BLANKS);
        v.addValidation("fDesc", Validator.NO_BLANKS);
        v.addValidation("fStatusId", Validator.IS_VALID_TERM, TermType.STATUS);
        HashMap errors = v.validate();
        if (!errors.isEmpty()) {
            String[] fieldNames = { "fName", "fDesc" };
            fp.setCurrentStringValuesAsPreset(fieldNames);
            fp.addPresetValue("fStatusId", fp.getInt("fStatusId"));
            addPageMessage(respage.getString("errors_in_submission_see_below"));
            setInputMessages(errors);
            setPresetValues(fp.getPresetValues());
            // TODO determine if this is necessary
            int filterId = fp.getInt("filterId");
            FilterDAO fDAO = new FilterDAO(sm.getDataSource());
            FilterBean showFilter = (FilterBean) fDAO.findByPK(filterId);
            request.setAttribute("filter", showFilter);
            // maybe just set the above to the session?
            request.setAttribute("statuses", getStatuses());
            forwardPage(Page.EDIT_FILTER);
        } else {
            int filterId = fp.getInt("filterId");
            FilterDAO fDAO = new FilterDAO(sm.getDataSource());
            FilterBean filter = (FilterBean) fDAO.findByPK(filterId);
            filter.setName(fp.getString("fName"));
            filter.setDescription(fp.getString("fDesc"));
            filter.setStatus(Status.get(fp.getInt("fStatusId")));
            fDAO.update(filter);
            addPageMessage(respage.getString("the_filter_was_succesfully_updated"));
            // Collection filters = fDAO.findAll();
            // TODO make findAllByProject?
            // FormProcessor fp = new FormProcessor(request);
            FilterDAO fdao = new FilterDAO(sm.getDataSource());
            EntityBeanTable table = fp.getEntityBeanTable();
            // TODO make
            ArrayList filters = (ArrayList) fdao.findAll();
            // findAllByProject
            ArrayList filterRows = FilterRow.generateRowsFromBeans(filters);
            String[] columns = { resword.getString("filter_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.setQuery("CreateFiltersOne", new HashMap());
            table.setRows(filterRows);
            table.computeDisplay();
            request.setAttribute("table", table);
            forwardPage(Page.CREATE_FILTER_SCREEN_1);
        // forwardPage(Page.VALIDATE_EDIT_FILTER);
        }
    } else {
        int filterId = fp.getInt("filterId");
        FilterDAO fDAO = new FilterDAO(sm.getDataSource());
        FilterBean showFilter = (FilterBean) fDAO.findByPK(filterId);
        request.setAttribute("filter", showFilter);
        request.setAttribute("statuses", getStatuses());
        forwardPage(Page.EDIT_FILTER);
    }
}
Also used : FilterDAO(org.akaza.openclinica.dao.extract.FilterDAO) HashMap(java.util.HashMap) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) EntityBeanTable(org.akaza.openclinica.web.bean.EntityBeanTable) ArrayList(java.util.ArrayList) Validator(org.akaza.openclinica.control.form.Validator) FilterBean(org.akaza.openclinica.bean.extract.FilterBean)

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