use of org.akaza.openclinica.control.form.FormProcessor in project OpenClinica by OpenClinica.
the class RemoveDatasetServlet method processRequest.
@Override
public void processRequest() throws Exception {
FormProcessor fp = new FormProcessor(request);
int dsId = fp.getInt("dsId");
DatasetDAO dsDAO = new DatasetDAO(sm.getDataSource());
DatasetBean dataset = (DatasetBean) dsDAO.findByPK(dsId);
StudyDAO sdao = new StudyDAO(sm.getDataSource());
StudyBean study = (StudyBean) sdao.findByPK(dataset.getStudyId());
checkRoleByUserAndStudy(ub, study.getParentStudyId(), study.getId());
if (study.getId() != currentStudy.getId() && study.getParentStudyId() != currentStudy.getId()) {
addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " " + respage.getString("change_active_study_or_contact"));
forwardPage(Page.MENU_SERVLET);
return;
}
if (!ub.isSysAdmin() && dataset.getOwnerId() != ub.getId()) {
addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " " + respage.getString("change_active_study_or_contact"));
forwardPage(Page.MENU_SERVLET);
return;
}
String action = request.getParameter("action");
if (resword.getString("remove_this_dataset").equalsIgnoreCase(action)) {
dataset.setStatus(Status.DELETED);
dsDAO.update(dataset);
// +
addPageMessage(respage.getString("dataset_removed"));
// "System Administrators can "+
// "restore it if necessary.");
request.setAttribute("table", getDatasetTable());
forwardPage(Page.VIEW_DATASETS);
} else if (resword.getString("cancel").equalsIgnoreCase(action)) {
request.setAttribute("table", getDatasetTable());
forwardPage(Page.VIEW_DATASETS);
} else {
request.setAttribute("dataset", dataset);
forwardPage(Page.REMOVE_DATASET);
}
}
use of org.akaza.openclinica.control.form.FormProcessor in project OpenClinica by OpenClinica.
the class RemoveFilterServlet method getFilterTable.
private EntityBeanTable getFilterTable() {
FormProcessor fp = new FormProcessor(request);
FilterDAO fdao = new FilterDAO(sm.getDataSource());
EntityBeanTable table = fp.getEntityBeanTable();
ArrayList filters = (ArrayList) fdao.findAll();
// TODO make 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();
return table;
}
use of org.akaza.openclinica.control.form.FormProcessor in project OpenClinica by OpenClinica.
the class RemoveFilterServlet method processRequest.
@Override
public void processRequest() throws Exception {
FormProcessor fp = new FormProcessor(request);
int filterId = fp.getInt("filterId");
FilterDAO fDAO = new FilterDAO(sm.getDataSource());
FilterBean filter = (FilterBean) fDAO.findByPK(filterId);
String action = request.getParameter("action");
if (resword.getString("remove_this_filter").equalsIgnoreCase(action)) {
filter.setStatus(Status.DELETED);
fDAO.update(filter);
addPageMessage(respage.getString("filter_removed_admin_can_access_and_reverse"));
EntityBeanTable table = getFilterTable();
request.setAttribute("table", table);
forwardPage(Page.CREATE_FILTER_SCREEN_1);
} else if (resword.getString("cancel").equalsIgnoreCase(action)) {
EntityBeanTable table = getFilterTable();
request.setAttribute("table", table);
forwardPage(Page.CREATE_FILTER_SCREEN_1);
} else {
request.setAttribute("filter", filter);
forwardPage(Page.REMOVE_FILTER);
}
}
use of org.akaza.openclinica.control.form.FormProcessor 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;
}
use of org.akaza.openclinica.control.form.FormProcessor in project OpenClinica by OpenClinica.
the class RequestStudyServlet method confirm.
/**
*
* @param request
* @param response
*/
private void confirm() throws Exception {
Validator v = new Validator(request);
v.addValidation("studyId", Validator.IS_AN_INTEGER);
v.addValidation("studyRoleId", Validator.IS_VALID_TERM, TermType.ROLE);
HashMap errors = v.validate();
FormProcessor fp = new FormProcessor(request);
StudyUserRoleBean newRole = new StudyUserRoleBean();
if (fp.getInt("studyRoleId") > 0) {
newRole.setRole(Role.get(fp.getInt("studyRoleId")));
}
newRole.setStudyId(fp.getInt("studyId"));
StudyDAO sdao = new StudyDAO(sm.getDataSource());
StudyBean studyRequested = (StudyBean) sdao.findByPK(newRole.getStudyId());
newRole.setStudyName(studyRequested.getName());
session.setAttribute("newRole", newRole);
if (!errors.isEmpty()) {
logger.info("after processing form,error is not empty");
request.setAttribute("formMessages", errors);
forwardPage(Page.REQUEST_STUDY);
} else {
logger.info("after processing form,no errors");
forwardPage(Page.REQUEST_STUDY_CONFIRM);
}
}
Aggregations