Search in sources :

Example 11 with ParticipantPortalRegistrar

use of org.akaza.openclinica.service.pmanage.ParticipantPortalRegistrar in project OpenClinica by OpenClinica.

the class StudyModuleController method registerParticipate.

@RequestMapping(value = "/{study}/register", method = RequestMethod.POST)
public String registerParticipate(@PathVariable("study") String studyOid, HttpServletRequest request) throws Exception {
    studyDao = new StudyDAO(dataSource);
    StudyBean study = studyDao.findByOid(studyOid);
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(dataSource);
    StudyParameterValueBean spv = spvdao.findByHandleAndStudy(study.getId(), "participantPortal");
    ParticipantPortalRegistrar registrar = new ParticipantPortalRegistrar();
    Locale locale = LocaleResolver.getLocale(request);
    ResourceBundleProvider.updateLocale(locale);
    respage = ResourceBundleProvider.getPageMessagesBundle(locale);
    // Check if desired hostName is available. If so, send OCUI registration request
    String hostName = request.getParameter("hostName");
    if (hostName == null || hostName.equals("")) {
        addRegMessage(request, respage.getString("participate_hostname_invalid"));
        return "redirect:/pages/studymodule";
    }
    String status = "";
    String nameAvailability = registrar.getHostNameAvailability(hostName);
    if (nameAvailability.equals(ParticipantPortalRegistrar.UNAVAILABLE)) {
        addRegMessage(request, respage.getString("participate_hostname_not_available"));
        return "redirect:/pages/studymodule";
    } else if (nameAvailability.equals(ParticipantPortalRegistrar.UNKNOWN)) {
        addRegMessage(request, respage.getString("participate_not_available"));
        return "redirect:/pages/studymodule";
    } else if (nameAvailability.equals(ParticipantPortalRegistrar.INVALID)) {
        addRegMessage(request, respage.getString("participate_hostname_invalid"));
        return "redirect:/pages/studymodule";
    } else {
        // Returned status was 'available'. Proceed with registration.
        status = registrar.registerStudy(study.getOid(), hostName, study.getIdentifier());
    }
    // parameter.
    if (status.equals("")) {
        addRegMessage(request, respage.getString("participate_not_available"));
    } else {
        // Update OC Study configuration
        spv.setStudyId(study.getId());
        spv.setParameter("participantPortal");
        spv.setValue("enabled");
        if (spv.getId() > 0)
            spvdao.update(spv);
        else
            spvdao.create(spv);
        StudyBean currentStudy = (StudyBean) request.getSession().getAttribute("study");
        currentStudy.getStudyParameterConfig().setParticipantPortal("enabled");
    }
    return "redirect:/pages/studymodule";
}
Also used : Locale(java.util.Locale) ParticipantPortalRegistrar(org.akaza.openclinica.service.pmanage.ParticipantPortalRegistrar) StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 12 with ParticipantPortalRegistrar

use of org.akaza.openclinica.service.pmanage.ParticipantPortalRegistrar 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.addAttribute(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);
        map.addAttribute("participateURLFull", url + "/#/login");
    }
    // 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;
}
Also used : MalformedURLException(java.net.MalformedURLException) HashMap(java.util.HashMap) StudyGroupClassDAO(org.akaza.openclinica.dao.managestudy.StudyGroupClassDAO) ArrayList(java.util.ArrayList) StudyInfoPanel(org.akaza.openclinica.view.StudyInfoPanel) URL(java.net.URL) RuleDAO(org.akaza.openclinica.dao.rule.RuleDAO) Authorization(org.akaza.openclinica.service.pmanage.Authorization) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) SeRandomizationDTO(org.akaza.openclinica.service.pmanage.SeRandomizationDTO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) StudyModuleStatus(org.akaza.openclinica.domain.managestudy.StudyModuleStatus) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) ModelMap(org.springframework.ui.ModelMap) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) HttpSessionRequiredException(org.springframework.web.HttpSessionRequiredException) MalformedURLException(java.net.MalformedURLException) ParticipantPortalRegistrar(org.akaza.openclinica.service.pmanage.ParticipantPortalRegistrar) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) Collection(java.util.Collection) RandomizationRegistrar(org.akaza.openclinica.service.pmanage.RandomizationRegistrar) ModelMap(org.springframework.ui.ModelMap) Map(java.util.Map) HashMap(java.util.HashMap) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 13 with ParticipantPortalRegistrar

use of org.akaza.openclinica.service.pmanage.ParticipantPortalRegistrar in project OpenClinica by OpenClinica.

the class SystemController method getParticipateModule.

public HashMap<String, Object> getParticipateModule(StudyBean studyBean) {
    String portalURL = CoreResources.getField("portalURL");
    StudyParameterValueBean spvBean = getParticipateMod(studyBean, "participantPortal");
    String ocParticipateStatus = "";
    if (spvBean.isActive()) {
        // enabled , disabled
        ocParticipateStatus = spvBean.getValue().toString();
    }
    String ocuiParticipateStatus = "";
    ParticipantPortalRegistrar participantPortalRegistrar = new ParticipantPortalRegistrar();
    if (ocParticipateStatus.equals("enabled")) {
        try {
            ocuiParticipateStatus = participantPortalRegistrar.getRegistrationStatus(studyBean.getOid());
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    HashMap<String, String> mapMetadata = new HashMap<>();
    String url = "";
    URL pManageUrl = null;
    try {
        pManageUrl = new URL(portalURL);
    } catch (MalformedURLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    Authorization pManageAuthorization = participantPortalRegistrar.getAuthorization(studyBean.getOid());
    if (pManageAuthorization != null) {
        url = pManageUrl.getProtocol() + "://" + pManageAuthorization.getStudy().getHost() + "." + pManageUrl.getHost() + ((pManageUrl.getPort() > 0) ? ":" + String.valueOf(pManageUrl.getPort()) : "");
        mapMetadata.put("Participate Url", url);
    }
    HashMap<String, Object> mapParticipate = new HashMap<>();
    mapParticipate.put("enabled", ocParticipateStatus.equals("enabled") ? "True" : "False");
    mapParticipate.put("status", ocuiParticipateStatus.equals("") ? "INACTIVE" : ocuiParticipateStatus);
    mapParticipate.put("metadata", mapMetadata);
    HashMap<String, Object> mapModule = new HashMap<>();
    mapModule.put("Participate", mapParticipate);
    return mapModule;
}
Also used : Authorization(org.akaza.openclinica.service.pmanage.Authorization) MalformedURLException(java.net.MalformedURLException) ParticipantPortalRegistrar(org.akaza.openclinica.service.pmanage.ParticipantPortalRegistrar) StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) HashMap(java.util.HashMap) MessagingException(javax.mail.MessagingException) OpenClinicaSystemException(org.akaza.openclinica.exception.OpenClinicaSystemException) MailException(org.springframework.mail.MailException) SQLException(java.sql.SQLException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) URL(java.net.URL)

Example 14 with ParticipantPortalRegistrar

use of org.akaza.openclinica.service.pmanage.ParticipantPortalRegistrar in project OpenClinica by OpenClinica.

the class OdmStudySubjectController method mayProceed.

private boolean mayProceed(String studyOid, StudySubjectBean ssBean) throws Exception {
    boolean accessPermission = false;
    StudyBean study = getParentStudy(studyOid);
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(dataSource);
    StudyParameterValueBean pStatus = spvdao.findByHandleAndStudy(study.getId(), "participantPortal");
    participantPortalRegistrar = new ParticipantPortalRegistrar();
    // ACTIVE ,
    String pManageStatus = participantPortalRegistrar.getRegistrationStatus(studyOid).toString();
    // PENDING ,
    // INACTIVE
    // enabled , disabled
    String participateStatus = pStatus.getValue().toString();
    // available , pending , frozen , locked
    String studyStatus = study.getStatus().getName().toString();
    logger.info("pManageStatus: " + pManageStatus + "  participantStatus: " + participateStatus + "   studyStatus: " + studyStatus + "  studySubjectStatus: " + ssBean.getStatus().getName());
    System.out.println("pManageStatus: " + pManageStatus + "  participantStatus: " + participateStatus + "   studyStatus: " + studyStatus + "  studySubjectStatus: " + ssBean.getStatus().getName());
    if (participateStatus.equalsIgnoreCase("enabled") && studyStatus.equalsIgnoreCase("available") && pManageStatus.equalsIgnoreCase("ACTIVE") && ssBean.getStatus() == Status.AVAILABLE) {
        accessPermission = true;
    }
    return accessPermission;
}
Also used : ParticipantPortalRegistrar(org.akaza.openclinica.service.pmanage.ParticipantPortalRegistrar) StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO)

Example 15 with ParticipantPortalRegistrar

use of org.akaza.openclinica.service.pmanage.ParticipantPortalRegistrar in project OpenClinica by OpenClinica.

the class OdmController method mayProceed.

private boolean mayProceed(String studyOid) throws Exception {
    boolean accessPermission = false;
    StudyBean study = getParentStudy(studyOid);
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(dataSource);
    StudyParameterValueBean pStatus = spvdao.findByHandleAndStudy(study.getId(), "participantPortal");
    participantPortalRegistrar = new ParticipantPortalRegistrar();
    // ACTIVE ,
    String pManageStatus = participantPortalRegistrar.getRegistrationStatus(studyOid).toString();
    // PENDING ,
    // INACTIVE
    // enabled , disabled
    String participateStatus = pStatus.getValue().toString();
    // available , pending , frozen , locked
    String studyStatus = study.getStatus().getName().toString();
    System.out.println("pManageStatus: " + pManageStatus + "  participantStatus: " + participateStatus + "   studyStatus: " + studyStatus);
    logger.info("pManageStatus: " + pManageStatus + "  participantStatus: " + participateStatus + "   studyStatus: " + studyStatus);
    if (participateStatus.equalsIgnoreCase("enabled") && studyStatus.equalsIgnoreCase("available") && pManageStatus.equalsIgnoreCase("ACTIVE")) {
        accessPermission = true;
    }
    return accessPermission;
}
Also used : ParticipantPortalRegistrar(org.akaza.openclinica.service.pmanage.ParticipantPortalRegistrar) StudyParameterValueBean(org.akaza.openclinica.bean.service.StudyParameterValueBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO)

Aggregations

ParticipantPortalRegistrar (org.akaza.openclinica.service.pmanage.ParticipantPortalRegistrar)19 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)12 StudyParameterValueBean (org.akaza.openclinica.bean.service.StudyParameterValueBean)9 StudyParameterValueDAO (org.akaza.openclinica.dao.service.StudyParameterValueDAO)9 URL (java.net.URL)4 Authorization (org.akaza.openclinica.service.pmanage.Authorization)4 MalformedURLException (java.net.MalformedURLException)3 ArrayList (java.util.ArrayList)3 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)3 StudyParameterValue (org.akaza.openclinica.domain.datamap.StudyParameterValue)3 HashMap (java.util.HashMap)2 MessagingException (javax.mail.MessagingException)2 UserAccountDAO (org.akaza.openclinica.dao.login.UserAccountDAO)2 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)2 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)2 Study (org.akaza.openclinica.domain.datamap.Study)2 OpenClinicaSystemException (org.akaza.openclinica.exception.OpenClinicaSystemException)2 RandomizationRegistrar (org.akaza.openclinica.service.pmanage.RandomizationRegistrar)2 SeRandomizationDTO (org.akaza.openclinica.service.pmanage.SeRandomizationDTO)2 MailException (org.springframework.mail.MailException)2