use of org.akaza.openclinica.dao.login.UserAccountDAO in project OpenClinica by OpenClinica.
the class XsltTransformJob method initDependencies.
/**
* Initializes the dependencies of this job with the components from the Spring application context.
*
* @param scheduler
*/
private void initDependencies(Scheduler scheduler) {
try {
ApplicationContext ctx = (ApplicationContext) scheduler.getContext().get("applicationContext");
DataSource dataSource = ctx.getBean(DataSource.class);
mailSender = ctx.getBean(OpenClinicaMailSender.class);
auditEventDAO = ctx.getBean(AuditEventDAO.class);
datasetDao = ctx.getBean(DatasetDAO.class);
userAccountDao = ctx.getBean(UserAccountDAO.class);
studyDao = new StudyDAO(dataSource);
archivedDatasetFileDao = ctx.getBean(ArchivedDatasetFileDAO.class);
generateFileService = ctx.getBean(GenerateExtractFileService.class);
odmFileCreation = ctx.getBean(OdmFileCreation.class);
} catch (SchedulerException e) {
throw new IllegalStateException("Could not load dependencies from scheduler context", e);
}
}
use of org.akaza.openclinica.dao.login.UserAccountDAO in project OpenClinica by OpenClinica.
the class DeleteUserServlet method processRequest.
@Override
protected void processRequest() throws Exception {
UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
FormProcessor fp = new FormProcessor(request);
int userId = fp.getInt(ARG_USERID);
int action = fp.getInt(ARG_ACTION);
UserAccountBean u = (UserAccountBean) udao.findByPK(userId);
String message;
if (!u.isActive()) {
message = respage.getString("the_specified_user_not_exits");
} else if (!EntityAction.contains(action)) {
message = respage.getString("the_specified_action_on_the_user_is_invalid");
} else if (!EntityAction.get(action).equals(EntityAction.DELETE) && !EntityAction.get(action).equals(EntityAction.RESTORE)) {
message = respage.getString("the_specified_action_is_not_allowed");
} else {
EntityAction desiredAction = EntityAction.get(action);
u.setUpdater(ub);
if (desiredAction.equals(EntityAction.DELETE)) {
udao.delete(u);
if (udao.isQuerySuccessful()) {
message = respage.getString("the_user_has_been_removed_successfully");
// YW 07-31-2007 << for feature that deletion doesn't need
// email the deleted user.
/*
* //YW 07-26-2007 << catch exception (eg. timeout) and
* inform users. try { sendDeleteEmail(u); } catch
* (Exception e) { message += " However, there has been an
* error sending the user an email regarding this
* deletion."; }
*/
// YW >>
} else {
message = respage.getString("the_user_could_not_be_deleted_due_database_error");
}
} else {
SecurityManager sm = (SecurityManager) SpringServletAccess.getApplicationContext(context).getBean("securityManager");
String password = sm.genPassword();
String passwordHash = sm.encrytPassword(password, getUserDetails());
if (!u.isLdapUser()) {
u.setPasswd(passwordHash);
u.setPasswdTimestamp(null);
}
udao.restore(u);
if (udao.isQuerySuccessful()) {
message = respage.getString("the_user_has_been_restored");
try {
if (!u.isLdapUser()) {
sendRestoreEmail(u, password);
}
} catch (Exception e) {
message += respage.getString("however_was_error_sending_user_email_regarding");
}
} else {
message = respage.getString("the_user_could_not_be_deleted_due_database_error");
}
}
}
addPageMessage(message);
forwardPage(Page.LIST_USER_ACCOUNTS_SERVLET);
}
use of org.akaza.openclinica.dao.login.UserAccountDAO in project OpenClinica by OpenClinica.
the class EditStudyUserRoleServlet method processRequest.
@Override
protected void processRequest() throws Exception {
UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
FormProcessor fp = new FormProcessor(request);
int studyId = fp.getInt(ARG_STUDY_ID);
String uName = fp.getString(ARG_USER_NAME);
StudyUserRoleBean studyUserRole = udao.findRoleByUserNameAndStudyId(uName, studyId);
StudyDAO sdao = new StudyDAO(sm.getDataSource());
StudyBean sb = (StudyBean) sdao.findByPK(studyUserRole.getStudyId());
if (sb != null) {
studyUserRole.setStudyName(sb.getName());
}
if (!studyUserRole.isActive()) {
String message = respage.getString("the_user_has_no_role_in_study");
addPageMessage(message);
forwardPage(Page.LIST_USER_ACCOUNTS_SERVLET);
} else {
Map roleMap = new LinkedHashMap();
for (Iterator it = getRoles().iterator(); it.hasNext(); ) {
Role role = (Role) it.next();
roleMap.put(role.getId(), role.getDescription());
}
roleMap = new LinkedHashMap();
ResourceBundle resterm = org.akaza.openclinica.i18n.util.ResourceBundleProvider.getTermsBundle();
StudyBean study = (StudyBean) sdao.findByPK(studyUserRole.getStudyId());
if (study.getParentStudyId() == 0) {
for (Iterator it = getRoles().iterator(); it.hasNext(); ) {
Role role = (Role) it.next();
switch(role.getId()) {
case 2:
roleMap.put(role.getId(), resterm.getString("Study_Coordinator").trim());
break;
case 3:
roleMap.put(role.getId(), resterm.getString("Study_Director").trim());
break;
case 4:
roleMap.put(role.getId(), resterm.getString("Investigator").trim());
break;
case 5:
roleMap.put(role.getId(), resterm.getString("Data_Entry_Person").trim());
break;
case 6:
roleMap.put(role.getId(), resterm.getString("Monitor").trim());
break;
default:
}
}
} else {
for (Iterator it = getRoles().iterator(); it.hasNext(); ) {
Role role = (Role) it.next();
switch(role.getId()) {
// break;
case 4:
roleMap.put(role.getId(), resterm.getString("site_investigator").trim());
break;
case 5:
roleMap.put(role.getId(), resterm.getString("site_Data_Entry_Person").trim());
break;
case 6:
roleMap.put(role.getId(), resterm.getString("site_monitor").trim());
break;
case 7:
roleMap.put(role.getId(), resterm.getString("site_Data_Entry_Person2").trim());
break;
default:
}
}
}
if (study.getParentStudyId() > 0) {
roleMap.remove(Role.COORDINATOR.getId());
roleMap.remove(Role.STUDYDIRECTOR.getId());
}
// send the user to the right place..
if (!fp.isSubmitted()) {
request.setAttribute("userName", uName);
request.setAttribute("studyUserRole", studyUserRole);
request.setAttribute("roles", roleMap);
request.setAttribute("chosenRoleId", new Integer(studyUserRole.getRole().getId()));
forwardPage(Page.EDIT_STUDY_USER_ROLE);
} else // process the form
{
Validator v = new Validator(request);
v.addValidation(INPUT_ROLE, Validator.IS_VALID_TERM, TermType.ROLE);
HashMap errors = v.validate();
if (errors.isEmpty()) {
int roleId = fp.getInt(INPUT_ROLE);
Role r = Role.get(roleId);
studyUserRole.setRoleName(r.getName());
studyUserRole.setUpdater(ub);
udao.updateStudyUserRole(studyUserRole, uName);
String message = respage.getString("the_user_in_study_has_been_updated");
addPageMessage(message);
forwardPage(Page.LIST_USER_ACCOUNTS_SERVLET);
} else {
String message = respage.getString("the_role_choosen_was_invalid_choose_another");
addPageMessage(message);
request.setAttribute("userName", uName);
request.setAttribute("studyUserRole", studyUserRole);
request.setAttribute("chosenRoleId", new Integer(fp.getInt(INPUT_ROLE)));
request.setAttribute("roles", roleMap);
forwardPage(Page.EDIT_STUDY_USER_ROLE);
}
}
}
}
use of org.akaza.openclinica.dao.login.UserAccountDAO in project OpenClinica by OpenClinica.
the class AdminSystemServlet method processRequest.
// < ResourceBundleresword,resexception;
/*
* (non-Javadoc)
*
* @see org.akaza.openclinica.control.core.SecureController#processRequest()
*/
@Override
protected void processRequest() throws Exception {
// find last 5 modifed studies
StudyDAO sdao = new StudyDAO(sm.getDataSource());
ArrayList studies = (ArrayList) sdao.findAllByLimit(true);
request.setAttribute("studies", studies);
ArrayList allStudies = (ArrayList) sdao.findAll();
request.setAttribute("allStudyNumber", new Integer(allStudies.size()));
UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
ArrayList users = (ArrayList) udao.findAllByLimit(true);
request.setAttribute("users", users);
ArrayList allUsers = (ArrayList) udao.findAll();
request.setAttribute("allUserNumber", new Integer(allUsers.size()));
SubjectDAO subdao = new SubjectDAO(sm.getDataSource());
ArrayList subjects = (ArrayList) subdao.findAllByLimit(true);
request.setAttribute("subjects", subjects);
ArrayList allSubjects = (ArrayList) subdao.findAll();
request.setAttribute("allSubjectNumber", new Integer(allSubjects.size()));
CRFDAO cdao = new CRFDAO(sm.getDataSource());
ArrayList crfs = (ArrayList) cdao.findAllByLimit(true);
request.setAttribute("crfs", crfs);
ArrayList allCrfs = (ArrayList) cdao.findAll();
request.setAttribute("allCrfNumber", new Integer(allCrfs.size()));
resetPanel();
panel.setOrderedData(true);
setToPanel(resword.getString("in_the_application"), "");
if (allSubjects.size() > 0) {
setToPanel(resword.getString("subjects"), new Integer(allSubjects.size()).toString());
}
if (allUsers.size() > 0) {
setToPanel(resword.getString("users"), new Integer(allUsers.size()).toString());
}
if (allStudies.size() > 0) {
setToPanel(resword.getString("studies"), new Integer(allStudies.size()).toString());
}
if (allCrfs.size() > 0) {
setToPanel(resword.getString("CRFs"), new Integer(allCrfs.size()).toString());
}
panel.setStudyInfoShown(false);
forwardPage(Page.ADMIN_SYSTEM);
}
use of org.akaza.openclinica.dao.login.UserAccountDAO in project OpenClinica by OpenClinica.
the class CreateJobImportServlet method setUpServlet.
/*
* Find all the form items and re-populate as necessary
*/
private void setUpServlet() throws Exception {
String directory = SQLInitServlet.getField("filePath") + DIR_PATH + File.separator;
logger.debug("found directory: " + directory);
// find all the form items and re-populate them if necessary
FormProcessor fp2 = new FormProcessor(request);
UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
StudyDAO sdao = new StudyDAO(sm.getDataSource());
// ArrayList studies = udao.findStudyByUser(ub.getName(), (ArrayList)
// sdao.findAll());
// request.setAttribute("studies", studies);
// tbh, replacing the above with another version, 06/2009
ArrayList<StudyBean> all = (ArrayList<StudyBean>) sdao.findAll();
ArrayList<StudyBean> finalList = new ArrayList<StudyBean>();
for (StudyBean sb : all) {
if (!(sb.getParentStudyId() > 0)) {
finalList.add(sb);
// System.out.println("found study name: " + sb.getName());
finalList.addAll(sdao.findAllByParent(sb.getId()));
}
}
// System.out.println("found list of studies: " + finalList.toString());
addEntityList("studies", finalList, respage.getString("a_user_cannot_be_created_no_study_as_active"), Page.ADMIN_SYSTEM);
// YW >>
// << tbh
request.setAttribute("filePath", directory);
// request.setAttribute("activeStudy", activeStudy);
request.setAttribute(JOB_NAME, fp2.getString(JOB_NAME));
request.setAttribute(JOB_DESC, fp2.getString(JOB_DESC));
request.setAttribute(EMAIL, fp2.getString(EMAIL));
request.setAttribute(HOURS, new Integer(fp2.getInt(HOURS)).toString());
request.setAttribute(MINUTES, new Integer(fp2.getInt(MINUTES)).toString());
}
Aggregations