Search in sources :

Example 96 with StudyBean

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

the class AccountController method mayProceed.

private boolean mayProceed(String studyOid) throws Exception {
    boolean accessPermission = false;
    StudyBean siteStudy = getStudy(studyOid);
    StudyBean study = getParentStudy(studyOid);
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(dataSource);
    StudyParameterValueBean pStatus = spvdao.findByHandleAndStudy(study.getId(), "participantPortal");
    participantPortalRegistrar = new ParticipantPortalRegistrar();
    // ACTIVE ,
    String pManageStatus = participantPortalRegistrar.getRegistrationStatus(study.getOid()).toString();
    // PENDING ,
    // INACTIVE
    // enabled , disabled
    String participateStatus = pStatus.getValue().toString();
    // available , pending , frozen , locked
    String studyStatus = study.getStatus().getName().toString();
    // available , pending , frozen , locked
    String siteStatus = siteStudy.getStatus().getName().toString();
    logger.info("pManageStatus: " + pManageStatus + "  participantStatus: " + participateStatus + "   studyStatus: " + studyStatus + "   siteStatus: " + siteStatus);
    if (participateStatus.equalsIgnoreCase("enabled") && studyStatus.equalsIgnoreCase("available") && siteStatus.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)

Example 97 with StudyBean

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

the class AccountController method getAccount2.

/**
 * @api {get} /pages/accounts/study/:studyOid/accesscode/:accessCode Retrieve a user account - participant
 * @apiName getAccount2
 * @apiPermission Module participate - enabled & admin
 * @apiVersion 3.8.0
 * @apiParam {String} studyOid Study Oid.
 * @apiParam {String} accessCode Participant Access code .
 * @apiGroup User Account
 * @apiDescription Retrieves the participant user account with the given accessCode and studyOid
 * @apiParamExample {json} Request-Example:
 *                  {
 *                  "studyOid": " S_BL101",
 *                  "accessCode": "yfzqpvDpiJftIZgNDphvxg=="
 *                  }
 * @apiSuccessExample {json} Success-Response:
 *                    HTTP/1.1 200 OK
 *                    {
 *                    "lName": "",
 *                    "mobile": "jLGQwxkuVpPBLJCtnLdrAw==",
 *                    "accessCode": "yfzqpvDpiJftIZgNDphvxg==",
 *                    "password": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
 *                    "email": "XzJadh3l3V7uUoPCggbSoIfoNW8IQU3qsvrtHfJH7J0=",
 *                    "userName": "S_BL101.SS_SUBA101",
 *                    "studySubjectId": null,
 *                    "fName": "07hQGfwT6LRXk0rLLYwkviwNdOEycnj4lOjrNMBdesk="
 *                    }
 */
@RequestMapping(value = "/study/{studyOid}/accesscode/{accessCode}", method = RequestMethod.GET)
public ResponseEntity<UserDTO> getAccount2(@PathVariable("studyOid") String studyOid, @PathVariable("accessCode") String accessCode) throws Exception {
    ResourceBundleProvider.updateLocale(new Locale("en_US"));
    uDTO = null;
    accessCode = URLDecoder.decode(accessCode, "UTF-8");
    StudyBean parentStudy = getParentStudy(studyOid);
    String oid = parentStudy.getOid();
    if (isStudyASiteLevelStudy(studyOid))
        return new ResponseEntity<UserDTO>(uDTO, org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
    if (!mayProceed(oid))
        return new ResponseEntity<UserDTO>(uDTO, org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
    if (isStudyDoesNotExist(oid))
        return new ResponseEntity<UserDTO>(uDTO, org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
    if (isAccessCodeIsNull(accessCode))
        return new ResponseEntity<UserDTO>(uDTO, org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
    UserAccountBean accessCodeAccountBean = getAccessCodeAccount(accessCode);
    if (!accessCodeAccountBean.isActive())
        return new ResponseEntity<UserDTO>(uDTO, org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
    // This code should've been in liquibase migration for better readability.
    if (accessCodeAccountBean.getApiKey() == null || accessCodeAccountBean.getApiKey().isEmpty()) {
        String apiKey = null;
        do {
            apiKey = getRandom32ChApiKey();
        } while (isApiKeyExist(apiKey));
        accessCodeAccountBean.setEnableApiKey(true);
        accessCodeAccountBean.setApiKey(apiKey);
        updateUserAccount(accessCodeAccountBean);
    }
    buildUserDTO(accessCodeAccountBean);
    // Client want to trade access_code for api_key, for later usage of our api.
    if (accessCodeAccountBean.isEnableApiKey()) {
        uDTO.setApiKey(accessCodeAccountBean.getApiKey());
    }
    return new ResponseEntity<UserDTO>(uDTO, org.springframework.http.HttpStatus.OK);
}
Also used : Locale(java.util.Locale) ResponseEntity(org.springframework.http.ResponseEntity) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) UserDTO(org.akaza.openclinica.bean.login.UserDTO) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 98 with StudyBean

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

the class BatchCRFMigrationController method run.

@Override
public void run() {
    dataSource = helperObject.getDataSource();
    cBean = helperObject.getcBean();
    reportLog = helperObject.getReportLog();
    stBean = helperObject.getStBean();
    resterms = helperObject.getResterms();
    userAccountBean = helperObject.getUserAccountBean();
    openClinicaMailSender = helperObject.getOpenClinicaMailSender();
    sessionFactory = helperObject.getSessionFactory();
    Session session = sessionFactory.openSession();
    Transaction tx = session.beginTransaction();
    helperObject.setSession(session);
    int i = 0;
    for (EventCRFBean eventCrfToMigrate : helperObject.getEventCrfListToMigrate()) {
        i++;
        executeMigrationAction(helperObject, eventCrfToMigrate);
        if (i % 50 == 0) {
            session.flush();
            session.clear();
        }
        StudySubjectBean ssBean = (StudySubjectBean) ssdao().findByPK(eventCrfToMigrate.getStudySubjectId());
        StudyBean sBean = (StudyBean) sdao().findByPK(ssBean.getStudyId());
        StudyEventBean seBean = (StudyEventBean) sedao().findByPK(eventCrfToMigrate.getStudyEventId());
        StudyEventDefinitionBean sedBean = (StudyEventDefinitionBean) seddao().findByPK(seBean.getStudyEventDefinitionId());
        reportLog.getLogs().add(cBean.getName() + "," + helperObject.getSourceCrfVersionBean().getName() + "," + helperObject.getTargetCrfVersionBean().getName() + "," + ssBean.getLabel() + "," + sBean.getName() + "," + sedBean.getName() + "," + seBean.getSampleOrdinal());
    }
    tx.commit();
    session.close();
    String fileName = new SimpleDateFormat("_yyyy-MM-dd-hhmmssSaa'.txt'").format(new Date());
    fileName = "logFile" + fileName;
    File file = createLogFile(fileName);
    PrintWriter writer = null;
    try {
        writer = openFile(file);
    } catch (FileNotFoundException | UnsupportedEncodingException e) {
        e.printStackTrace();
    } finally {
        writer.print(toStringTextFormat(reportLog, resterms, stBean, cBean));
        closeFile(writer);
    }
    String reportUrl = getReportUrl(fileName, helperObject.getUrlBase());
    String fullName = userAccountBean.getFirstName() + " " + userAccountBean.getLastName();
    StringBuilder body = new StringBuilder();
    body.append(resterms.getString("Dear") + " " + fullName + ",<br><br>" + resterms.getString("Batch_CRF_version_migration_has_finished_running") + "<br>" + resterms.getString("Study") + ": " + stBean.getName() + "<br>" + resterms.getString("CRF") + ": " + cBean.getName() + "<br><br>" + resterms.getString("A_summary_report_of_the_migration_is_available_here") + ":<br>" + reportUrl + "<br><br>" + resterms.getString("Thank_you_Your_OpenClinica_System"));
    logger.info(body.toString());
    openClinicaMailSender.sendEmail(userAccountBean.getEmail(), EmailEngine.getAdminEmail(), resterms.getString("Batch_Migration_Complete_For") + " " + stBean.getName(), body.toString(), true);
}
Also used : StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) Date(java.util.Date) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) Transaction(org.hibernate.Transaction) StudySubjectBean(org.akaza.openclinica.bean.managestudy.StudySubjectBean) SimpleDateFormat(java.text.SimpleDateFormat) File(java.io.File) Session(org.hibernate.Session) PrintWriter(java.io.PrintWriter)

Example 99 with StudyBean

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

the class DiscrepancyNoteController method getStudy.

private StudyBean getStudy(String oid) {
    sdao = new StudyDAO(dataSource);
    StudyBean studyBean = (StudyBean) sdao.findByOid(oid);
    return studyBean;
}
Also used : StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Example 100 with StudyBean

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

the class DiscrepancyNoteController method getStudy.

private StudyBean getStudy(Integer id) {
    sdao = new StudyDAO(dataSource);
    StudyBean studyBean = (StudyBean) sdao.findByPK(id);
    return studyBean;
}
Also used : StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Aggregations

StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)366 ArrayList (java.util.ArrayList)185 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)184 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)92 HashMap (java.util.HashMap)85 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)68 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)65 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)62 Date (java.util.Date)61 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)59 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)58 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)57 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)56 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)52 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)52 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)45 UserAccountDAO (org.akaza.openclinica.dao.login.UserAccountDAO)42 Locale (java.util.Locale)41 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)41 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)38