use of org.akaza.openclinica.view.StudyInfoPanel 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.view.StudyInfoPanel in project OpenClinica by OpenClinica.
the class SecureController method forwardPage.
/**
* <P>
* Forwards to a jsp page. Additions to the forwardPage() method involve checking the session for the bread crumb trail
* and setting it, if necessary. Setting it here allows the developer to only have to update the
* <code>BreadcrumbTrail</code> class.
*
* @param jspPage The page to go to.
* @param checkTrail The command to check for, and set a trail in the session.
*/
protected void forwardPage(Page jspPage, boolean checkTrail) {
Page page1 = Page.valueOf(jspPage.name());
String temp;
// YW 10-03-2007 <<
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Pragma", "no-cache");
response.setDateHeader("Expires", -1);
response.setHeader("Cache-Control", "no-store");
if (request.getAttribute(POP_UP_URL) == null) {
request.setAttribute(POP_UP_URL, "");
}
try {
// Added 01/19/2005 for breadcrumbs, tbh
if (checkTrail) {
BreadcrumbTrail bt = new BreadcrumbTrail();
if (session != null) {
// added bu jxu, fixed bug for log out
/* ArrayList trail = (ArrayList) session.getAttribute("trail");
if (trail == null) {
trail = bt.generateTrail(jspPage, request);
} else {
bt.setTrail(trail);
trail = bt.generateTrail(jspPage, request);
}
session.setAttribute("trail", trail);*/
panel = (StudyInfoPanel) session.getAttribute(STUDY_INFO_PANEL);
if (panel == null) {
panel = new StudyInfoPanel();
panel.setData(jspPage, session, request);
} else {
panel.setData(jspPage, session, request);
}
session.setAttribute(STUDY_INFO_PANEL, panel);
}
// we are also using checkTrail to update the panel, tbh
// 01/31/2005
}
temp = page1.getFileName();
// above added 01/19/2005, tbh
context.getRequestDispatcher(temp).forward(request, response);
} catch (Exception se) {
/* if ("View Notes".equals(jspPage.getTitle())) {
String viewNotesURL = jspPage.getFileName();
if (viewNotesURL != null && viewNotesURL.contains("listNotes_p_=")) {
String[] ps = viewNotesURL.split("listNotes_p_=");
String t = ps[1].split("&")[0];
int p = t.length() > 0 ? Integer.valueOf(t).intValue() : -1;
if (p > 1) {
viewNotesURL = viewNotesURL.replace("listNotes_p_=" + p, "listNotes_p_=" + (p - 1));
//forwardPage(Page.setNewPage(viewNotesURL, "View Notes"));
try {
getServletContext().getRequestDispatcher(viewNotesURL).forward(request, response);
} catch (ServletException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else if (p <= 0) {
forwardPage(Page.VIEW_DISCREPANCY_NOTES_IN_STUDY);
}
}
}
*/
logger.error(se.getMessage(), se);
} finally {
page1 = null;
jspPage = null;
temp = null;
}
}
use of org.akaza.openclinica.view.StudyInfoPanel in project OpenClinica by OpenClinica.
the class ChangeCRFVersionController method resetPanel.
private void resetPanel(HttpServletRequest request) {
StudyInfoPanel panel = new StudyInfoPanel();
panel.reset();
panel.setIconInfoShown(false);
request.getSession().setAttribute("panel", panel);
}
use of org.akaza.openclinica.view.StudyInfoPanel in project OpenClinica by OpenClinica.
the class SDVController method viewAllSubjectHandler.
@RequestMapping("/viewAllSubjectSDVtmp")
public ModelMap viewAllSubjectHandler(HttpServletRequest request, @RequestParam("studyId") int studyId, HttpServletResponse response) {
if (!mayProceed(request)) {
try {
response.sendRedirect(request.getContextPath() + "/MainMenu?message=authentication_failed");
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
ResourceBundleProvider.updateLocale(LocaleResolver.getLocale(request));
// Reseting the side info panel set by SecureControler Mantis Issue: 8680.
// Todo need something to reset panel from all the Spring Controllers
StudyInfoPanel panel = new StudyInfoPanel();
panel.reset();
HttpSession session = request.getSession();
request.getSession().setAttribute("panel", panel);
ModelMap gridMap = new ModelMap();
// set up request attributes for sidebar
// Not necessary when using old page design...
// setUpSidebar(request);
boolean showMoreLink = false;
if (session.getAttribute("tableFacadeRestore") != null && session.getAttribute("tableFacadeRestore") == "false") {
session.setAttribute("tableFacadeRestore", "true");
session.setAttribute("sSdvRestore", "false");
showMoreLink = true;
} else if (request.getParameter("showMoreLink") != null) {
showMoreLink = Boolean.parseBoolean(request.getParameter("showMoreLink").toString());
} else if (session.getAttribute("sdv_showMoreLink") != null) {
showMoreLink = Boolean.parseBoolean(session.getAttribute("sdv_showMoreLink") + "");
} else {
showMoreLink = true;
}
request.setAttribute("showMoreLink", showMoreLink + "");
session.setAttribute("sdv_showMoreLink", showMoreLink + "");
request.setAttribute("studyId", studyId);
String restore = (String) request.getAttribute("sdv_restore");
restore = restore != null && restore.length() > 0 ? restore : "false";
request.setAttribute("sdv_restore", restore);
// request.setAttribute("imagePathPrefix","../");
// We need a study subject id for the first tab;
Integer studySubjectId = (Integer) request.getAttribute("studySubjectId");
studySubjectId = studySubjectId == null || studySubjectId == 0 ? 0 : studySubjectId;
request.setAttribute("studySubjectId", studySubjectId);
// set up the elements for the view's filter box
// sdvUtil.prepareSDVSelectElements(request,studyBean);
ArrayList<String> pageMessages = (ArrayList<String>) request.getAttribute("pageMessages");
if (pageMessages == null) {
pageMessages = new ArrayList<String>();
}
request.setAttribute("pageMessages", pageMessages);
String sdvMatrix = sdvUtil.renderEventCRFTableWithLimit(request, studyId, "../");
gridMap.addAttribute(SUBJECT_SDV_TABLE_ATTRIBUTE, sdvMatrix);
return gridMap;
}
use of org.akaza.openclinica.view.StudyInfoPanel in project OpenClinica by OpenClinica.
the class StudyModuleController method handleMainPage.
@RequestMapping(method = RequestMethod.GET)
public ModelMap handleMainPage(HttpServletRequest request, HttpServletResponse response) {
ModelMap map = new ModelMap();
// Todo need something to reset panel from all the Spring Controllers
StudyInfoPanel panel = new StudyInfoPanel();
UserAccountBean userBean = (UserAccountBean) request.getSession().getAttribute("userBean");
if (!mayProceed(request)) {
try {
response.sendRedirect(request.getContextPath() + "/MainMenu?message=authentication_failed");
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
panel.reset();
request.getSession().setAttribute("panel", panel);
// setUpSidebar(request);
ResourceBundleProvider.updateLocale(LocaleResolver.getLocale(request));
StudyBean currentStudy = (StudyBean) request.getSession().getAttribute("study");
eventDefinitionCRFDao = new EventDefinitionCRFDAO(dataSource);
studyEventDefinitionDao = new StudyEventDefinitionDAO(dataSource);
crfDao = new CRFDAO(dataSource);
studyGroupClassDao = new StudyGroupClassDAO(dataSource);
studyDao = new StudyDAO(dataSource);
userDao = new UserAccountDAO(dataSource);
ruleDao = new RuleDAO(dataSource);
StudyModuleStatus sms = studyModuleStatusDao.findByStudyId(currentStudy.getId());
if (sms == null) {
sms = new StudyModuleStatus();
sms.setStudyId(currentStudy.getId());
}
int crfCount = crfDao.findAllByStudy(currentStudy.getId()).size();
int crfWithEventDefinition = crfDao.findAllActiveByDefinitions(currentStudy.getId()).size();
int totalCrf = crfCount + crfWithEventDefinition;
// int eventDefinitionCount = eventDefinitionCRFDao.findAllActiveByStudy(currentStudy).size();
int eventDefinitionCount = studyEventDefinitionDao.findAllActiveByStudy(currentStudy).size();
int subjectGroupCount = studyGroupClassDao.findAllActiveByStudy(currentStudy).size();
// List<RuleSetBean> ruleSets = ruleSetService.getRuleSetsByStudy(currentStudy);
// ruleSets = ruleSetService.filterByStatusEqualsAvailableOnlyRuleSetRules(ruleSets);
int ruleCount = ruleSetService.getCountByStudy(currentStudy);
int siteCount = studyDao.findOlnySiteIdsByStudy(currentStudy).size();
int userCount = userDao.findAllUsersByStudy(currentStudy.getId()).size();
Collection childStudies = studyDao.findAllByParent(currentStudy.getId());
Map childStudyUserCount = new HashMap();
for (Object sb : childStudies) {
StudyBean childStudy = (StudyBean) sb;
childStudyUserCount.put(childStudy.getName(), userDao.findAllUsersByStudy(childStudy.getId()).size());
}
if (sms.getCrf() == 0) {
sms.setCrf(StudyModuleStatus.NOT_STARTED);
}
if (sms.getCrf() != 3 && totalCrf > 0) {
sms.setCrf(StudyModuleStatus.IN_PROGRESS);
}
if (sms.getEventDefinition() == 0) {
sms.setEventDefinition(StudyModuleStatus.NOT_STARTED);
}
if (sms.getEventDefinition() != 3 && eventDefinitionCount > 0) {
sms.setEventDefinition(StudyModuleStatus.IN_PROGRESS);
}
if (sms.getSubjectGroup() == 0) {
sms.setSubjectGroup(StudyModuleStatus.NOT_STARTED);
}
if (sms.getSubjectGroup() != 3 && subjectGroupCount > 0) {
sms.setSubjectGroup(StudyModuleStatus.IN_PROGRESS);
}
if (sms.getRule() == 0) {
sms.setRule(StudyModuleStatus.NOT_STARTED);
}
if (sms.getRule() != 3 && ruleCount > 0) {
sms.setRule(StudyModuleStatus.IN_PROGRESS);
}
if (sms.getSite() == 0) {
sms.setSite(StudyModuleStatus.NOT_STARTED);
}
if (sms.getSite() != 3 && siteCount > 0) {
sms.setSite(StudyModuleStatus.IN_PROGRESS);
}
if (sms.getUsers() == 0) {
sms.setUsers(StudyModuleStatus.NOT_STARTED);
}
if (sms.getUsers() != 3 && userCount > 0) {
sms.setUsers(StudyModuleStatus.IN_PROGRESS);
}
map.addObject(sms);
map.addAttribute("crfCount", totalCrf);
map.addAttribute("eventDefinitionCount", eventDefinitionCount);
map.addAttribute("subjectGroupCount", subjectGroupCount);
map.addAttribute("ruleCount", ruleCount);
map.addAttribute("siteCount", siteCount);
map.addAttribute("userCount", userCount);
map.addAttribute("childStudyUserCount", childStudyUserCount);
map.addAttribute("studyId", currentStudy.getId());
map.addAttribute("currentStudy", currentStudy);
// Load Participate registration information
String portalURL = CoreResources.getField("portalURL");
map.addAttribute("portalURL", portalURL);
if (portalURL != null && !portalURL.equals("")) {
String participateOCStatus = currentStudy.getStudyParameterConfig().getParticipantPortal();
ParticipantPortalRegistrar registrar = new ParticipantPortalRegistrar();
Authorization pManageAuthorization = registrar.getAuthorization(currentStudy.getOid());
String participateStatus = "";
String url = "";
try {
URL pManageUrl = new URL(portalURL);
if (pManageAuthorization != null && pManageAuthorization.getAuthorizationStatus() != null && pManageAuthorization.getAuthorizationStatus().getStatus() != null)
participateStatus = pManageAuthorization.getAuthorizationStatus().getStatus();
map.addAttribute("participateURL", pManageUrl);
map.addAttribute("participateOCStatus", participateOCStatus);
map.addAttribute("participateStatus", participateStatus);
if (pManageAuthorization != null && pManageAuthorization.getStudy() != null && pManageAuthorization.getStudy().getHost() != null && !pManageAuthorization.getStudy().getHost().equals("")) {
url = pManageUrl.getProtocol() + "://" + pManageAuthorization.getStudy().getHost() + "." + pManageUrl.getHost() + ((pManageUrl.getPort() > 0) ? ":" + String.valueOf(pManageUrl.getPort()) : "");
}
} catch (MalformedURLException e) {
logger.error(e.getMessage());
logger.error(ExceptionUtils.getStackTrace(e));
}
map.addAttribute("participateURLDisplay", url);
}
// Load Randomization information
String moduleManager = CoreResources.getField("moduleManager");
map.addAttribute("moduleManager", moduleManager);
if (moduleManager != null && !moduleManager.equals("")) {
String randomizationOCStatus = currentStudy.getStudyParameterConfig().getRandomization();
RandomizationRegistrar randomizationRegistrar = new RandomizationRegistrar();
SeRandomizationDTO randomization = null;
try {
randomization = randomizationRegistrar.getCachedRandomizationDTOObject(currentStudy.getOid(), true);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
String randomizationStatus = "";
URL randomizeUrl = null;
if (randomization != null && randomization.getStatus() != null) {
randomizationStatus = randomization.getStatus();
if (randomization.getUrl() != null) {
try {
randomizeUrl = new URL(randomization.getUrl());
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
map.addAttribute("randomizeURL", randomizeUrl);
map.addAttribute("randomizationOCStatus", randomizationOCStatus);
map.addAttribute("randomizationStatus", randomizationStatus);
}
// @pgawade 13-April-2011- #8877: Added the rule designer URL
if (null != coreResources) {
map.addAttribute("ruleDesignerURL", coreResources.getField("designer.url"));
map.addAttribute("contextPath", getContextPath(request));
logMe("before checking getHostPath url = " + request.getRequestURL());
// JN: for the eclinicalhosting the https is not showing up in the request path, going for a fix of taking
// the hostpath from sysurl
// map.addAttribute("hostPath", getHostPath(request));
map.addAttribute("hostPath", getHostPathFromSysUrl(coreResources.getField("sysURL.base"), request.getContextPath()));
map.addAttribute("path", "pages/studymodule");
}
// UserAccountBean userBean = (UserAccountBean) request.getSession().getAttribute("userBean");
request.setAttribute("userBean", userBean);
ArrayList statusMap = Status.toStudyUpdateMembersList();
// statusMap.add(Status.PENDING);
request.setAttribute("statusMap", statusMap);
if (currentStudy.getParentStudyId() > 0) {
StudyBean parentStudy = (StudyBean) studyDao.findByPK(currentStudy.getParentStudyId());
request.setAttribute("parentStudy", parentStudy);
}
ArrayList pageMessages = new ArrayList();
if (request.getSession().getAttribute("pageMessages") != null) {
pageMessages.addAll((ArrayList) request.getSession().getAttribute("pageMessages"));
request.setAttribute("pageMessages", pageMessages);
request.getSession().removeAttribute("pageMessages");
}
ArrayList regMessages = new ArrayList();
if (request.getSession().getAttribute(REG_MESSAGE) != null) {
regMessages.addAll((ArrayList) request.getSession().getAttribute(REG_MESSAGE));
request.setAttribute(REG_MESSAGE, regMessages);
request.getSession().removeAttribute(REG_MESSAGE);
}
return map;
}
Aggregations