Search in sources :

Example 76 with UserAccountDAO

use of org.akaza.openclinica.dao.login.UserAccountDAO in project OpenClinica by OpenClinica.

the class AccountController method isApiKeyExist.

public Boolean isApiKeyExist(String uuid) {
    UserAccountDAO udao = new UserAccountDAO(dataSource);
    UserAccountBean uBean = (UserAccountBean) udao.findByApiKey(uuid);
    if (uBean == null || !uBean.isActive()) {
        return false;
    } else {
        return true;
    }
}
Also used : UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO)

Example 77 with UserAccountDAO

use of org.akaza.openclinica.dao.login.UserAccountDAO in project OpenClinica by OpenClinica.

the class AccountController method updateUserAccount.

private void updateUserAccount(UserAccountBean userAccountBean) {
    UserAccountDAO udao = new UserAccountDAO(dataSource);
    udao.update(userAccountBean);
}
Also used : UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO)

Example 78 with UserAccountDAO

use of org.akaza.openclinica.dao.login.UserAccountDAO in project OpenClinica by OpenClinica.

the class AccountController method getAllParticipantPerStudy.

@RequestMapping(value = "/study/{studyOid}", method = RequestMethod.GET)
public ResponseEntity<ArrayList<UserDTO>> getAllParticipantPerStudy(@PathVariable("studyOid") String studyOid) throws Exception {
    ResourceBundleProvider.updateLocale(new Locale("en_US"));
    UserAccountDAO udao = new UserAccountDAO(dataSource);
    ArrayList<UserDTO> uDTOs = null;
    StudyBean parentStudy = getParentStudy(studyOid);
    String oid = parentStudy.getOid();
    if (isStudyDoesNotExist(oid))
        return new ResponseEntity<ArrayList<UserDTO>>(uDTOs, org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
    udao = new UserAccountDAO(dataSource);
    ArrayList<UserAccountBean> uBeans = (ArrayList<UserAccountBean>) udao.findAllParticipantsByStudyOid(oid);
    if (uBeans != null) {
        uDTOs = new ArrayList<>();
        for (UserAccountBean uBean : uBeans) {
            UserDTO uDTO = new UserDTO();
            String username = uBean.getName();
            String studySubjectOid = username.substring(username.indexOf(".") + 1);
            StudySubjectDAO ssdao = new StudySubjectDAO(dataSource);
            String studySubjectId = ssdao.findByOid(studySubjectOid).getLabel();
            uDTO.setfName(uBean.getFirstName());
            uDTO.setEmail(uBean.getEmail());
            uDTO.setMobile(uBean.getPhone());
            uDTO.setAccessCode(uBean.getAccessCode());
            uDTO.setUserName(uBean.getName());
            uDTO.setPassword(uBean.getPasswd());
            uDTO.setlName(uBean.getLastName());
            uDTO.setStudySubjectId(studySubjectId);
            uDTOs.add(uDTO);
        }
        return new ResponseEntity<ArrayList<UserDTO>>(uDTOs, org.springframework.http.HttpStatus.OK);
    } else {
        return new ResponseEntity<ArrayList<UserDTO>>(uDTOs, org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
    }
}
Also used : Locale(java.util.Locale) UserDTO(org.akaza.openclinica.bean.login.UserDTO) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) ResponseEntity(org.springframework.http.ResponseEntity) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 79 with UserAccountDAO

use of org.akaza.openclinica.dao.login.UserAccountDAO in project OpenClinica by OpenClinica.

the class AuditEventDAO method setStudyAndSubjectInfo.

public AuditEventBean setStudyAndSubjectInfo(AuditEventBean aeb) {
    if (aeb.getStudyId() > 0) {
        StudyDAO sdao = new StudyDAO(this.ds);
        StudyBean sbean = (StudyBean) sdao.findByPK(aeb.getStudyId());
        aeb.setStudyName(sbean.getName());
    }
    if (aeb.getSubjectId() > 0) {
        SubjectBean subbean = new SubjectBean();
        SubjectDAO subdao = new SubjectDAO(this.ds);
        subbean = (SubjectBean) subdao.findByPK(aeb.getSubjectId());
        aeb.setSubjectName(subbean.getName());
    }
    if (aeb.getUserId() > 0) {
        UserAccountBean updater = new UserAccountBean();
        UserAccountDAO uadao = new UserAccountDAO(this.ds);
        updater = (UserAccountBean) uadao.findByPK(aeb.getUserId());
        aeb.setUpdater(updater);
    }
    return aeb;
}
Also used : SubjectBean(org.akaza.openclinica.bean.submit.SubjectBean) SubjectDAO(org.akaza.openclinica.dao.submit.SubjectDAO) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO)

Example 80 with UserAccountDAO

use of org.akaza.openclinica.dao.login.UserAccountDAO in project OpenClinica by OpenClinica.

the class RandomizeService method getRandomizationCode.

// Rest Call to OCUI to get Randomization
public String getRandomizationCode(EventCRFBean eventCrfBean, List<StratificationFactorBean> stratificationFactorBeans, RuleSetBean ruleSet) throws JSONException {
    StudySubjectDAO ssdao = new StudySubjectDAO<>(ds);
    StudySubjectBean ssBean = (StudySubjectBean) ssdao.findByPK(eventCrfBean.getStudySubjectId());
    // study subject oid
    String identifier = ssBean.getOid();
    StudyDAO sdao = new StudyDAO<>(ds);
    StudyBean sBean = (StudyBean) sdao.findByPK(ssBean.getStudyId());
    // site or study oid
    String siteIdentifier = sBean.getOid();
    // site or study name
    String name = sBean.getName();
    UserAccountDAO udao = new UserAccountDAO(ds);
    int userId = 0;
    if (eventCrfBean.getUpdaterId() == 0) {
        userId = eventCrfBean.getOwnerId();
    } else {
        userId = eventCrfBean.getUpdaterId();
    }
    UserAccountBean uBean = (UserAccountBean) udao.findByPK(userId);
    String user = uBean.getName();
    // sBean should be parent study
    // put randomization object in cache
    StudyBean study = getParentStudy(sBean.getOid());
    SeRandomizationDTO randomization = null;
    try {
        randomization = getCachedRandomizationDTOObject(study.getOid(), false);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    String randomiseUrl = randomization.getUrl();
    String username = randomization.getUsername();
    String password = randomization.getPassword();
    String timezone = "America/New_York";
    // String randomiseUrl = "https://evaluation.sealedenvelope.com/redpill/seti2";
    // String username = "oc";
    // String password = "secret";
    HttpHeaders headers = createHeaders(username, password);
    headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
    // retrieve json object if Randomization exist ,otherwise return a null object
    JSONObject jsonRandObject = retrieveARandomisation(randomiseUrl, ssBean, headers);
    if (jsonRandObject != null) {
        return (String) jsonRandObject.get("code");
    } else {
        // if Site identifier exists ,then update otherwise create new Site identifier
        addOrUpdateASite(randomiseUrl, sBean, headers, timezone);
        // send for Randomization
        JSONObject jsonRandomisedObject = randomiseSubject(randomiseUrl, ssBean, sBean, headers, user, stratificationFactorBeans, eventCrfBean, ruleSet);
        if (jsonRandomisedObject != null)
            return (String) jsonRandomisedObject.get("code");
        else
            return "";
    }
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) JSONObject(org.springframework.security.oauth2.common.json.JSONObject) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) SeRandomizationDTO(org.akaza.openclinica.service.pmanage.SeRandomizationDTO) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) JSONException(org.springframework.security.oauth2.common.json.JSONException)

Aggregations

UserAccountDAO (org.akaza.openclinica.dao.login.UserAccountDAO)101 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)69 ArrayList (java.util.ArrayList)44 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)43 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)42 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)36 StudyUserRoleBean (org.akaza.openclinica.bean.login.StudyUserRoleBean)24 Date (java.util.Date)23 HashMap (java.util.HashMap)21 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)18 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)16 Locale (java.util.Locale)15 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)14 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)14 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)13 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)12 SubjectDAO (org.akaza.openclinica.dao.submit.SubjectDAO)12 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)11 DiscrepancyNoteBean (org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean)10 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)10