use of org.akaza.openclinica.web.bean.EntityBeanTable in project OpenClinica by OpenClinica.
the class AuditLogUserServlet method processRequest.
/*
* (non-Javadoc) Assume that we get the user id automatically. We will jump
* from the edit user page if the user is an admin, they can get to see the
* users' log
*
* @see org.akaza.openclinica.control.core.SecureController#processRequest()
*/
@Override
protected void processRequest() throws Exception {
FormProcessor fp = new FormProcessor(request);
int userId = fp.getInt(ARG_USERID);
if (userId == 0) {
Integer userIntId = (Integer) session.getAttribute(ARG_USERID);
userId = userIntId.intValue();
} else {
session.setAttribute(ARG_USERID, new Integer(userId));
}
AuditEventDAO aeDAO = new AuditEventDAO(sm.getDataSource());
ArrayList al = aeDAO.findAllByUserId(userId);
EntityBeanTable table = fp.getEntityBeanTable();
ArrayList allRows = AuditEventRow.generateRowsFromBeans(al);
// String[] columns = { "Date and Time", "Action", "Entity/Operation",
// "Record ID", "Changes and Additions","Other Info" };
// table.setColumns(new ArrayList(Arrays.asList(columns)));
// table.hideColumnLink(4);
// table.hideColumnLink(1);
// table.hideColumnLink(5);
// table.setQuery("AuditLogUser?userLogId="+userId, new HashMap());
String[] columns = { resword.getString("date_and_time"), resword.getString("action_message"), resword.getString("entity_operation"), resword.getString("study_site"), resword.getString("study_subject_ID"), resword.getString("changes_and_additions"), // "Other Info",
resword.getString("actions") };
table.setColumns(new ArrayList(Arrays.asList(columns)));
table.setAscendingSort(false);
table.hideColumnLink(1);
table.hideColumnLink(5);
table.hideColumnLink(6);
// table.hideColumnLink(7);
table.setQuery("AuditLogUser?userLogId=" + userId, new HashMap());
table.setRows(allRows);
table.computeDisplay();
request.setAttribute("table", table);
UserAccountDAO uadao = new UserAccountDAO(sm.getDataSource());
UserAccountBean uabean = (UserAccountBean) uadao.findByPK(userId);
request.setAttribute("auditUserBean", uabean);
forwardPage(Page.AUDIT_LOG_USER);
}
use of org.akaza.openclinica.web.bean.EntityBeanTable in project OpenClinica by OpenClinica.
the class ListUserAccountsServlet method processRequest.
@Override
protected void processRequest() throws Exception {
FormProcessor fp = new FormProcessor(request);
UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
EntityBeanTable table = fp.getEntityBeanTable();
// table.setSortingIfNotExplicitlySet(1, false);
ArrayList allUsers = getAllUsers(udao);
setStudyNamesInStudyUserRoles(allUsers);
ArrayList allUserRows = UserAccountRow.generateRowsFromBeans(allUsers);
String[] columns = { resword.getString("user_name"), resword.getString("first_name"), resword.getString("last_name"), resword.getString("status"), resword.getString("actions") };
table.setColumns(new ArrayList(Arrays.asList(columns)));
table.hideColumnLink(4);
table.setQuery("ListUserAccounts", new HashMap());
table.addLink(resword.getString("create_a_new_user"), "CreateUserAccount");
table.setRows(allUserRows);
table.computeDisplay();
request.setAttribute("table", table);
String message = fp.getString(ARG_MESSAGE, true);
request.setAttribute(ARG_MESSAGE, message);
request.setAttribute("siteRoleMap", Role.siteRoleMap);
request.setAttribute("studyRoleMap", Role.studyRoleMap);
resetPanel();
panel.setStudyInfoShown(false);
panel.setOrderedData(true);
if (allUsers.size() > 0) {
setToPanel(resword.getString("users"), new Integer(allUsers.size()).toString());
}
forwardPage(Page.LIST_USER_ACCOUNTS);
}
use of org.akaza.openclinica.web.bean.EntityBeanTable in project OpenClinica by OpenClinica.
the class AddCRFToDefinitionServlet method confirmDefinition.
private void confirmDefinition() throws Exception {
FormProcessor fp = new FormProcessor(request);
Map tmpCRFIdMap = (HashMap) session.getAttribute("tmpCRFIdMap");
if (tmpCRFIdMap == null) {
tmpCRFIdMap = new HashMap();
}
ArrayList crfsWithVersion = (ArrayList) session.getAttribute("crfsWithVersion");
for (int i = 0; i < crfsWithVersion.size(); i++) {
int id = fp.getInt("id" + i);
String name = fp.getString("name" + i);
String selected = fp.getString("selected" + i);
if (!StringUtil.isBlank(selected) && "yes".equalsIgnoreCase(selected.trim())) {
tmpCRFIdMap.put(id, name);
} else {
if (tmpCRFIdMap.containsKey(id)) {
tmpCRFIdMap.remove(id);
}
}
}
session.setAttribute("tmpCRFIdMap", tmpCRFIdMap);
EntityBeanTable table = fp.getEntityBeanTable();
ArrayList allRows = CRFRow.generateRowsFromBeans(crfsWithVersion);
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);
StudyEventDefinitionBean def1 = (StudyEventDefinitionBean) session.getAttribute("definition");
HashMap args = new HashMap();
args.put("actionName", "next");
args.put("pageNum", "1");
args.put("name", def1.getName());
args.put("repeating", new Boolean(def1.isRepeating()).toString());
args.put("category", def1.getCategory());
args.put("description", def1.getDescription());
args.put("type", def1.getType());
table.setQuery("AddCRFToDefinition", args);
table.setRows(allRows);
table.computeDisplay();
request.setAttribute("table", table);
forwardPage(Page.UPDATE_EVENT_DEFINITION2);
}
use of org.akaza.openclinica.web.bean.EntityBeanTable in project OpenClinica by OpenClinica.
the class ShowFileServlet method processRequest.
@Override
public void processRequest() throws Exception {
FormProcessor fp = new FormProcessor(request);
int fileId = fp.getInt("fileId");
int dsId = fp.getInt("datasetId");
DatasetDAO dsdao = new DatasetDAO(sm.getDataSource());
DatasetBean db = (DatasetBean) dsdao.findByPK(dsId);
ArchivedDatasetFileDAO asdfdao = new ArchivedDatasetFileDAO(sm.getDataSource());
ArchivedDatasetFileBean asdfBean = (ArchivedDatasetFileBean) asdfdao.findByPK(fileId);
ArrayList newFileList = new ArrayList();
newFileList.add(asdfBean);
// request.setAttribute("filelist",newFileList);
ArrayList filterRows = ArchivedDatasetFileRow.generateRowsFromBeans(newFileList);
EntityBeanTable table = fp.getEntityBeanTable();
String[] columns = { resword.getString("file_name"), resword.getString("run_time"), resword.getString("file_size"), resword.getString("created_date"), resword.getString("created_by") };
table.setColumns(new ArrayList(Arrays.asList(columns)));
table.hideColumnLink(0);
table.hideColumnLink(1);
table.hideColumnLink(2);
table.hideColumnLink(3);
table.hideColumnLink(4);
// table.setQuery("ExportDataset?datasetId=" +db.getId(), new
// HashMap());
// trying to continue...
// session.setAttribute("newDataset",db);
request.setAttribute("dataset", db);
request.setAttribute("file", asdfBean);
table.setRows(filterRows);
table.computeDisplay();
request.setAttribute("table", table);
Page finalTarget = Page.EXPORT_DATA_CUSTOM;
finalTarget.setFileName("/WEB-INF/jsp/extract/generateMetadataFile.jsp");
forwardPage(finalTarget);
}
use of org.akaza.openclinica.web.bean.EntityBeanTable in project OpenClinica by OpenClinica.
the class ViewDatasetsServlet method processRequest.
@Override
public void processRequest() throws Exception {
DatasetDAO dsdao = new DatasetDAO(sm.getDataSource());
String action = request.getParameter("action");
resetPanel();
request.setAttribute(STUDY_INFO_PANEL, panel);
// YW, 2-15-2008 <<
session.removeAttribute("allSelectedItems");
session.removeAttribute("allSelectedGroups");
session.removeAttribute("allItems");
session.removeAttribute("newDataset");
// YW >>
if (StringUtil.isBlank(action)) {
// YW 08-2008 << 2529 fix
StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
StudyBean studyWithEventDefinitions = currentStudy;
if (currentStudy.getParentStudyId() > 0) {
studyWithEventDefinitions = new StudyBean();
studyWithEventDefinitions.setId(currentStudy.getParentStudyId());
}
ArrayList seds = seddao.findAllActiveByStudy(studyWithEventDefinitions);
CRFDAO crfdao = new CRFDAO(sm.getDataSource());
HashMap events = new LinkedHashMap();
for (int i = 0; i < seds.size(); i++) {
StudyEventDefinitionBean sed = (StudyEventDefinitionBean) seds.get(i);
ArrayList crfs = (ArrayList) crfdao.findAllActiveByDefinition(sed);
if (!crfs.isEmpty()) {
events.put(sed, crfs);
}
}
session.setAttribute("eventsForCreateDataset", events);
// YW >>
FormProcessor fp = new FormProcessor(request);
EntityBeanTable table = fp.getEntityBeanTable();
ArrayList datasets = new ArrayList();
// if (ub.isSysAdmin()) {
// datasets = 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();
request.setAttribute("table", table);
// this is the old code that the tabling code replaced:
// ArrayList datasets = (ArrayList)dsdao.findAll();
// request.setAttribute("datasets", datasets);
forwardPage(Page.VIEW_DATASETS);
} else {
if ("owner".equalsIgnoreCase(action)) {
FormProcessor fp = new FormProcessor(request);
int ownerId = fp.getInt("ownerId");
EntityBeanTable table = fp.getEntityBeanTable();
ArrayList datasets = (ArrayList) dsdao.findByOwnerId(ownerId, currentStudy.getId());
/*
* if (datasets.isEmpty()) {
* forwardPage(Page.VIEW_EMPTY_DATASETS); } else {
*/
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_all_datasets"), "ViewDatasets");
table.addLink(resword.getString("create_dataset"), "CreateDataset");
table.setQuery("ViewDatasets?action=owner&ownerId=" + ub.getId(), new HashMap());
table.setRows(datasetRows);
table.computeDisplay();
request.setAttribute("table", table);
// this is the old code:
// ArrayList datasets = (ArrayList)dsdao.findByOwnerId(ownerId);
// request.setAttribute("datasets", datasets);
forwardPage(Page.VIEW_DATASETS);
// }
} else if ("details".equalsIgnoreCase(action)) {
FormProcessor fp = new FormProcessor(request);
int datasetId = fp.getInt("datasetId");
DatasetBean db = initializeAttributes(datasetId);
StudyDAO sdao = new StudyDAO(sm.getDataSource());
StudyBean study = (StudyBean) sdao.findByPK(db.getStudyId());
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;
}
/*
* EntityBeanTable table = fp.getEntityBeanTable(); ArrayList
* datasetRows = DatasetRow.generateRowFromBean(db); String[]
* columns = { "Dataset Name", "Description", "Created By",
* "Created Date", "Status", "Actions" }; table.setColumns(new
* ArrayList(Arrays.asList(columns))); table.hideColumnLink(5);
* table.setQuery("ViewDatasets", new HashMap());
* table.setRows(datasetRows); table.computeDisplay();
* request.setAttribute("table", table);
*/
request.setAttribute("dataset", db);
forwardPage(Page.VIEW_DATASET_DETAILS);
}
}
}
Aggregations