Search in sources :

Example 41 with StudyBean

use of org.akaza.openclinica.bean.managestudy.StudyBean in project OpenClinica by OpenClinica.

the class RuleDaoTest method testFindByOid.

public void testFindByOid() {
    // RuleDao ruleDao = (RuleDao) getContext().getBean("ruleDao");
    RuleBean ruleBean = new RuleBean();
    ruleBean.setOid("RULE_1");
    StudyBean studyBean = new StudyBean();
    studyBean.setId(1);
    ruleBean.setStudy(studyBean);
    RuleBean persistentRuleBean = ruleDao.findByOid(ruleBean);
    assertNotNull("RuleSet is null", persistentRuleBean);
    assertEquals("The id of the retrieved RuleSet should be 1", new Integer(-1), persistentRuleBean.getId());
}
Also used : StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) RuleBean(org.akaza.openclinica.domain.rule.RuleBean)

Example 42 with StudyBean

use of org.akaza.openclinica.bean.managestudy.StudyBean in project OpenClinica by OpenClinica.

the class RuleSetServiceTest method getRuleSetsByCrfStudyAndStudyEventDefinition.

// @pgawade 08-NOV-2010 Commented out the test
// "testFilterRuleSetsByStudyEventOrdinal" temporarily. Krikor will look
// into this.
// public void testFilterRuleSetsByStudyEventOrdinal() {
// List<RuleSetBean> ruleSets = getRuleSets();
// StudyEventDAO studyEventDao = new StudyEventDAO(getDataSource());
// StudyEventBean studyEventBean = (StudyEventBean)
// studyEventDao.findByPK(1);
//
// RuleSetServiceInterface instance = (RuleSetServiceInterface)
// getContext().getBean("ruleSetService");
// List<RuleSetBean> ruleSets1 =
// instance.filterRuleSetsByStudyEventOrdinal(ruleSets, studyEventBean);
//
// assertEquals("Expressions Size inside this RuleSet should be 1", 1,
// ruleSets1.get(0).getExpressions().size());
// assertEquals("Expression Value should be SE_ED2REPEA[1].F_CONC_V20.IG_CONC_CONCOMITANTMEDICATIONS.I_CONC_CON_MED_NAME",
// "SE_ED2REPEA[1].F_CONC_V20.IG_CONC_CONCOMITANTMEDICATIONS.I_CONC_CON_MED_NAME",
// ruleSets1.get(0).getExpressions().get(0).getValue());
// }
//
// @pgawade 08-NOV-2010 Commented out the test
// "testFilterRuleSetsByStudyEventOrdinalWithALL" temporarily. Krikor will
// look into this.
// public void testFilterRuleSetsByStudyEventOrdinalWithALL() {
// List<RuleSetBean> ruleSets = getRuleSets();
// StudyEventDAO studyEventDao = new StudyEventDAO(getDataSource());
// StudyEventBean studyEventBean = (StudyEventBean)
// studyEventDao.findByPK(2);
//
// RuleSetServiceInterface instance = (RuleSetServiceInterface)
// getContext().getBean("ruleSetService");
// ruleSets.get(0).getTarget().setValue("SE_ED2REPEA[ALL].F_CONC_V20.IG_CONC_CONCOMITANTMEDICATIONS.I_CONC_CON_MED_NAME");
// List<RuleSetBean> ruleSets2 =
// instance.filterRuleSetsByStudyEventOrdinal(ruleSets, studyEventBean);
//
// assertEquals("Expressions Size inside this RuleSet should be 1", 1,
// ruleSets2.get(0).getExpressions().size());
// assertEquals("Expression Value should be SE_ED2REPEA[2].F_CONC_V20.IG_CONC_CONCOMITANTMEDICATIONS.I_CONC_CON_MED_NAME",
// "SE_ED2REPEA[2].F_CONC_V20.IG_CONC_CONCOMITANTMEDICATIONS.I_CONC_CON_MED_NAME",
// ruleSets2.get(0).getExpressions().get(0).getValue());
// }
private List<RuleSetBean> getRuleSetsByCrfStudyAndStudyEventDefinition() {
    StudyDAO studyDao = new StudyDAO(getDataSource());
    StudyBean study = (StudyBean) studyDao.findByPK(1);
    assertNotNull(study);
    StudyEventDefinitionDAO studyEventDefinitionDao = new StudyEventDefinitionDAO(getDataSource());
    StudyEventDefinitionBean studyEventDefinition = (StudyEventDefinitionBean) studyEventDefinitionDao.findByPK(2);
    assertNotNull(studyEventDefinition);
    CRFVersionDAO crfVersionDao = new CRFVersionDAO(getDataSource());
    CRFVersionBean crfVersion = (CRFVersionBean) crfVersionDao.findByPK(2);
    assertNotNull(crfVersion);
    RuleSetServiceInterface instance = (RuleSetServiceInterface) getContext().getBean("ruleSetService");
    List<RuleSetBean> ruleSets = instance.getRuleSetsByCrfStudyAndStudyEventDefinition(study, studyEventDefinition, crfVersion);
    return ruleSets;
}
Also used : CRFVersionDAO(org.akaza.openclinica.dao.submit.CRFVersionDAO) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) RuleSetBean(org.akaza.openclinica.domain.rule.RuleSetBean)

Example 43 with StudyBean

use of org.akaza.openclinica.bean.managestudy.StudyBean in project OpenClinica by OpenClinica.

the class SampleTest method testStatement.

public void testStatement() {
    StudyDAO studyDao = new StudyDAO(getDataSource());
    StudyBean study = (StudyBean) studyDao.findByPK(1);
    assertNotNull(study);
}
Also used : StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Example 44 with StudyBean

use of org.akaza.openclinica.bean.managestudy.StudyBean in project OpenClinica by OpenClinica.

the class EditStudyUserRoleServlet method processRequest.

@Override
protected void processRequest() throws Exception {
    UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
    FormProcessor fp = new FormProcessor(request);
    int studyId = fp.getInt(ARG_STUDY_ID);
    String uName = fp.getString(ARG_USER_NAME);
    StudyUserRoleBean studyUserRole = udao.findRoleByUserNameAndStudyId(uName, studyId);
    StudyDAO sdao = new StudyDAO(sm.getDataSource());
    StudyBean sb = (StudyBean) sdao.findByPK(studyUserRole.getStudyId());
    if (sb != null) {
        studyUserRole.setStudyName(sb.getName());
    }
    if (!studyUserRole.isActive()) {
        String message = respage.getString("the_user_has_no_role_in_study");
        addPageMessage(message);
        forwardPage(Page.LIST_USER_ACCOUNTS_SERVLET);
    } else {
        Map roleMap = new LinkedHashMap();
        for (Iterator it = getRoles().iterator(); it.hasNext(); ) {
            Role role = (Role) it.next();
            roleMap.put(role.getId(), role.getDescription());
        }
        roleMap = new LinkedHashMap();
        ResourceBundle resterm = org.akaza.openclinica.i18n.util.ResourceBundleProvider.getTermsBundle();
        StudyBean study = (StudyBean) sdao.findByPK(studyUserRole.getStudyId());
        if (study.getParentStudyId() == 0) {
            for (Iterator it = getRoles().iterator(); it.hasNext(); ) {
                Role role = (Role) it.next();
                switch(role.getId()) {
                    case 2:
                        roleMap.put(role.getId(), resterm.getString("Study_Coordinator").trim());
                        break;
                    case 3:
                        roleMap.put(role.getId(), resterm.getString("Study_Director").trim());
                        break;
                    case 4:
                        roleMap.put(role.getId(), resterm.getString("Investigator").trim());
                        break;
                    case 5:
                        roleMap.put(role.getId(), resterm.getString("Data_Entry_Person").trim());
                        break;
                    case 6:
                        roleMap.put(role.getId(), resterm.getString("Monitor").trim());
                        break;
                    default:
                }
            }
        } else {
            for (Iterator it = getRoles().iterator(); it.hasNext(); ) {
                Role role = (Role) it.next();
                switch(role.getId()) {
                    //                            break;
                    case 4:
                        roleMap.put(role.getId(), resterm.getString("site_investigator").trim());
                        break;
                    case 5:
                        roleMap.put(role.getId(), resterm.getString("site_Data_Entry_Person").trim());
                        break;
                    case 6:
                        roleMap.put(role.getId(), resterm.getString("site_monitor").trim());
                        break;
                    case 7:
                        roleMap.put(role.getId(), resterm.getString("site_Data_Entry_Person2").trim());
                        break;
                    default:
                }
            }
        }
        if (study.getParentStudyId() > 0) {
            roleMap.remove(Role.COORDINATOR.getId());
            roleMap.remove(Role.STUDYDIRECTOR.getId());
        }
        // send the user to the right place..
        if (!fp.isSubmitted()) {
            request.setAttribute("userName", uName);
            request.setAttribute("studyUserRole", studyUserRole);
            request.setAttribute("roles", roleMap);
            request.setAttribute("chosenRoleId", new Integer(studyUserRole.getRole().getId()));
            forwardPage(Page.EDIT_STUDY_USER_ROLE);
        } else // process the form
        {
            Validator v = new Validator(request);
            v.addValidation(INPUT_ROLE, Validator.IS_VALID_TERM, TermType.ROLE);
            HashMap errors = v.validate();
            if (errors.isEmpty()) {
                int roleId = fp.getInt(INPUT_ROLE);
                Role r = Role.get(roleId);
                studyUserRole.setRoleName(r.getName());
                studyUserRole.setUpdater(ub);
                udao.updateStudyUserRole(studyUserRole, uName);
                String message = respage.getString("the_user_in_study_has_been_updated");
                addPageMessage(message);
                forwardPage(Page.LIST_USER_ACCOUNTS_SERVLET);
            } else {
                String message = respage.getString("the_role_choosen_was_invalid_choose_another");
                addPageMessage(message);
                request.setAttribute("userName", uName);
                request.setAttribute("studyUserRole", studyUserRole);
                request.setAttribute("chosenRoleId", new Integer(fp.getInt(INPUT_ROLE)));
                request.setAttribute("roles", roleMap);
                forwardPage(Page.EDIT_STUDY_USER_ROLE);
            }
        }
    }
}
Also used : FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyUserRoleBean(org.akaza.openclinica.bean.login.StudyUserRoleBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) Role(org.akaza.openclinica.bean.core.Role) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) Validator(org.akaza.openclinica.control.form.Validator)

Example 45 with StudyBean

use of org.akaza.openclinica.bean.managestudy.StudyBean in project OpenClinica by OpenClinica.

the class BatchCRFMigrationServlet method processRequest.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void processRequest() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    ArrayList<CRFVersionBean> crfVersionList = null;
    ArrayList<FormLayoutBean> formLayoutList = null;
    ArrayList<StudyEventDefinitionBean> eventList = null;
    ArrayList<StudyBean> siteList = null;
    // 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);
    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 fldao = new FormLayoutDAO(sm.getDataSource());
        CRFBean crf = (CRFBean) cdao.findByPK(crfId);
        request.setAttribute("crfName", crf.getName());
        // ArrayList<CRFVersionBean> versions = (ArrayList<CRFVersionBean>) vdao.findAllByCRF(crfId);
        ArrayList<FormLayoutBean> formLayouts = (ArrayList<FormLayoutBean>) fldao.findAllByCRF(crfId);
        crfVersionList = new ArrayList<CRFVersionBean>();
        formLayoutList = new ArrayList<FormLayoutBean>();
        for (FormLayoutBean version : formLayouts) {
            if (version.getStatus().isAvailable())
                formLayoutList.add(version);
        }
        // for (CRFVersionBean version : versions) {
        // if (version.getStatus().isAvailable())
        // crfVersionList.add(version);
        // }
        // crf.setVersions(crfVersionList);
        crf.setFormLayouts(formLayoutList);
        ArrayList<StudyBean> listOfSites = (ArrayList<StudyBean>) sdao().findAllByParent(currentStudy.getId());
        siteList = new ArrayList<StudyBean>();
        StudyBean studyBean = new StudyBean();
        studyBean.setOid(currentStudy.getOid());
        studyBean.setName(resterm.getString("Study_Level_Subjects_Only"));
        siteList.add(studyBean);
        for (StudyBean s : listOfSites) {
            if (s.getStatus().isAvailable()) {
                siteList.add(s);
            }
        }
        ArrayList<StudyEventDefinitionBean> listOfDefn = seddao().findAllByStudy(currentStudy);
        eventList = new ArrayList<StudyEventDefinitionBean>();
        for (StudyEventDefinitionBean d : listOfDefn) {
            if (d.getStatus().isAvailable()) {
                eventList.add(d);
            }
        }
        // if coming from change crf version -> display message
        String crfVersionChangeMsg = fp.getString("isFromCRFVersionBatchChange");
        if (crfVersionChangeMsg != null && !crfVersionChangeMsg.equals("")) {
            addPageMessage(crfVersionChangeMsg);
        }
        request.setAttribute("study", currentStudy);
        request.setAttribute("siteList", siteList);
        request.setAttribute("eventList", eventList);
        request.setAttribute(CRF, crf);
        forwardPage(Page.BATCH_CRF_MIGRATION);
    }
}
Also used : CRFDAO(org.akaza.openclinica.dao.admin.CRFDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) FormLayoutBean(org.akaza.openclinica.bean.submit.FormLayoutBean) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) CRFBean(org.akaza.openclinica.bean.admin.CRFBean) FormLayoutDAO(org.akaza.openclinica.dao.submit.FormLayoutDAO) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean)

Aggregations

StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)350 ArrayList (java.util.ArrayList)183 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)175 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)92 HashMap (java.util.HashMap)84 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)66 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)65 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)62 Date (java.util.Date)59 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)58 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)57 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)56 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)54 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)52 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)52 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)45 Locale (java.util.Locale)39 UserAccountDAO (org.akaza.openclinica.dao.login.UserAccountDAO)39 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)37 Iterator (java.util.Iterator)36