use of org.akaza.openclinica.dao.service.StudyParameterValueDAO in project OpenClinica by OpenClinica.
the class StudyModuleController method registerRandimization.
@RequestMapping(value = "/{study}/randomize", method = RequestMethod.POST)
public String registerRandimization(@PathVariable("study") String studyOid, HttpServletRequest request) throws Exception {
studyDao = new StudyDAO(dataSource);
StudyBean study = studyDao.findByOid(studyOid);
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(dataSource);
StudyParameterValueBean spv = spvdao.findByHandleAndStudy(study.getId(), "randomization");
RandomizationRegistrar randomizationRegistrar = new RandomizationRegistrar();
Locale locale = LocaleResolver.getLocale(request);
ResourceBundleProvider.updateLocale(locale);
respage = ResourceBundleProvider.getPageMessagesBundle(locale);
String status = "";
UserAccountBean userBean = (UserAccountBean) request.getSession().getAttribute("userBean");
// Update OC Study configuration
// send another email to sales@openclinica.com thru MandrillViaOcUi
status = randomizationRegistrar.randomizeStudy(study.getOid(), study.getIdentifier(), userBean);
if (status.equals("")) {
// addRegMessage(request, respage.getString("randomization_not_available"));
} else {
// Update OC Study configuration
randomizationRegistrar.sendEmail(mailSender, userBean, respage.getString("randomization_email_subject_sent_to_user"), respage.getString("randomization_email_content_message_sent_to_user"));
spv.setStudyId(study.getId());
spv.setParameter("randomization");
spv.setValue("enabled");
if (spv.getId() > 0)
spvdao.update(spv);
else
spvdao.create(spv);
StudyBean currentStudy = (StudyBean) request.getSession().getAttribute("study");
currentStudy.getStudyParameterConfig().setRandomization("enabled");
}
return "redirect:/pages/studymodule";
}
use of org.akaza.openclinica.dao.service.StudyParameterValueDAO in project OpenClinica by OpenClinica.
the class StudyModuleController method deactivateParticipate.
@RequestMapping(value = "/{study}/deactivate", method = RequestMethod.GET)
public String deactivateParticipate(@PathVariable("study") String studyOid, HttpServletRequest request) throws Exception {
studyDao = new StudyDAO(dataSource);
StudyBean study = studyDao.findByOid(studyOid);
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(dataSource);
StudyParameterValueBean spv = spvdao.findByHandleAndStudy(study.getId(), "participantPortal");
spv.setStudyId(study.getId());
spv.setParameter("participantPortal");
spv.setValue("disabled");
if (spv.getId() > 0)
spvdao.update(spv);
else
spvdao.create(spv);
StudyBean currentStudy = (StudyBean) request.getSession().getAttribute("study");
currentStudy.getStudyParameterConfig().setParticipantPortal("disabled");
return "redirect:/pages/studymodule";
}
use of org.akaza.openclinica.dao.service.StudyParameterValueDAO in project OpenClinica by OpenClinica.
the class SystemController method getParticipateMod.
public StudyParameterValueBean getParticipateMod(StudyBean studyBean, String value) {
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(dataSource);
StudyParameterValueBean pStatus = spvdao.findByHandleAndStudy(studyBean.getId(), value);
return pStatus;
}
use of org.akaza.openclinica.dao.service.StudyParameterValueDAO in project OpenClinica by OpenClinica.
the class MetadataCollectorResource method populateStudyBean.
private StudyBean populateStudyBean(StudyBean studyBean) {
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(this.dataSource);
@SuppressWarnings("rawtypes") ArrayList studyParameters = spvdao.findParamConfigByStudy(studyBean);
studyBean.setStudyParameters(studyParameters);
StudyConfigService scs = new StudyConfigService(this.dataSource);
if (studyBean.getParentStudyId() <= 0) {
// top study
studyBean = scs.setParametersForStudy(studyBean);
} else {
// YW <<
studyBean.setParentStudyName(((StudyBean) getStudyDao().findByPK(studyBean.getParentStudyId())).getName());
// YW >>
studyBean = scs.setParametersForSite(studyBean);
}
return studyBean;
}
use of org.akaza.openclinica.dao.service.StudyParameterValueDAO in project OpenClinica by OpenClinica.
the class MainMenuServlet method processRequest.
@Override
public void processRequest() throws Exception {
FormProcessor fp = new FormProcessor(request);
ub.incNumVisitsToMainMenu();
session.setAttribute(USER_BEAN_NAME, ub);
request.setAttribute("iconInfoShown", true);
request.setAttribute("closeInfoShowIcons", false);
if (ub == null || ub.getId() == 0) {
// in case database connection is
// broken
forwardPage(Page.MENU, false);
return;
}
StudyDAO sdao = new StudyDAO(sm.getDataSource());
ArrayList studies = null;
long pwdExpireDay = new Long(SQLInitServlet.getField("passwd_expiration_time")).longValue();
Date lastPwdChangeDate = ub.getPasswdTimestamp();
// a flag tells whether users are required to change pwd upon the first
// time log in or pwd expired
int pwdChangeRequired = new Integer(SQLInitServlet.getField("change_passwd_required")).intValue();
// update last visit date to current date
UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
UserAccountBean ub1 = (UserAccountBean) udao.findByPK(ub.getId());
ub1.setLastVisitDate(new Date(System.currentTimeMillis()));
// have to actually set the above to a timestamp? tbh
ub1.setOwner(ub1);
ub1.setUpdater(ub1);
udao.update(ub1);
// Use study Id in JSPs
request.setAttribute("studyId", currentStudy.getId());
// Event Definition list and Group Class list for add suybject window.
request.setAttribute("allDefsArray", super.getEventDefinitionsByCurrentStudy());
request.setAttribute("studyGroupClasses", super.getStudyGroupClassesByCurrentStudy());
if (ub.isLdapUser()) {
// "Forge" a password change date for LDAP user
lastPwdChangeDate = new Date();
}
System.out.println("is ub a ldapuser??" + ub.isLdapUser());
//@pgawade 18-Sep-2012: fix for issue #14506 (https://issuetracker.openclinica.com/view.php?id=14506#c58197)
if ((lastPwdChangeDate != null) || ((lastPwdChangeDate == null) && (pwdChangeRequired == 0))) {
// not a new user
if (lastPwdChangeDate != null) {
Calendar cal = Calendar.getInstance();
// compute difference between current date and lastPwdChangeDate
long difference = Math.abs(cal.getTime().getTime() - lastPwdChangeDate.getTime());
long days = difference / (1000 * 60 * 60 * 24);
session.setAttribute("passwordExpired", "no");
if (!ub.isLdapUser() && pwdExpireDay > 0 && days >= pwdExpireDay) {
// password expired, need to be changed
System.out.println("here");
studies = (ArrayList) sdao.findAllByUser(ub.getName());
request.setAttribute("studies", studies);
session.setAttribute("userBean1", ub);
addPageMessage(respage.getString("password_expired"));
// YW 06-25-2007 << add the feature that if password is expired,
// have to go through /ResetPassword page
session.setAttribute("passwordExpired", "yes");
if (pwdChangeRequired == 1) {
request.setAttribute("mustChangePass", "yes");
addPageMessage(respage.getString("your_password_has_expired_must_change"));
} else {
request.setAttribute("mustChangePass", "no");
addPageMessage(respage.getString("password_expired") + " " + respage.getString("if_you_do_not_want_change_leave_blank"));
}
forwardPage(Page.RESET_PASSWORD);
// YW >>
}
}
if (ub.getNumVisitsToMainMenu() <= 1) {
if (ub.getLastVisitDate() != null) {
addPageMessage(respage.getString("welcome") + " " + ub.getFirstName() + " " + ub.getLastName() + ". " + respage.getString("last_logged") + " " + local_df.format(ub.getLastVisitDate()) + ". ");
} else {
addPageMessage(respage.getString("welcome") + " " + ub.getFirstName() + " " + ub.getLastName() + ". ");
}
if (currentStudy.getStatus().isLocked()) {
addPageMessage(respage.getString("current_study_locked"));
} else if (currentStudy.getStatus().isFrozen()) {
addPageMessage(respage.getString("current_study_frozen"));
}
}
////Integer assignedDiscrepancies = getDiscrepancyNoteDAO().countAllItemDataByStudyAndUser(currentStudy, ub);
//Integer assignedDiscrepancies = getDiscrepancyNoteDAO().getViewNotesCountWithFilter(" AND dn.assigned_user_id ="
// + ub.getId() + " AND (dn.resolution_status_id=1 OR dn.resolution_status_id=2 OR dn.resolution_status_id=3)", currentStudy);
//Yufang code added by Jamuna, to optimize the query on MainMenu
Integer assignedDiscrepancies = getDiscrepancyNoteDAO().getViewNotesCountWithFilter(ub.getId(), currentStudy.getId());
request.setAttribute("assignedDiscrepancies", assignedDiscrepancies == null ? 0 : assignedDiscrepancies);
int parentStudyId = currentStudy.getParentStudyId() > 0 ? currentStudy.getParentStudyId() : currentStudy.getId();
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
StudyParameterValueBean parentSPV = spvdao.findByHandleAndStudy(parentStudyId, "subjectIdGeneration");
currentStudy.getStudyParameterConfig().setSubjectIdGeneration(parentSPV.getValue());
String idSetting = parentSPV.getValue();
if (idSetting.equals("auto editable") || idSetting.equals("auto non-editable")) {
//Shaoyu Su
//int nextLabel = this.getStudySubjectDAO().findTheGreatestLabel() + 1;
//request.setAttribute("label", new Integer(nextLabel).toString());
request.setAttribute("label", resword.getString("id_generated_Save_Add"));
//@pgawade 27-June-2012 fix for issue 13477: set label to "ID will be generated on Save or Add" in case of auto generated subject id
fp.addPresetValue("label", resword.getString("id_generated_Save_Add"));
}
setPresetValues(fp.getPresetValues());
if (currentRole.isInvestigator() || currentRole.isResearchAssistant() || currentRole.isResearchAssistant2()) {
setupListStudySubjectTable();
}
if (currentRole.isMonitor()) {
setupSubjectSDVTable();
} else if (currentRole.isCoordinator() || currentRole.isDirector()) {
if (currentStudy.getStatus().isPending()) {
response.sendRedirect(request.getContextPath() + Page.MANAGE_STUDY_MODULE.getFileName());
return;
}
setupStudySiteStatisticsTable();
setupSubjectEventStatusStatisticsTable();
setupStudySubjectStatusStatisticsTable();
if (currentStudy.getParentStudyId() == 0) {
setupStudyStatisticsTable();
}
}
forwardPage(Page.MENU);
// }
} else {
// a new user's first log in
studies = (ArrayList) sdao.findAllByUser(ub.getName());
request.setAttribute("studies", studies);
session.setAttribute("userBean1", ub);
if (pwdChangeRequired == 1) {
} else {
forwardPage(Page.MENU);
}
}
}
Aggregations