use of org.akaza.openclinica.bean.extract.DatasetBean 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.bean.extract.DatasetBean 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);
}
}
}
use of org.akaza.openclinica.bean.extract.DatasetBean in project OpenClinica by OpenClinica.
the class RestoreStudyServlet method processRequest.
@Override
public void processRequest() throws Exception {
StudyDAO sdao = new StudyDAO(sm.getDataSource());
FormProcessor fp = new FormProcessor(request);
int studyId = fp.getInt("id");
StudyBean study = (StudyBean) sdao.findByPK(studyId);
// find all sites
ArrayList sites = (ArrayList) sdao.findAllByParent(studyId);
// find all user and roles in the study, include ones in sites
UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
ArrayList userRoles = udao.findAllByStudyId(studyId);
// find all subjects in the study, include ones in sites
StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
ArrayList subjects = ssdao.findAllByStudy(study);
// find all events in the study, include ones in sites
StudyEventDefinitionDAO sefdao = new StudyEventDefinitionDAO(sm.getDataSource());
ArrayList definitions = sefdao.findAllByStudy(study);
String action = request.getParameter("action");
if (studyId == 0) {
addPageMessage(respage.getString("please_choose_a_study_to_restore"));
forwardPage(Page.STUDY_LIST_SERVLET);
} else {
if ("confirm".equalsIgnoreCase(action)) {
request.setAttribute("studyToRestore", study);
request.setAttribute("sitesToRestore", sites);
request.setAttribute("userRolesToRestore", userRoles);
request.setAttribute("subjectsToRestore", subjects);
request.setAttribute("definitionsToRRestore", definitions);
forwardPage(Page.RESTORE_STUDY);
} else {
logger.info("submit to restore the study");
// change all statuses to unavailable
StudyDAO studao = new StudyDAO(sm.getDataSource());
study.setStatus(study.getOldStatus());
study.setUpdater(ub);
study.setUpdatedDate(new Date());
studao.update(study);
// YW 09-27-2007 << restore auto-removed sites
for (int i = 0; i < sites.size(); i++) {
StudyBean site = (StudyBean) sites.get(i);
if (site.getStatus() == Status.AUTO_DELETED) {
site.setStatus(site.getOldStatus());
site.setUpdater(ub);
site.setUpdatedDate(new Date());
sdao.update(site);
}
}
// restore all users and roles
for (int i = 0; i < userRoles.size(); i++) {
StudyUserRoleBean role = (StudyUserRoleBean) userRoles.get(i);
if (role.getStatus().equals(Status.AUTO_DELETED)) {
role.setStatus(Status.AVAILABLE);
role.setUpdater(ub);
role.setUpdatedDate(new Date());
udao.updateStudyUserRole(role, role.getUserName());
}
}
// is current active study
if (study.getId() == currentStudy.getId()) {
currentStudy.setStatus(Status.AVAILABLE);
StudyUserRoleBean r = (new UserAccountDAO(sm.getDataSource())).findRoleByUserNameAndStudyId(ub.getName(), currentStudy.getId());
currentRole.setRole(r.getRole());
} else // active site will be restored as well if it was auto-removed
if (currentStudy.getParentStudyId() == study.getId() && currentStudy.getStatus() == Status.AUTO_DELETED) {
currentStudy.setStatus(Status.AVAILABLE);
StudyUserRoleBean r = (new UserAccountDAO(sm.getDataSource())).findRoleByUserNameAndStudyId(ub.getName(), currentStudy.getId());
StudyUserRoleBean rInParent = (new UserAccountDAO(sm.getDataSource())).findRoleByUserNameAndStudyId(ub.getName(), currentStudy.getParentStudyId());
// according to logic in SecureController.java: inherited
// role from parent study, pick the higher role
currentRole.setRole(Role.get(Role.max(r.getRole(), rInParent.getRole()).getId()));
}
// restore all subjects
for (int i = 0; i < subjects.size(); i++) {
StudySubjectBean subject = (StudySubjectBean) subjects.get(i);
if (subject.getStatus().equals(Status.AUTO_DELETED)) {
subject.setStatus(Status.AVAILABLE);
subject.setUpdater(ub);
subject.setUpdatedDate(new Date());
ssdao.update(subject);
}
}
// restore all study_group
StudyGroupDAO sgdao = new StudyGroupDAO(sm.getDataSource());
StudyGroupClassDAO sgcdao = new StudyGroupClassDAO(sm.getDataSource());
SubjectGroupMapDAO sgmdao = new SubjectGroupMapDAO(sm.getDataSource());
ArrayList groups = sgcdao.findAllByStudy(study);
for (int i = 0; i < groups.size(); i++) {
StudyGroupClassBean group = (StudyGroupClassBean) groups.get(i);
if (group.getStatus().equals(Status.AUTO_DELETED)) {
group.setStatus(Status.AVAILABLE);
group.setUpdater(ub);
group.setUpdatedDate(new Date());
sgcdao.update(group);
// all subject_group_map
ArrayList subjectGroupMaps = sgmdao.findAllByStudyGroupClassId(group.getId());
for (int j = 0; j < subjectGroupMaps.size(); j++) {
SubjectGroupMapBean sgMap = (SubjectGroupMapBean) subjectGroupMaps.get(j);
if (sgMap.getStatus().equals(Status.AUTO_DELETED)) {
sgMap.setStatus(Status.AVAILABLE);
sgMap.setUpdater(ub);
sgMap.setUpdatedDate(new Date());
sgmdao.update(sgMap);
}
}
}
}
// restore all event definitions and event
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
for (int i = 0; i < definitions.size(); i++) {
StudyEventDefinitionBean definition = (StudyEventDefinitionBean) definitions.get(i);
if (definition.getStatus().equals(Status.AUTO_DELETED)) {
definition.setStatus(Status.AVAILABLE);
definition.setUpdater(ub);
definition.setUpdatedDate(new Date());
sefdao.update(definition);
ArrayList edcs = (ArrayList) edcdao.findAllByDefinition(definition.getId());
for (int j = 0; j < edcs.size(); j++) {
EventDefinitionCRFBean edc = (EventDefinitionCRFBean) edcs.get(j);
if (edc.getStatus().equals(Status.AUTO_DELETED)) {
edc.setStatus(Status.AVAILABLE);
edc.setUpdater(ub);
edc.setUpdatedDate(new Date());
edcdao.update(edc);
}
}
ArrayList events = (ArrayList) sedao.findAllByDefinition(definition.getId());
EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
for (int j = 0; j < events.size(); j++) {
StudyEventBean event = (StudyEventBean) events.get(j);
if (event.getStatus().equals(Status.AUTO_DELETED)) {
event.setStatus(Status.AVAILABLE);
event.setUpdater(ub);
event.setUpdatedDate(new Date());
sedao.update(event);
ArrayList eventCRFs = ecdao.findAllByStudyEvent(event);
ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
for (int k = 0; k < eventCRFs.size(); k++) {
EventCRFBean eventCRF = (EventCRFBean) eventCRFs.get(k);
if (eventCRF.getStatus().equals(Status.AUTO_DELETED)) {
eventCRF.setStatus(eventCRF.getOldStatus());
eventCRF.setUpdater(ub);
eventCRF.setUpdatedDate(new Date());
ecdao.update(eventCRF);
ArrayList itemDatas = iddao.findAllByEventCRFId(eventCRF.getId());
for (int a = 0; a < itemDatas.size(); a++) {
ItemDataBean item = (ItemDataBean) itemDatas.get(a);
if (item.getStatus().equals(Status.AUTO_DELETED)) {
item.setStatus(item.getOldStatus());
item.setUpdater(ub);
item.setUpdatedDate(new Date());
iddao.update(item);
}
}
}
}
}
}
}
}
// for definitions
DatasetDAO datadao = new DatasetDAO(sm.getDataSource());
ArrayList dataset = datadao.findAllByStudyId(study.getId());
for (int i = 0; i < dataset.size(); i++) {
DatasetBean data = (DatasetBean) dataset.get(i);
if (data.getStatus().equals(Status.AUTO_DELETED)) {
data.setStatus(Status.AVAILABLE);
data.setUpdater(ub);
data.setUpdatedDate(new Date());
datadao.update(data);
}
}
addPageMessage(respage.getString("this_study_has_been_restored_succesfully"));
forwardPage(Page.STUDY_LIST_SERVLET);
}
}
}
use of org.akaza.openclinica.bean.extract.DatasetBean in project OpenClinica by OpenClinica.
the class ViewSelectedServlet method processRequest.
@Override
public void processRequest() throws Exception {
DatasetBean db = (DatasetBean) session.getAttribute("newDataset");
HashMap events = (HashMap) session.getAttribute(CreateDatasetServlet.EVENTS_FOR_CREATE_DATASET);
if (events == null) {
events = new HashMap();
}
request.setAttribute("eventlist", events);
CRFDAO crfdao = new CRFDAO(sm.getDataSource());
ItemDAO idao = new ItemDAO(sm.getDataSource());
ItemFormMetadataDAO imfdao = new ItemFormMetadataDAO(sm.getDataSource());
// new
ArrayList ids = CreateDatasetServlet.allSedItemIdsInStudy(events, crfdao, idao);
// ArrayList();
// ArrayList allItemsInStudy = EditSelectedServlet.selectAll(events,
// crfdao, idao);
// for (int j = 0; j < allItemsInStudy.size(); j++) {
// ItemBean item = (ItemBean) allItemsInStudy.get(j);
// Integer itemId = new Integer(item.getId());
// if (!ids.contains(itemId)) {
// ids.add(itemId);
// }
// }
session.setAttribute("numberOfStudyItems", new Integer(ids.size()).toString());
ArrayList items = new ArrayList();
if (db == null || db.getItemIds().size() == 0) {
session.setAttribute("allSelectedItems", items);
// FIXME can it be that we have no selected
setUpStudyGroups();
// items and
// some selected groups? tbh
forwardPage(Page.CREATE_DATASET_VIEW_SELECTED);
return;
}
items = getAllSelected(db, idao, imfdao);
session.setAttribute("allSelectedItems", items);
FormProcessor fp = new FormProcessor(request);
String status = fp.getString("status");
if (!StringUtil.isBlank(status) && "html".equalsIgnoreCase(status)) {
forwardPage(Page.CREATE_DATASET_VIEW_SELECTED_HTML);
} else {
setUpStudyGroups();
forwardPage(Page.CREATE_DATASET_VIEW_SELECTED);
}
}
use of org.akaza.openclinica.bean.extract.DatasetBean in project OpenClinica by OpenClinica.
the class RestoreDatasetServlet 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);
String action = request.getParameter("action");
if (resword.getString("restore_this_dataset").equalsIgnoreCase(action)) {
dataset.setStatus(Status.AVAILABLE);
dsDAO.update(dataset);
addPageMessage(respage.getString("dataset_has_been_succesfully_reinstated"));
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.RESTORE_DATASET);
}
}
Aggregations