Search in sources :

Example 91 with UserAccountDAO

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

the class SystemController method getSystemStatus.

@RequestMapping(value = "/systemstatus", method = RequestMethod.POST)
public ResponseEntity<HashMap> getSystemStatus() throws Exception {
    ResourceBundleProvider.updateLocale(new Locale("en_US"));
    HashMap<String, String> map = new HashMap<>();
    map.put("OpenClinica Version", CoreResources.getField("OpenClinica.version"));
    map.put("Java Version", System.getProperty("java.version"));
    map.put("Java Class Path", System.getProperty("java.class.path"));
    map.put("Java Home", System.getProperty("java.home"));
    map.put("OS Name", System.getProperty("os.name"));
    map.put("OS Version", System.getProperty("os.version"));
    map.put("OS Architecture", System.getProperty("os.arch"));
    map.put("File Separator", System.getProperty("file.separator"));
    map.put("Path Separator", System.getProperty("path.separator"));
    map.put("Line Separator", System.getProperty("line.separator"));
    map.put("User Home", System.getProperty("user.home"));
    map.put("User Directory", System.getProperty("user.dir"));
    map.put("User Name", System.getProperty("user.name"));
    Map<String, String> env = System.getenv();
    for (String envName : env.keySet()) {
        System.out.format("%s=%s%n", envName, env.get(envName));
    }
    DatabaseMetaData metaData = dataSource.getConnection().getMetaData();
    try {
        UserAccountDAO udao = new UserAccountDAO(dataSource);
        UserAccountBean uBean = (UserAccountBean) udao.findByPK(1);
        if (uBean.getFirstName().equals("Root") && uBean.getLastName().equals("User")) {
            map.put("Root User Account First And Last Name", uBean.getFirstName() + " " + uBean.getLastName());
            map.put("Database Connection", "PASS");
        } else {
            map.put("Database Connection", "FAIL");
        }
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return new ResponseEntity<HashMap>(map, org.springframework.http.HttpStatus.OK);
}
Also used : Locale(java.util.Locale) ResponseEntity(org.springframework.http.ResponseEntity) HashMap(java.util.HashMap) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) DatabaseMetaData(java.sql.DatabaseMetaData) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) 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) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 92 with UserAccountDAO

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

the class UserAccountController method getUserAccountByStudy.

private ArrayList<UserAccountBean> getUserAccountByStudy(String userName, ArrayList allStudies) {
    udao = new UserAccountDAO(dataSource);
    ArrayList<UserAccountBean> userAccountBeans = udao.findStudyByUser(userName, allStudies);
    return userAccountBeans;
}
Also used : UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO)

Example 93 with UserAccountDAO

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

the class UserAccountController method getUserAccountByApiKey.

private UserAccountBean getUserAccountByApiKey(String apiKey) {
    udao = new UserAccountDAO(dataSource);
    UserAccountBean userAccountBean = (UserAccountBean) udao.findByApiKey(apiKey);
    return userAccountBean;
}
Also used : UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO)

Example 94 with UserAccountDAO

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

the class UserAccountController method createUserAccount.

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

Example 95 with UserAccountDAO

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

the class UserInfoController method getCrcAccountBySession.

/**
 * @api {get} /pages/userinfo/study/:studyOid/crc Retrieve a user account - crc
 * @apiName getCrcAccountBySession
 * @apiPermission Module participate - enabled & admin
 * @apiVersion 3.12.2
 * @apiGroup User Account
 * @apiDescription Retrieves the crc user account associated with the current session.
 * @apiParamExample {json} Request-Example:
 *                  {
 *                  "studyOid": " S_BL101",
 *                  }
 * @apiSuccessExample {json} Success-Response:
 *                    HTTP/1.1 200 OK
 *                    {
 *                    "lName": "Jackson",
 *                    "mobile": "",
 *                    "accessCode": "",
 *                    "apiKey": "6e8b69f6fb774e899f9a6c349c5adace",
 *                    "password": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
 *                    "email": "abc@yahoo.com",
 *                    "userName": "crc_user",
 *                    "studySubjectId": null,
 *                    "fName": "joe"
 *                    }
 */
@RequestMapping(value = "/study/{studyOid}/crc", method = RequestMethod.GET)
public ResponseEntity<UserDTO> getCrcAccountBySession(@PathVariable("studyOid") String studyOid) throws Exception {
    ResourceBundleProvider.updateLocale(new Locale("en_US"));
    sdao = new StudyDAO(dataSource);
    udao = new UserAccountDAO(dataSource);
    boolean isRequestValid = true;
    uDTO = null;
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    Object principle = null;
    if (auth != null)
        principle = auth.getPrincipal();
    StudyBean currentStudy = sdao.findByOid(studyOid);
    UserAccountBean userAccount = (UserAccountBean) udao.findByUserName(((UserDetails) principle).getUsername());
    StudyBean parentStudy = getParentStudy(currentStudy.getOid());
    Integer pStudyId = parentStudy.getId();
    String oid = parentStudy.getOid();
    if (isStudyASiteLevelStudy(currentStudy.getOid()))
        isRequestValid = false;
    else if (!mayProceed(oid))
        isRequestValid = false;
    else if (isStudyDoesNotExist(oid))
        isRequestValid = false;
    else if (isCRCUserAccountDoesNotExist(userAccount.getName()))
        isRequestValid = false;
    else if (doesCRCNotHaveStudyAccessRole(userAccount.getName(), pStudyId))
        isRequestValid = false;
    if (isRequestValid) {
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_JSON);
        buildUserDTO(userAccount);
        return new ResponseEntity<UserDTO>(uDTO, headers, org.springframework.http.HttpStatus.OK);
    } else {
        return new ResponseEntity<UserDTO>(uDTO, org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
    }
}
Also used : Locale(java.util.Locale) HttpHeaders(org.springframework.http.HttpHeaders) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) ResponseEntity(org.springframework.http.ResponseEntity) UserDetails(org.springframework.security.core.userdetails.UserDetails) Authentication(org.springframework.security.core.Authentication) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

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