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;
}
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);
}
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);
}
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;
}
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;
}
Aggregations