use of org.akaza.openclinica.dao.managestudy.StudyDAO in project OpenClinica by OpenClinica.
the class ViewStudyUserServlet method processRequest.
@Override
public void processRequest() throws Exception {
UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
String name = request.getParameter("name");
String studyIdString = request.getParameter("studyId");
// if(request.getParameter("submit")!=null)
{
if (StringUtil.isBlank(name) || StringUtil.isBlank(studyIdString)) {
addPageMessage(respage.getString("please_choose_a_user_to_view"));
forwardPage(Page.LIST_USER_IN_STUDY_SERVLET);
} else {
int studyId = Integer.valueOf(studyIdString.trim()).intValue();
UserAccountBean user = (UserAccountBean) udao.findByUserName(name);
request.setAttribute("user", user);
StudyUserRoleBean uRole = udao.findRoleByUserNameAndStudyId(name, studyId);
request.setAttribute("uRole", uRole);
StudyDAO sdao = new StudyDAO(sm.getDataSource());
StudyBean study = (StudyBean) sdao.findByPK(studyId);
request.setAttribute("uStudy", study);
request.setAttribute("siteRoleMap", Role.siteRoleMap);
// BWP 12/7/07 >>To provide the view with the correct date format
// pattern, locale sensitive
String pattn = "";
pattn = ResourceBundleProvider.getFormatBundle().getString("date_format_string");
request.setAttribute("dateFormatPattern", pattn);
request.setAttribute("action", "");
forwardPage(Page.VIEW_USER_IN_STUDY);
}
}
}
use of org.akaza.openclinica.dao.managestudy.StudyDAO in project OpenClinica by OpenClinica.
the class UpdateStudyServletNew method processRequest.
@Override
public void processRequest() throws Exception {
resetPanel();
FormProcessor fp = new FormProcessor(request);
Validator v = new Validator(request);
int studyId = fp.getInt("id");
studyId = studyId == 0 ? fp.getInt("studyId") : studyId;
String action = fp.getString("action");
StudyDAO sdao = new StudyDAO(sm.getDataSource());
boolean isInterventional = false;
study = (StudyBean) sdao.findByPK(studyId);
if (study.getId() != currentStudy.getId()) {
addPageMessage(respage.getString("not_current_study") + respage.getString("change_study_contact_sysadmin"));
forwardPage(Page.MENU_SERVLET);
return;
}
study.setId(studyId);
StudyConfigService scs = new StudyConfigService(sm.getDataSource());
study = scs.setParametersForStudy(study);
request.setAttribute("studyToView", study);
request.setAttribute("studyId", studyId + "");
request.setAttribute("studyPhaseMap", CreateStudyServlet.studyPhaseMap);
ArrayList statuses = Status.toStudyUpdateMembersList();
statuses.add(Status.PENDING);
request.setAttribute("statuses", statuses);
String interventional = resadmin.getString("interventional");
isInterventional = interventional.equalsIgnoreCase(study.getProtocolType());
request.setAttribute("isInterventional", isInterventional ? "1" : "0");
String protocolType = study.getProtocolTypeKey();
// A. Hamid. 5001
if (study.getParentStudyId() > 0) {
StudyBean parentStudy = (StudyBean) sdao.findByPK(study.getParentStudyId());
request.setAttribute("parentStudy", parentStudy);
}
ArrayList interventionArray = new ArrayList();
if (isInterventional) {
interventionArray = parseInterventions(study);
setMaps(isInterventional, interventionArray);
} else {
setMaps(isInterventional, interventionArray);
}
if (!action.equals("submit")) {
// First Load First Form
if (study.getDatePlannedStart() != null) {
fp.addPresetValue(INPUT_START_DATE, local_df.format(study.getDatePlannedStart()));
}
if (study.getDatePlannedEnd() != null) {
fp.addPresetValue(INPUT_END_DATE, local_df.format(study.getDatePlannedEnd()));
}
if (study.getProtocolDateVerification() != null) {
fp.addPresetValue(INPUT_VER_DATE, local_df.format(study.getProtocolDateVerification()));
}
setPresetValues(fp.getPresetValues());
// first load 2nd form
}
if (study == null) {
addPageMessage(respage.getString("please_choose_a_study_to_edit"));
forwardPage(Page.STUDY_LIST_SERVLET);
return;
}
if (action.equals("submit")) {
validateStudy1(fp, v);
validateStudy2(fp, new Validator(request));
validateStudy3(isInterventional, new Validator(request), fp);
validateStudy4(fp, new Validator(request));
validateStudy5(fp, new Validator(request));
validateStudy6(fp, new Validator(request));
confirmWholeStudy(fp);
request.setAttribute("studyToView", study);
if (!errors.isEmpty()) {
logger.error("found errors : " + errors.toString());
request.setAttribute("formMessages", errors);
forwardPage(Page.UPDATE_STUDY_NEW);
} else {
study.setProtocolType(protocolType);
submitStudy(study);
addPageMessage(respage.getString("the_study_has_been_updated_succesfully"));
ArrayList pageMessages = (ArrayList) request.getAttribute(PAGE_MESSAGE);
session.setAttribute("pageMessages", pageMessages);
response.sendRedirect(request.getContextPath() + "/pages/studymodule");
// forwardPage(Page.MANAGE_STUDY_MODULE);
}
} else {
forwardPage(Page.UPDATE_STUDY_NEW);
}
}
use of org.akaza.openclinica.dao.managestudy.StudyDAO in project OpenClinica by OpenClinica.
the class UpdateSubStudyServlet method submitStudy.
/**
* Inserts the new study into databa *
* @throws MalformedURLException *
*/
private void submitStudy() throws MalformedURLException {
StudyDAO sdao = new StudyDAO(sm.getDataSource());
StudyBean study = (StudyBean) session.getAttribute("newStudy");
ArrayList parameters = study.getStudyParameters();
/*
* logger.info("study bean to be updated:\n");
* logger.info(study.getName()+ "\n" + study.getCreatedDate() + "\n" +
* study.getIdentifier() + "\n" + study.getParentStudyId()+ "\n" +
* study.getSummary()+ "\n" + study.getPrincipalInvestigator()+ "\n" +
* study.getDatePlannedStart()+ "\n" + study.getDatePlannedEnd()+ "\n" +
* study.getFacilityName()+ "\n" + study.getFacilityCity()+ "\n" +
* study.getFacilityState()+ "\n" + study.getFacilityZip()+ "\n" +
* study.getFacilityCountry()+ "\n" +
* study.getFacilityRecruitmentStatus()+ "\n" +
* study.getFacilityContactName()+ "\n" +
* study.getFacilityContactEmail()+ "\n" +
* study.getFacilityContactPhone()+ "\n" +
* study.getFacilityContactDegree());
*/
// study.setCreatedDate(new Date());
study.setUpdatedDate(new Date());
study.setUpdater(ub);
sdao.update(study);
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
for (int i = 0; i < parameters.size(); i++) {
StudyParamsConfig config = (StudyParamsConfig) parameters.get(i);
StudyParameterValueBean spv = config.getValue();
StudyParameterValueBean spv1 = spvdao.findByHandleAndStudy(spv.getStudyId(), spv.getParameter());
if (spv1.getId() > 0) {
spv = (StudyParameterValueBean) spvdao.update(spv);
} else {
spv = (StudyParameterValueBean) spvdao.create(spv);
}
// spv = (StudyParameterValueBean)spvdao.update(config.getValue());
}
submitSiteEventDefinitions(study);
// session.removeAttribute("newStudy");
// session.removeAttribute("parentName");
// session.removeAttribute("definitions");
// session.removeAttribute("sdvOptions");
addPageMessage(respage.getString("the_site_has_been_updated_succesfully"));
String fromListSite = (String) session.getAttribute("fromListSite");
if (fromListSite != null && fromListSite.equals("yes")) {
// session.removeAttribute("fromListSite");
forwardPage(Page.SITE_LIST_SERVLET);
} else {
// session.removeAttribute("fromListSite");
forwardPage(Page.STUDY_LIST_SERVLET);
}
}
use of org.akaza.openclinica.dao.managestudy.StudyDAO in project OpenClinica by OpenClinica.
the class ViewSectionDataEntryByIdServlet method processRequest.
/*
* (non-Javadoc)
* @see org.akaza.openclinica.control.managestudy.ViewSectionDataEntryServlet#processRequest()
*/
@Override
public void processRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
StudyDAO studyDao = new StudyDAO(getDataSource());
StudyBean currentStudy = (StudyBean) studyDao.findByPK(1);
CRFVersionDAO crfVersionDao = new CRFVersionDAO(getDataSource());
if (request.getParameter("id") == null) {
forwardPage(Page.LOGIN, request, response);
}
request.setAttribute("study", currentStudy);
CRFVersionBean crfVersion = crfVersionDao.findByOid(request.getParameter("id"));
if (crfVersion != null) {
request.setAttribute("crfVersionId", String.valueOf(crfVersion.getId()));
request.setAttribute("crfId", String.valueOf(crfVersion.getCrfId()));
super.processRequest(request, response);
} else {
forwardPage(Page.LOGIN, request, response);
}
}
use of org.akaza.openclinica.dao.managestudy.StudyDAO in project OpenClinica by OpenClinica.
the class CreateDiscrepancyNoteServlet method generateUserAccounts.
private ArrayList generateUserAccounts(int studyId, int subjectId) {
UserAccountDAO userAccountDAO = new UserAccountDAO(sm.getDataSource());
StudyDAO studyDAO = new StudyDAO(sm.getDataSource());
StudyBean subjectStudy = studyDAO.findByStudySubjectId(subjectId);
// study id, tbh 03/2009
ArrayList userAccounts = new ArrayList();
if (currentStudy.getParentStudyId() > 0) {
userAccounts = userAccountDAO.findAllUsersByStudyOrSite(studyId, currentStudy.getParentStudyId(), subjectId);
} else if (subjectStudy.getParentStudyId() > 0) {
userAccounts = userAccountDAO.findAllUsersByStudyOrSite(subjectStudy.getId(), subjectStudy.getParentStudyId(), subjectId);
} else {
userAccounts = userAccountDAO.findAllUsersByStudyOrSite(studyId, 0, subjectId);
}
return userAccounts;
}
Aggregations