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