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");
}
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);
}
}
Aggregations