use of org.akaza.openclinica.control.form.FormProcessor in project OpenClinica by OpenClinica.
the class PauseJobServlet method processRequest.
// also perhaps DRY, tbh
@Override
protected void processRequest() throws Exception {
FormProcessor fp = new FormProcessor(request);
String triggerName = fp.getString("tname");
// String gName = fp.getString("gname");
String gName = request.getParameter("gname");
String finalGroupName = "";
if ("".equals(gName) || "0".equals(gName)) {
finalGroupName = XsltTriggerService.TRIGGER_GROUP_NAME;
} else {
// should equal 1
finalGroupName = groupImportName;
}
String deleteMe = fp.getString("del");
scheduler = getScheduler();
Trigger trigger = scheduler.getTrigger(TriggerKey.triggerKey(triggerName, finalGroupName));
try {
if (("y".equals(deleteMe)) && (ub.isSysAdmin())) {
scheduler.deleteJob(JobKey.jobKey(triggerName, finalGroupName));
// set return message here
logger.debug("deleted job: " + triggerName);
addPageMessage("The following job " + triggerName + " and its corresponding Trigger have been deleted from the system.");
} else {
if (scheduler.getTriggerState(TriggerKey.triggerKey(triggerName, finalGroupName)) == Trigger.TriggerState.PAUSED) {
scheduler.resumeTrigger(TriggerKey.triggerKey(triggerName, finalGroupName));
// trigger.setPriority(Trigger.DEFAULT_PRIORITY);
logger.debug("-- resuming trigger! " + triggerName + " " + finalGroupName);
addPageMessage("This trigger " + triggerName + " has been resumed and will continue to run until paused or deleted.");
// set message here
} else {
scheduler.pauseTrigger(TriggerKey.triggerKey(triggerName, finalGroupName));
// trigger.setPriority(Trigger.STATE_PAUSED);
logger.debug("-- pausing trigger! " + triggerName + " " + finalGroupName);
addPageMessage("This trigger " + triggerName + " has been paused, and will not run again until it is restored.");
// set message here
}
}
} catch (NullPointerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// set a message
if ("".equals(gName) || "0".equals(gName)) {
forwardPage(Page.VIEW_JOB_SERVLET);
} else {
forwardPage(Page.VIEW_IMPORT_JOB_SERVLET);
}
}
use of org.akaza.openclinica.control.form.FormProcessor in project OpenClinica by OpenClinica.
the class RestoreCRFServlet method processRequest.
@Override
public void processRequest() throws Exception {
CRFDAO cdao = new CRFDAO(sm.getDataSource());
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
FormProcessor fp = new FormProcessor(request);
// checks which module the requests are from
String module = fp.getString(MODULE);
request.setAttribute(MODULE, module);
int crfId = fp.getInt("id", true);
String action = request.getParameter("action");
if (crfId == 0) {
addPageMessage(respage.getString("please_choose_a_CRF_to_restore"));
forwardPage(Page.CRF_LIST_SERVLET);
} else {
CRFBean crf = (CRFBean) cdao.findByPK(crfId);
ArrayList versions = cvdao.findAllByCRFId(crfId);
crf.setVersions(versions);
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
ArrayList edcs = (ArrayList) edcdao.findAllByCRF(crfId);
SectionDAO secdao = new SectionDAO(sm.getDataSource());
EventCRFDAO evdao = new EventCRFDAO(sm.getDataSource());
ArrayList eventCRFs = evdao.findAllByCRF(crfId);
if ("confirm".equalsIgnoreCase(action)) {
request.setAttribute("crfToRestore", crf);
request.setAttribute("eventCRFs", eventCRFs);
forwardPage(Page.RESTORE_CRF);
} else {
logger.info("submit to restore the crf");
crf.setStatus(Status.AVAILABLE);
crf.setUpdater(ub);
crf.setUpdatedDate(new Date());
cdao.update(crf);
for (int i = 0; i < versions.size(); i++) {
CRFVersionBean version = (CRFVersionBean) versions.get(i);
if (version.getStatus().equals(Status.AUTO_DELETED)) {
version.setStatus(Status.AVAILABLE);
version.setUpdater(ub);
version.setUpdatedDate(new Date());
cvdao.update(version);
ArrayList sections = secdao.findAllByCRFVersionId(version.getId());
for (int j = 0; j < sections.size(); j++) {
SectionBean section = (SectionBean) sections.get(j);
if (section.getStatus().equals(Status.AUTO_DELETED)) {
section.setStatus(Status.AVAILABLE);
section.setUpdater(ub);
section.setUpdatedDate(new Date());
secdao.update(section);
}
}
}
}
for (int i = 0; i < edcs.size(); i++) {
EventDefinitionCRFBean edc = (EventDefinitionCRFBean) edcs.get(i);
if (edc.getStatus().equals(Status.AUTO_DELETED)) {
edc.setStatus(Status.AVAILABLE);
edc.setUpdater(ub);
edc.setUpdatedDate(new Date());
edcdao.update(edc);
}
}
ItemDataDAO idao = new ItemDataDAO(sm.getDataSource());
for (int i = 0; i < eventCRFs.size(); i++) {
EventCRFBean eventCRF = (EventCRFBean) eventCRFs.get(i);
if (eventCRF.getStatus().equals(Status.AUTO_DELETED)) {
eventCRF.setStatus(Status.AVAILABLE);
eventCRF.setUpdater(ub);
eventCRF.setUpdatedDate(new Date());
evdao.update(eventCRF);
ArrayList items = idao.findAllByEventCRFId(eventCRF.getId());
for (int j = 0; j < items.size(); j++) {
ItemDataBean item = (ItemDataBean) items.get(j);
if (item.getStatus().equals(Status.AUTO_DELETED)) {
item.setStatus(Status.AVAILABLE);
item.setUpdater(ub);
item.setUpdatedDate(new Date());
idao.update(item);
}
}
}
}
addPageMessage(respage.getString("the_CRF") + crf.getName() + " " + respage.getString("has_been_restored_succesfully"));
forwardPage(Page.CRF_LIST_SERVLET);
}
}
}
use of org.akaza.openclinica.control.form.FormProcessor in project OpenClinica by OpenClinica.
the class RestoreCRFVersionServlet method processRequest.
@Override
public void processRequest() throws Exception {
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
FormProcessor fp = new FormProcessor(request);
// checks which module the requests are from
String module = fp.getString(MODULE);
request.setAttribute(MODULE, module);
int versionId = fp.getInt("id", true);
String action = fp.getString("action");
if (versionId == 0) {
addPageMessage(respage.getString("please_choose_a_CRF_version_to_restore"));
forwardPage(Page.CRF_LIST_SERVLET);
} else {
if (StringUtil.isBlank(action)) {
addPageMessage(respage.getString("no_action_specified"));
forwardPage(Page.CRF_LIST_SERVLET);
return;
}
CRFVersionBean version = (CRFVersionBean) cvdao.findByPK(versionId);
SectionDAO secdao = new SectionDAO(sm.getDataSource());
EventCRFDAO evdao = new EventCRFDAO(sm.getDataSource());
// find all event crfs by version id
ArrayList eventCRFs = evdao.findAllByCRFVersion(versionId);
if ("confirm".equalsIgnoreCase(action)) {
request.setAttribute("versionToRestore", version);
request.setAttribute("eventCRFs", eventCRFs);
forwardPage(Page.RESTORE_CRF_VERSION);
} else {
logger.info("submit to restore the crf version");
// version
version.setStatus(Status.AVAILABLE);
version.setUpdater(ub);
version.setUpdatedDate(new Date());
cvdao.update(version);
// all sections
ArrayList sections = secdao.findAllByCRFVersionId(version.getId());
for (int j = 0; j < sections.size(); j++) {
SectionBean section = (SectionBean) sections.get(j);
if (section.getStatus().equals(Status.AUTO_DELETED)) {
section.setStatus(Status.AVAILABLE);
section.setUpdater(ub);
section.setUpdatedDate(new Date());
secdao.update(section);
}
}
// all item data related to event crfs
ItemDataDAO idao = new ItemDataDAO(sm.getDataSource());
for (int i = 0; i < eventCRFs.size(); i++) {
EventCRFBean eventCRF = (EventCRFBean) eventCRFs.get(i);
if (eventCRF.getStatus().equals(Status.AUTO_DELETED)) {
eventCRF.setStatus(Status.AVAILABLE);
eventCRF.setUpdater(ub);
eventCRF.setUpdatedDate(new Date());
evdao.update(eventCRF);
ArrayList items = idao.findAllByEventCRFId(eventCRF.getId());
for (int j = 0; j < items.size(); j++) {
ItemDataBean item = (ItemDataBean) items.get(j);
if (item.getStatus().equals(Status.AUTO_DELETED)) {
item.setStatus(Status.AVAILABLE);
item.setUpdater(ub);
item.setUpdatedDate(new Date());
idao.update(item);
}
}
}
}
addPageMessage(respage.getString("the_CRF_version") + version.getName() + " " + respage.getString("has_been_restored_succesfully"));
forwardPage(Page.CRF_LIST_SERVLET);
}
}
}
use of org.akaza.openclinica.control.form.FormProcessor in project OpenClinica by OpenClinica.
the class InitUpdateCRFServlet method processRequest.
@Override
public void processRequest() throws Exception {
resetPanel();
panel.setStudyInfoShown(false);
panel.setOrderedData(true);
setToPanel(resword.getString("create_CRF"), respage.getString("br_create_new_CRF_entering"));
setToPanel(resword.getString("create_CRF_version"), respage.getString("br_create_new_CRF_uploading"));
setToPanel(resword.getString("revise_CRF_version"), respage.getString("br_if_you_owner_CRF_version"));
setToPanel(resword.getString("CRF_spreadsheet_template"), respage.getString("br_download_blank_CRF_spreadsheet_from"));
setToPanel(resword.getString("example_CRF_br_spreadsheets"), respage.getString("br_download_example_CRF_instructions_from"));
FormProcessor fp = new FormProcessor(request);
// checks which module the requests are from
String module = fp.getString(MODULE);
request.setAttribute(MODULE, module);
int crfId = fp.getInt(CRF_ID);
if (crfId == 0) {
addPageMessage(respage.getString("please_choose_a_CRF_version_to_update"));
forwardPage(Page.CRF_LIST_SERVLET);
} else {
CRFDAO cdao = new CRFDAO(sm.getDataSource());
CRFBean crf = (CRFBean) cdao.findByPK(crfId);
if (!ub.isSysAdmin() && (crf.getOwnerId() != ub.getId())) {
addPageMessage(respage.getString("no_have_correct_privilege_current_study") + " " + respage.getString("change_active_study_or_contact"));
forwardPage(Page.MENU_SERVLET);
return;
} else {
session.setAttribute(CRF, crf);
forwardPage(Page.UPDATE_CRF);
}
}
}
use of org.akaza.openclinica.control.form.FormProcessor in project OpenClinica by OpenClinica.
the class ViewCRFServlet method processRequest.
@Override
public void processRequest() throws Exception {
resetPanel();
panel.setStudyInfoShown(false);
panel.setOrderedData(true);
panel.setSubmitDataModule(false);
panel.setExtractData(false);
panel.setCreateDataset(false);
setToPanel(resword.getString("create_CRF"), respage.getString("br_create_new_CRF_entering"));
setToPanel(resword.getString("create_CRF_version"), respage.getString("br_create_new_CRF_uploading"));
setToPanel(resword.getString("revise_CRF_version"), respage.getString("br_if_you_owner_CRF_version"));
setToPanel(resword.getString("CRF_spreadsheet_template"), respage.getString("br_download_blank_CRF_spreadsheet_from"));
setToPanel(resword.getString("example_CRF_br_spreadsheets"), respage.getString("br_download_example_CRF_instructions_from"));
FormProcessor fp = new FormProcessor(request);
// checks which module the requests are from, manage or admin
String module = fp.getString(MODULE);
request.setAttribute(MODULE, module);
int crfId = fp.getInt(CRF_ID);
List<StudyBean> studyBeans = null;
if (crfId == 0) {
addPageMessage(respage.getString("please_choose_a_CRF_to_view"));
forwardPage(Page.CRF_LIST);
} else {
CRFDAO cdao = new CRFDAO(sm.getDataSource());
// CRFVersionDAO vdao = new CRFVersionDAO(sm.getDataSource());
FormLayoutDAO fdao = new FormLayoutDAO<>(sm.getDataSource());
CRFBean crf = (CRFBean) cdao.findByPK(crfId);
request.setAttribute("crfName", crf.getName());
// ArrayList<CRFVersionBean> crfVersions = (ArrayList<CRFVersionBean>) vdao.findAllByCRF(crfId);
ArrayList<FormLayoutBean> layoutVersions = (ArrayList<FormLayoutBean>) fdao.findAllByCRF(crfId);
crf.setVersions(layoutVersions);
ArrayList<ItemGroupCrvVersionUtil> items_verified = verifyUniqueItemPlacementInGroups(crf.getName());
request.setAttribute("items", items_verified);
if ("admin".equalsIgnoreCase(module)) {
// BWP 3279: generate a table showing a list of studies associated with the CRF>>
StudyDAO studyDAO = new StudyDAO(sm.getDataSource());
studyBeans = findStudiesForCRFId(crfId, studyDAO);
// Create the Jmesa table for the studies associated with the CRF
String studyHtml = renderStudiesTable(studyBeans);
request.setAttribute("studiesTableHTML", studyHtml);
// >>
}
Collection<TableColumnHolder> items = populate(crf, layoutVersions);
request.setAttribute(CRF, crf);
forwardPage(Page.VIEW_CRF);
}
}
Aggregations