use of org.akaza.openclinica.dao.service.StudyConfigService in project OpenClinica by OpenClinica.
the class InitUpdateStudyServlet method processRequest.
/**
* Processes the request
*/
@Override
public void processRequest() throws Exception {
StudyDAO sdao = new StudyDAO(sm.getDataSource());
String idString = request.getParameter("id");
logger.info("study id:" + idString);
if (StringUtil.isBlank(idString)) {
addPageMessage(respage.getString("please_choose_a_study_to_edit"));
forwardPage(Page.STUDY_LIST_SERVLET);
} else {
int studyId = Integer.valueOf(idString.trim()).intValue();
StudyBean study = (StudyBean) sdao.findByPK(studyId);
StudyConfigService scs = new StudyConfigService(sm.getDataSource());
study = scs.setParametersForStudy(study);
logger.info("date created:" + study.getCreatedDate());
logger.info("protocol Type:" + study.getProtocolType());
session.setAttribute("newStudy", study);
request.setAttribute("facRecruitStatusMap", CreateStudyServlet.facRecruitStatusMap);
request.setAttribute("statuses", Status.toActiveArrayList());
resetPanel();
panel.setStudyInfoShown(false);
panel.setOrderedData(true);
panel.setExtractData(false);
panel.setSubmitDataModule(false);
panel.setCreateDataset(false);
panel.setIconInfoShown(true);
panel.setManageSubject(false);
forwardPage(Page.UPDATE_STUDY1);
}
}
use of org.akaza.openclinica.dao.service.StudyConfigService in project OpenClinica by OpenClinica.
the class SetUpStudyRole method setUp.
public void setUp(HttpSession httpSession, UserAccountBean userAccountBean) {
StudyUserRoleBean currentRole = new StudyUserRoleBean();
StudyBean currentStudy = new StudyBean();
StudyInfoPanel panel = new StudyInfoPanel();
StudyDAO sdao = new StudyDAO(dataSource);
if (userAccountBean.getId() > 0 && userAccountBean.getActiveStudyId() > 0) {
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(dataSource);
currentStudy = (StudyBean) sdao.findByPK(userAccountBean.getActiveStudyId());
ArrayList studyParameters = spvdao.findParamConfigByStudy(currentStudy);
currentStudy.setStudyParameters(studyParameters);
StudyConfigService scs = new StudyConfigService(dataSource);
if (currentStudy.getParentStudyId() <= 0) {
// top study
scs.setParametersForStudy(currentStudy);
} else {
// YW <<
currentStudy.setParentStudyName(((StudyBean) sdao.findByPK(currentStudy.getParentStudyId())).getName());
// YW >>
scs.setParametersForSite(currentStudy);
}
// set up the panel here, tbh
panel.reset();
/*
* panel.setData("Study", currentStudy.getName());
* panel.setData("Summary", currentStudy.getSummary());
* panel.setData("Start Date",
* sdf.format(currentStudy.getDatePlannedStart()));
* panel.setData("End Date",
* sdf.format(currentStudy.getDatePlannedEnd()));
* panel.setData("Principal Investigator",
* currentStudy.getPrincipalInvestigator());
*/
httpSession.setAttribute(STUDY_INFO_PANEL, panel);
} else {
currentStudy = new StudyBean();
}
httpSession.setAttribute("study", currentStudy);
// restored
if (currentStudy.getParentStudyId() > 0) {
currentStudy.setParentStudyName(((StudyBean) sdao.findByPK(currentStudy.getParentStudyId())).getName());
}
if (currentStudy.getParentStudyId() > 0) {
/*The Role decription will be set depending on whether the user logged in at
study lever or site level. issue-2422*/
List roles = Role.toArrayList();
for (Iterator it = roles.iterator(); it.hasNext(); ) {
Role role = (Role) it.next();
switch(role.getId()) {
case 2:
role.setDescription("site_Study_Coordinator");
break;
case 3:
role.setDescription("site_Study_Director");
break;
case 4:
role.setDescription("site_investigator");
break;
case 5:
role.setDescription("site_Data_Entry_Person");
break;
case 6:
role.setDescription("site_monitor");
break;
case 7:
role.setDescription("site_Data_Entry_Person2");
break;
default:
}
}
} else {
/*If the current study is a site, we will change the role description. issue-2422*/
List roles = Role.toArrayList();
for (Iterator it = roles.iterator(); it.hasNext(); ) {
Role role = (Role) it.next();
switch(role.getId()) {
case 2:
role.setDescription("Study_Coordinator");
break;
case 3:
role.setDescription("Study_Director");
break;
case 4:
role.setDescription("investigator");
break;
case 5:
role.setDescription("Data_Entry_Person");
break;
case 6:
role.setDescription("monitor");
break;
default:
}
}
}
if (currentRole.getId() <= 0) {
// kept as "invalid" -- YW 06-21-2007
if (userAccountBean.getId() > 0 && currentStudy.getId() > 0 && !currentStudy.getStatus().getName().equals("removed")) {
currentRole = userAccountBean.getRoleByStudy(currentStudy.getId());
if (currentStudy.getParentStudyId() > 0) {
// Checking if currentStudy has been removed or not will
// ge good enough -- YW 10-17-2007
StudyUserRoleBean roleInParent = userAccountBean.getRoleByStudy(currentStudy.getParentStudyId());
// inherited role from parent study, pick the higher
// role
currentRole.setRole(Role.max(currentRole.getRole(), roleInParent.getRole()));
}
// logger.info("currentRole:" + currentRole.getRoleName());
} else {
currentRole = new StudyUserRoleBean();
}
httpSession.setAttribute("userRole", currentRole);
} else // active study has been removed.
if (currentRole.getId() > 0 && (currentStudy.getStatus().equals(Status.DELETED) || currentStudy.getStatus().equals(Status.AUTO_DELETED))) {
currentRole.setRole(Role.INVALID);
currentRole.setStatus(Status.DELETED);
httpSession.setAttribute("userRole", currentRole);
}
}
use of org.akaza.openclinica.dao.service.StudyConfigService in project OpenClinica by OpenClinica.
the class ChangeStudyServlet method changeStudy.
private void changeStudy() throws Exception {
Validator v = new Validator(request);
FormProcessor fp = new FormProcessor(request);
int studyId = fp.getInt("studyId");
int prevStudyId = currentStudy.getId();
StudyDAO sdao = new StudyDAO(sm.getDataSource());
StudyBean current = (StudyBean) sdao.findByPK(studyId);
// reset study parameters -jxu 02/09/2007
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
ArrayList studyParameters = spvdao.findParamConfigByStudy(current);
current.setStudyParameters(studyParameters);
int parentStudyId = currentStudy.getParentStudyId() > 0 ? currentStudy.getParentStudyId() : currentStudy.getId();
StudyParameterValueBean parentSPV = spvdao.findByHandleAndStudy(parentStudyId, "subjectIdGeneration");
current.getStudyParameterConfig().setSubjectIdGeneration(parentSPV.getValue());
String idSetting = current.getStudyParameterConfig().getSubjectIdGeneration();
if (idSetting.equals("auto editable") || idSetting.equals("auto non-editable")) {
int nextLabel = this.getStudySubjectDAO().findTheGreatestLabel() + 1;
request.setAttribute("label", new Integer(nextLabel).toString());
}
StudyConfigService scs = new StudyConfigService(sm.getDataSource());
if (current.getParentStudyId() <= 0) {
// top study
scs.setParametersForStudy(current);
} else {
// YW <<
if (current.getParentStudyId() > 0) {
current.setParentStudyName(((StudyBean) sdao.findByPK(current.getParentStudyId())).getName());
}
// YW 06-12-2007>>
scs.setParametersForSite(current);
}
if (current.getStatus().equals(Status.DELETED) || current.getStatus().equals(Status.AUTO_DELETED)) {
session.removeAttribute("studyWithRole");
addPageMessage(restext.getString("study_choosed_removed_restore_first"));
} else {
session.setAttribute("study", current);
currentStudy = current;
// change user's active study id
UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
ub.setActiveStudyId(current.getId());
ub.setUpdater(ub);
ub.setUpdatedDate(new java.util.Date());
udao.update(ub);
if (current.getParentStudyId() > 0) {
/*
* The Role decription will be set depending on whether the user
* logged in at study lever or site level. issue-2422
*/
List roles = Role.toArrayList();
for (Iterator it = roles.iterator(); it.hasNext(); ) {
Role role = (Role) it.next();
switch(role.getId()) {
case 2:
role.setDescription("site_Study_Coordinator");
break;
case 3:
role.setDescription("site_Study_Director");
break;
case 4:
role.setDescription("site_investigator");
break;
case 5:
role.setDescription("site_Data_Entry_Person");
break;
case 6:
role.setDescription("site_monitor");
break;
case 7:
role.setDescription("site_Data_Entry_Person2");
break;
default:
}
}
} else {
/*
* If the current study is a site, we will change the role
* description. issue-2422
*/
List roles = Role.toArrayList();
for (Iterator it = roles.iterator(); it.hasNext(); ) {
Role role = (Role) it.next();
switch(role.getId()) {
case 2:
role.setDescription("Study_Coordinator");
break;
case 3:
role.setDescription("Study_Director");
break;
case 4:
role.setDescription("investigator");
break;
case 5:
role.setDescription("Data_Entry_Person");
break;
case 6:
role.setDescription("monitor");
break;
default:
}
}
}
currentRole = (StudyUserRoleBean) session.getAttribute("studyWithRole");
session.setAttribute("userRole", currentRole);
session.removeAttribute("studyWithRole");
addPageMessage(restext.getString("current_study_changed_succesfully"));
}
ub.incNumVisitsToMainMenu();
// YW 2-18-2008, if study has been really changed <<
if (prevStudyId != studyId) {
session.removeAttribute("eventsForCreateDataset");
session.setAttribute("tableFacadeRestore", "false");
}
request.setAttribute("studyJustChanged", "yes");
// YW >>
//Integer assignedDiscrepancies = getDiscrepancyNoteDAO().countAllItemDataByStudyAndUser(currentStudy, ub);
Integer assignedDiscrepancies = getDiscrepancyNoteDAO().getViewNotesCountWithFilter(" AND dn.assigned_user_id =" + ub.getId() + " AND (dn.resolution_status_id=1 OR dn.resolution_status_id=2 OR dn.resolution_status_id=3)", currentStudy);
request.setAttribute("assignedDiscrepancies", assignedDiscrepancies == null ? 0 : assignedDiscrepancies);
if (currentRole.isInvestigator() || currentRole.isResearchAssistant() || currentRole.isResearchAssistant2()) {
setupListStudySubjectTable();
}
if (currentRole.isMonitor()) {
setupSubjectSDVTable();
} else if (currentRole.isCoordinator() || currentRole.isDirector()) {
if (currentStudy.getStatus().isPending()) {
response.sendRedirect(request.getContextPath() + Page.MANAGE_STUDY_MODULE.getFileName());
return;
}
setupStudySiteStatisticsTable();
setupSubjectEventStatusStatisticsTable();
setupStudySubjectStatusStatisticsTable();
if (currentStudy.getParentStudyId() == 0) {
setupStudyStatisticsTable();
}
}
forwardPage(Page.MENU);
}
use of org.akaza.openclinica.dao.service.StudyConfigService in project OpenClinica by OpenClinica.
the class CoreSecureController method process.
private void process(HttpServletRequest request, HttpServletResponse response) throws OpenClinicaException, UnsupportedEncodingException {
request.setCharacterEncoding("UTF-8");
response.setHeader("Content-Encoding", "gzip");
HttpSession session = request.getSession();
// BWP >> 1/8/2008
try {
// YW 10-03-2007 <<
session.setMaxInactiveInterval(Integer.parseInt(SQLInitServlet.getField("max_inactive_interval")));
// YW >>
} catch (NumberFormatException nfe) {
// BWP>>3600 is the datainfo.properties maxInactiveInterval on
// 1/8/2008
session.setMaxInactiveInterval(3600);
}
// If the session already has a value with key SUPPORT_URL don't reset
if (session.getAttribute(SUPPORT_URL) == null) {
session.setAttribute(SUPPORT_URL, SQLInitServlet.getSupportURL());
}
UserAccountBean ub = (UserAccountBean) session.getAttribute(USER_BEAN_NAME);
StudyBean currentStudy = (StudyBean) session.getAttribute("study");
StudyUserRoleBean currentRole = (StudyUserRoleBean) session.getAttribute("userRole");
// Set current language preferences
Locale locale = LocaleResolver.getLocale(request);
ResourceBundleProvider.updateLocale(locale);
resadmin = ResourceBundleProvider.getAdminBundle(locale);
resaudit = ResourceBundleProvider.getAuditEventsBundle(locale);
resexception = ResourceBundleProvider.getExceptionsBundle(locale);
resformat = ResourceBundleProvider.getFormatBundle(locale);
restext = ResourceBundleProvider.getTextsBundle(locale);
resterm = ResourceBundleProvider.getTermsBundle(locale);
resword = ResourceBundleProvider.getWordsBundle(locale);
respage = ResourceBundleProvider.getPageMessagesBundle(locale);
resworkflow = ResourceBundleProvider.getWorkflowBundle(locale);
try {
String userName = request.getRemoteUser();
ServletContext context = getServletContext();
// BWP 1/8/08<< the sm variable may already be set with a mock
// object,
// from the perspective of
// JUnit servlets tests
/*
* if(sm==null && (!StringUtil.isBlank(userName))) {//check if user
* logged in, then create a new sessionmanger to get ub //create a
* new sm in order to get a new ub object sm = new
* SessionManager(ub, userName); }
*/
// BWP 01/08 >>
// sm = new SessionManager(ub, userName);
SessionManager sm = new SessionManager(ub, userName, SpringServletAccess.getApplicationContext(context));
ub = sm.getUserBean();
request.getSession().setAttribute("sm", sm);
session.setAttribute("userBean", ub);
StudyDAO sdao = new StudyDAO(getDataSource());
if (currentStudy == null || currentStudy.getId() <= 0) {
if (ub.getId() > 0 && ub.getActiveStudyId() > 0) {
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(getDataSource());
currentStudy = (StudyBean) sdao.findByPK(ub.getActiveStudyId());
ArrayList studyParameters = spvdao.findParamConfigByStudy(currentStudy);
currentStudy.setStudyParameters(studyParameters);
StudyConfigService scs = new StudyConfigService(getDataSource());
if (currentStudy.getParentStudyId() <= 0) {
// top study
scs.setParametersForStudy(currentStudy);
} else {
// YW <<
currentStudy.setParentStudyName(((StudyBean) sdao.findByPK(currentStudy.getParentStudyId())).getName());
// YW >>
scs.setParametersForSite(currentStudy);
}
// set up the panel here, tbh
panel.reset();
/*
* panel.setData("Study", currentStudy.getName());
* panel.setData("Summary", currentStudy.getSummary());
* panel.setData("Start Date",
* sdf.format(currentStudy.getDatePlannedStart()));
* panel.setData("End Date",
* sdf.format(currentStudy.getDatePlannedEnd()));
* panel.setData("Principal Investigator",
* currentStudy.getPrincipalInvestigator());
*/
session.setAttribute(STUDY_INFO_PANEL, panel);
} else {
currentStudy = new StudyBean();
}
// The above line is moved here since currentstudy's value is set in else block and could change
session.setAttribute("study", currentStudy);
} else if (currentStudy.getId() > 0) {
// restored
if (currentStudy.getParentStudyId() > 0) {
currentStudy.setParentStudyName(((StudyBean) sdao.findByPK(currentStudy.getParentStudyId())).getName());
}
// YW >>
}
if (currentStudy.getParentStudyId() > 0) {
/*
* The Role decription will be set depending on whether the user
* logged in at study lever or site level. issue-2422
*/
List roles = Role.toArrayList();
for (Iterator it = roles.iterator(); it.hasNext(); ) {
Role role = (Role) it.next();
switch(role.getId()) {
case 2:
role.setDescription("site_Study_Coordinator");
break;
case 3:
role.setDescription("site_Study_Director");
break;
case 4:
role.setDescription("site_investigator");
break;
case 5:
role.setDescription("site_Data_Entry_Person");
break;
case 6:
role.setDescription("site_monitor");
break;
case 7:
role.setDescription("site_Data_Entry_Person2");
break;
default:
}
}
} else {
/*
* If the current study is a site, we will change the role
* description. issue-2422
*/
List roles = Role.toArrayList();
for (Iterator it = roles.iterator(); it.hasNext(); ) {
Role role = (Role) it.next();
switch(role.getId()) {
case 2:
role.setDescription("Study_Coordinator");
break;
case 3:
role.setDescription("Study_Director");
break;
case 4:
role.setDescription("Investigator");
break;
case 5:
role.setDescription("Data_Entry_Person");
break;
case 6:
role.setDescription("Monitor");
break;
default:
}
}
}
if (currentRole == null || currentRole.getId() <= 0) {
// kept as "invalid" -- YW 06-21-2007
if (ub.getId() > 0 && currentStudy.getId() > 0 && !currentStudy.getStatus().getName().equals("removed")) {
currentRole = ub.getRoleByStudy(currentStudy.getId());
if (currentStudy.getParentStudyId() > 0) {
// Checking if currentStudy has been removed or not will
// ge good enough -- YW 10-17-2007
StudyUserRoleBean roleInParent = ub.getRoleByStudy(currentStudy.getParentStudyId());
// inherited role from parent study, pick the higher
// role
currentRole.setRole(Role.max(currentRole.getRole(), roleInParent.getRole()));
}
// logger.info("currentRole:" + currentRole.getRoleName());
} else {
currentRole = new StudyUserRoleBean();
}
session.setAttribute("userRole", currentRole);
} else // active study has been removed.
if (currentRole.getId() > 0 && (currentStudy.getStatus().equals(Status.DELETED) || currentStudy.getStatus().equals(Status.AUTO_DELETED))) {
currentRole.setRole(Role.INVALID);
currentRole.setStatus(Status.DELETED);
session.setAttribute("userRole", currentRole);
}
// YW 06-19-2007 >>
request.setAttribute("isAdminServlet", getAdminServlet());
// logger.info(rq_names);
if (!request.getRequestURI().endsWith("ResetPassword")) {
passwdTimeOut(request, response, ub);
}
mayProceed(request, response);
// pingJobServer(request);
processRequest(request, response);
} catch (InconsistentStateException ise) {
ise.printStackTrace();
LOGGER.warn("InconsistentStateException: org.akaza.openclinica.control.CoreSecureController: ", ise);
unlockCRFOnError(request);
addPageMessage(ise.getOpenClinicaMessage(), request);
forwardPage(ise.getGoTo(), request, response);
} catch (InsufficientPermissionException ipe) {
ipe.printStackTrace();
LOGGER.warn("InsufficientPermissionException: org.akaza.openclinica.control.CoreSecureController: ", ipe);
unlockCRFOnError(request);
// addPageMessage(ipe.getOpenClinicaMessage());
forwardPage(ipe.getGoTo(), request, response);
} catch (Exception e) {
LOGGER.error("Error processing request", e);
unlockCRFOnError(request);
forwardPage(Page.ERROR, request, response);
}
}
Aggregations