use of org.akaza.openclinica.dao.managestudy.StudySubjectDAO in project OpenClinica by OpenClinica.
the class ListEventsForSubjectServlet method processRequest.
@Override
public void processRequest() throws Exception {
FormProcessor fp = new FormProcessor(request);
// checks which module the requests are from
String module = fp.getString(MODULE);
request.setAttribute(MODULE, module);
String pageNumber = fp.getString(ListStudySubjectServlet.SUBJECT_PAGE_NUMBER);
String filterKeyword = fp.getString(ListStudySubjectServlet.FILTER_KEYWORD);
String tmpSearch = fp.getString(ListStudySubjectServlet.SEARCH_SUBMITTED);
boolean searchSubmitted = !(tmpSearch == null || "".equalsIgnoreCase(tmpSearch)) && !"".equalsIgnoreCase(filterKeyword);
SubjectMatrixUtil matrixUtil = new SubjectMatrixUtil();
String query = matrixUtil.createPaginatingQuery(pageNumber);
StringBuilder extendedQuery = new StringBuilder(query);
// URL encode the search keyword, since it will be a parameter in the
// URL
String filterKeywordURLEncode = java.net.URLEncoder.encode(filterKeyword, "UTF-8");
if (searchSubmitted) {
extendedQuery.append("&ebl_sortColumnInd=0&submitted=1&ebl_sortAscending=1&ebl_filtered=1");
extendedQuery.append("&").append(ListStudySubjectServlet.FILTER_KEYWORD).append("=").append(filterKeywordURLEncode);
}
request.setAttribute(ListStudySubjectServlet.PAGINATING_QUERY, extendedQuery.toString());
int definitionId = fp.getInt("defId");
int tabId = fp.getInt("tab");
if (definitionId <= 0) {
addPageMessage(respage.getString("please_choose_an_ED_ta_to_vies_details"));
forwardPage(Page.LIST_STUDY_SUBJECTS);
return;
}
StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
StudyEventDefinitionBean sed = (StudyEventDefinitionBean) seddao.findByPK(definitionId);
StudySubjectDAO sdao = new StudySubjectDAO(sm.getDataSource());
StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
SubjectGroupMapDAO sgmdao = new SubjectGroupMapDAO(sm.getDataSource());
StudyGroupClassDAO sgcdao = new StudyGroupClassDAO(sm.getDataSource());
EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
CRFDAO crfdao = new CRFDAO(sm.getDataSource());
// find all the groups in the current study
ArrayList studyGroupClasses = sgcdao.findAllActiveByStudy(currentStudy);
// information for the event tabs
ArrayList allDefs = seddao.findAllActiveByStudy(currentStudy);
boolean isASite = false;
if (currentStudy.getParentStudyId() > 0) {
StudyDAO stdao = new StudyDAO(sm.getDataSource());
StudyBean parent = (StudyBean) stdao.findByPK(currentStudy.getParentStudyId());
allDefs = seddao.findAllActiveByStudy(parent);
}
ArrayList eventDefinitionCRFs = (ArrayList) edcdao.findAllActiveByEventDefinitionId(this.currentStudy, definitionId);
for (int i = 0; i < eventDefinitionCRFs.size(); i++) {
EventDefinitionCRFBean edc = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
CRFBean crf = (CRFBean) crfdao.findByPK(edc.getCrfId());
edc.setCrf(crf);
}
request.setAttribute("studyGroupClasses", studyGroupClasses);
request.setAttribute("allDefsArray", allDefs);
request.setAttribute("allDefsNumber", new Integer(allDefs.size()));
request.setAttribute("groupSize", new Integer(studyGroupClasses.size()));
request.setAttribute("eventDefCRFSize", new Integer(eventDefinitionCRFs.size()));
request.setAttribute("tabId", new Integer(tabId));
request.setAttribute("studyEventDef", sed);
request.setAttribute("eventDefCRFs", eventDefinitionCRFs);
// find all the subjects in current study
ArrayList subjects = sdao.findAllByStudyId(currentStudy.getId());
ArrayList displayStudySubs = new ArrayList();
for (int i = 0; i < subjects.size(); i++) {
StudySubjectBean studySub = (StudySubjectBean) subjects.get(i);
ArrayList groups = (ArrayList) sgmdao.findAllByStudySubject(studySub.getId());
ArrayList subGClasses = new ArrayList();
for (int j = 0; j < studyGroupClasses.size(); j++) {
StudyGroupClassBean sgc = (StudyGroupClassBean) studyGroupClasses.get(j);
boolean hasClass = false;
for (int k = 0; k < groups.size(); k++) {
SubjectGroupMapBean sgmb = (SubjectGroupMapBean) groups.get(k);
if (sgmb.getGroupClassName().equalsIgnoreCase(sgc.getName())) {
subGClasses.add(sgmb);
hasClass = true;
break;
}
}
if (!hasClass) {
subGClasses.add(new SubjectGroupMapBean());
}
}
// find all eventcrfs for each event, for each event tab
ArrayList displaySubjectEvents = new ArrayList();
ArrayList<DisplayStudyEventBean> displayEvents = new ArrayList<DisplayStudyEventBean>();
ArrayList events = sedao.findAllByStudySubjectAndDefinition(studySub, sed);
for (int k = 0; k < events.size(); k++) {
StudyEventBean seb = (StudyEventBean) events.get(k);
DisplayStudyEventBean dseb = ListStudySubjectServlet.getDisplayStudyEventsForStudySubject(studySub, seb, sm.getDataSource(), ub, currentRole, this.currentStudy);
// ArrayList eventCRFs = ecdao.findAllByStudyEvent(seb);
// ArrayList al =
// ViewStudySubjectServlet.getUncompletedCRFs(sm.getDataSource(),
// eventDefinitionCRFs, eventCRFs);
// dseb.getUncompletedCRFs().add(al);
displayEvents.add(dseb);
}
ArrayList al = new ArrayList();
for (int k = 0; k < displayEvents.size(); k++) {
DisplayStudyEventBean dseb = displayEvents.get(k);
ArrayList eventCRFs = dseb.getDisplayEventCRFs();
for (int a = 0; a < eventDefinitionCRFs.size(); a++) {
EventDefinitionCRFBean edc = (EventDefinitionCRFBean) eventDefinitionCRFs.get(a);
int crfId = edc.getCrfId();
boolean hasCRF = false;
for (int b = 0; b < eventCRFs.size(); b++) {
DisplayEventCRFBean decb = (DisplayEventCRFBean) eventCRFs.get(b);
// decb.getStage().getName() );
if (decb.getEventCRF().getCrf().getId() == crfId) {
dseb.getAllEventCRFs().add(decb);
// logger.info("hasCRf" + crfId +
// decb.getEventCRF().getCrf().getName());
hasCRF = true;
break;
}
}
if (hasCRF == false) {
DisplayEventCRFBean db = new DisplayEventCRFBean();
db.setEventDefinitionCRF(edc);
db.getEventDefinitionCRF().setCrf(edc.getCrf());
dseb.getAllEventCRFs().add(db);
// logger.info("noCRf" + crfId);
}
}
// Issue 3212 BWP <<
if (currentStudy.getParentStudyId() > 0) {
// check each eventDefCRFBean and set its isHidden property
// to true, if its
// persistent/database-derived hideCrf is true (domain rule:
// hide the CRF from users logged into a site)
HideCRFManager hideCRFManager = HideCRFManager.createHideCRFManager();
hideCRFManager.optionallyCheckHideCRFProperty(dseb);
// remove a DisplayEventCRFBean from a DisplayStudyEventBean
// in the list
// if it contains a hidden CRF in its event definition
hideCRFManager.removeHiddenEventCRF(dseb);
// generate a boolean request attribute indicating whether
// any of the CRFs
// should be hidden
boolean hideCRFs = hideCRFManager.studyEventHasAHideCRFProperty(dseb);
request.setAttribute("hideCRFs", hideCRFs);
}
// >>
}
DisplayStudySubjectBean dssb = new DisplayStudySubjectBean();
dssb.setStudySubject(studySub);
dssb.setStudyGroups(subGClasses);
dssb.setStudyEvents(displayEvents);
if (definitionId > 0) {
dssb.setSedId(definitionId);
} else {
dssb.setSedId(-1);
}
displayStudySubs.add(dssb);
}
EntityBeanTable table = fp.getEntityBeanTable();
ArrayList allStudyRows = DisplayStudySubjectEventsRow.generateRowsFromBeans(displayStudySubs);
ArrayList columnArray = new ArrayList();
columnArray.add(resword.getString("ID"));
columnArray.add(resword.getString("subject_status"));
columnArray.add(resword.getString("gender"));
for (int i = 0; i < studyGroupClasses.size(); i++) {
StudyGroupClassBean sgc = (StudyGroupClassBean) studyGroupClasses.get(i);
columnArray.add(sgc.getName());
}
// columnArray.add("Event Sequence");
columnArray.add(resword.getString("event_status"));
columnArray.add(resword.getString("event_date"));
// Issue 3212 BWP <<
HideCRFManager hideCRFMgr = HideCRFManager.createHideCRFManager();
hideCRFMgr.hideSpecifiedEventCRFDefBeans(eventDefinitionCRFs);
for (int i = 0; i < eventDefinitionCRFs.size(); i++) {
EventDefinitionCRFBean edc = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
// Issue 3212 BWP <<
if (!(currentStudy.getParentStudyId() > 0)) {
columnArray.add(edc.getCrf().getName());
} else {
if (!edc.isHideCrf()) {
columnArray.add(edc.getCrf().getName());
}
}
// >>
}
columnArray.add(resword.getString("actions"));
String[] columns = new String[columnArray.size()];
columnArray.toArray(columns);
table.setColumns(new ArrayList(Arrays.asList(columns)));
table.setQuery("ListEventsForSubject?module=" + module + "&defId=" + definitionId + "&tab=" + tabId, new HashMap());
table.hideColumnLink(columnArray.size() - 1);
// if(currentStudy.getStatus().isAvailable()){
// table.addLink(resword.getString("add_new_subject"), "AddNewSubject");
// }
table.setRows(allStudyRows);
if (filterKeyword != null && !"".equalsIgnoreCase(filterKeyword)) {
table.setKeywordFilter(filterKeyword);
}
table.computeDisplay();
request.setAttribute("table", table);
forwardPage(Page.LIST_EVENTS_FOR_SUBJECT);
}
use of org.akaza.openclinica.dao.managestudy.StudySubjectDAO in project OpenClinica by OpenClinica.
the class ListDiscNotesSubjectServlet method processRequest.
// < ResourceBundleresexception,respage;
@Override
protected void processRequest() throws Exception {
String module = request.getParameter("module");
String moduleStr = "manage";
if (module != null && module.trim().length() > 0) {
if ("submit".equals(module)) {
request.setAttribute("module", "submit");
moduleStr = "submit";
} else if ("admin".equals(module)) {
request.setAttribute("module", "admin");
moduleStr = "admin";
} else {
request.setAttribute("module", "manage");
}
}
// << tbh 02/2010 filter out the entire module parameter to catch injections
// BWP 3098>> close the info side panel and show icons
request.setAttribute("closeInfoShowIcons", true);
// <<
// Determine whether to limit the displayed DN's to a certain DN type
int resolutionStatus = 0;
try {
resolutionStatus = Integer.parseInt(request.getParameter("resolutionStatus"));
} catch (NumberFormatException nfe) {
// Show all DN's
resolutionStatus = -1;
}
// Determine whether we already have a collection of resolutionStatus
// Ids, and if not
// create a new attribute. If there is no resolution status, then the
// Set object should be cleared,
// because we do not have to save a set of filter IDs.
boolean hasAResolutionStatus = resolutionStatus >= 1 && resolutionStatus <= 5;
Set<Integer> resolutionStatusIds = (HashSet) session.getAttribute(RESOLUTION_STATUS);
// remove the session if there is no resolution status
if (!hasAResolutionStatus && resolutionStatusIds != null) {
session.removeAttribute(RESOLUTION_STATUS);
resolutionStatusIds = null;
}
if (hasAResolutionStatus) {
if (resolutionStatusIds == null) {
resolutionStatusIds = new HashSet<Integer>();
}
resolutionStatusIds.add(resolutionStatus);
session.setAttribute(RESOLUTION_STATUS, resolutionStatusIds);
}
int discNoteType = 0;
try {
discNoteType = Integer.parseInt(request.getParameter("type"));
} catch (NumberFormatException nfe) {
// Show all DN's
discNoteType = -1;
}
request.setAttribute(DISCREPANCY_NOTE_TYPE, discNoteType);
DiscrepancyNoteUtil discNoteUtil = new DiscrepancyNoteUtil();
// Generate a summary of how we are filtering;
Map<String, List<String>> filterSummary = discNoteUtil.generateFilterSummary(discNoteType, resolutionStatusIds);
if (!filterSummary.isEmpty()) {
request.setAttribute(FILTER_SUMMARY, filterSummary);
}
locale = LocaleResolver.getLocale(request);
StudyBean sbean = (StudyBean) session.getAttribute("study");
//List<DiscrepancyNoteBean> allDiscNotes = discNoteUtil.getThreadedDNotesForStudy(sbean, resolutionStatusIds, sm.getDataSource(), discNoteType, true);
//Map stats = discNoteUtil.generateDiscNoteSummary(allDiscNotes);
Map stats = discNoteUtil.generateDiscNoteSummaryRefactored(sm.getDataSource(), currentStudy, resolutionStatusIds, discNoteType);
request.setAttribute("summaryMap", stats);
Set mapKeys = stats.keySet();
request.setAttribute("mapKeys", mapKeys);
// < resword =
// ResourceBundle.getBundle("org.akaza.openclinica.i18n.words",locale);
StudyDAO studyDAO = new StudyDAO(sm.getDataSource());
StudySubjectDAO sdao = new StudySubjectDAO(sm.getDataSource());
StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
SubjectGroupMapDAO sgmdao = new SubjectGroupMapDAO(sm.getDataSource());
StudyGroupClassDAO sgcdao = new StudyGroupClassDAO(sm.getDataSource());
StudyGroupDAO sgdao = new StudyGroupDAO(sm.getDataSource());
StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
EventCRFDAO edao = new EventCRFDAO(sm.getDataSource());
EventDefinitionCRFDAO eddao = new EventDefinitionCRFDAO(sm.getDataSource());
SubjectDAO subdao = new SubjectDAO(sm.getDataSource());
DiscrepancyNoteDAO dnDAO = new DiscrepancyNoteDAO(sm.getDataSource());
ListDiscNotesSubjectTableFactory factory = new ListDiscNotesSubjectTableFactory(ResourceBundleProvider.getTermsBundle(locale));
factory.setStudyEventDefinitionDao(seddao);
factory.setSubjectDAO(subdao);
factory.setStudySubjectDAO(sdao);
factory.setStudyEventDAO(sedao);
factory.setStudyBean(currentStudy);
factory.setStudyGroupClassDAO(sgcdao);
factory.setSubjectGroupMapDAO(sgmdao);
factory.setStudyDAO(studyDAO);
factory.setCurrentRole(currentRole);
factory.setCurrentUser(ub);
factory.setEventCRFDAO(edao);
factory.setEventDefintionCRFDAO(eddao);
factory.setStudyGroupDAO(sgdao);
factory.setDiscrepancyNoteDAO(dnDAO);
factory.setModule(moduleStr);
factory.setDiscNoteType(discNoteType);
// factory.setStudyHasDiscNotes(allDiscNotes != null &&
// !allDiscNotes.isEmpty());
factory.setResolutionStatus(resolutionStatus);
factory.setResolutionStatusIds(resolutionStatusIds);
factory.setResword(ResourceBundleProvider.getWordsBundle(locale));
String listDiscNotesHtml = factory.createTable(request, response).render();
request.setAttribute("listDiscNotesHtml", listDiscNotesHtml);
forwardPage(getJSP());
}
use of org.akaza.openclinica.dao.managestudy.StudySubjectDAO in project OpenClinica by OpenClinica.
the class DeleteStudyEventServlet method processRequest.
@Override
public void processRequest() throws Exception {
FormProcessor fp = new FormProcessor(request);
// studyEventId
int studyEventId = fp.getInt("id");
// studySubjectId
int studySubId = fp.getInt("studySubId");
StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
StudySubjectDAO subdao = new StudySubjectDAO(sm.getDataSource());
if (studyEventId == 0) {
addPageMessage(respage.getString("please_choose_a_SE_to_remove"));
request.setAttribute("id", new Integer(studySubId).toString());
forwardPage(Page.VIEW_STUDY_SUBJECT_SERVLET);
} else {
StudyEventBean event = (StudyEventBean) sedao.findByPK(studyEventId);
StudySubjectBean studySub = (StudySubjectBean) subdao.findByPK(studySubId);
request.setAttribute("studySub", studySub);
StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
StudyEventDefinitionBean sed = (StudyEventDefinitionBean) seddao.findByPK(event.getStudyEventDefinitionId());
event.setStudyEventDefinition(sed);
StudyDAO studydao = new StudyDAO(sm.getDataSource());
StudyBean study = (StudyBean) studydao.findByPK(studySub.getStudyId());
request.setAttribute("study", study);
String action = request.getParameter("action");
if ("confirm".equalsIgnoreCase(action)) {
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
// find all crfs in the definition
ArrayList eventDefinitionCRFs = (ArrayList) edcdao.findAllByEventDefinitionId(study, sed.getId());
EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
// construct info needed on view study event page
DisplayStudyEventBean de = new DisplayStudyEventBean();
de.setStudyEvent(event);
request.setAttribute("displayEvent", de);
// request.setAttribute("crfs", eventDefinitionCRFs);
forwardPage(Page.DELETE_STUDY_EVENT);
} else {
logger.info("submit to delete the event from study");
// delete event from study
event.setSubjectEventStatus(SubjectEventStatus.NOT_SCHEDULED);
event.setUpdater(ub);
event.setUpdatedDate(new Date());
sedao.update(event);
String emailBody = respage.getString("the_event") + " " + event.getStudyEventDefinition().getName() + " " + respage.getString("has_been_removed_from_the_subject_record_for") + " " + studySub.getLabel() + " " + respage.getString("in_the_study") + " " + study.getName() + ".";
addPageMessage(emailBody);
// sendEmail(emailBody);
request.setAttribute("id", new Integer(studySubId).toString());
forwardPage(Page.VIEW_STUDY_SUBJECT_SERVLET);
}
}
}
use of org.akaza.openclinica.dao.managestudy.StudySubjectDAO in project OpenClinica by OpenClinica.
the class FindStudyEventServlet method processRequest.
/*
* (non-Javadoc)
*
* @see org.akaza.openclinica.control.core.SecureController#processRequest()
*/
@Override
protected void processRequest() throws Exception {
FormProcessor fp = new FormProcessor(request);
String browseBy = fp.getString(INPUT_BROWSEBY);
int id = fp.getInt(INPUT_ID);
// User is going to Step 1
if (browseBy.equals("")) {
forwardPage(Page.FIND_STUDY_EVENTS_STEP1);
} else if (invalidBrowseBy(browseBy)) {
addPageMessage(respage.getString("must_browse_study_events_by_subject_or_event_definition"));
forwardPage(Page.FIND_STUDY_EVENTS_STEP1);
} else // User was at Step 1, is going to Step 2
if (id <= 0) {
int pageNum = fp.getInt(INPUT_PAGENUM);
ArrayList allDisplayEntities = new ArrayList();
if (browseBy.equals(ARG_BROWSEBY_SUBJECT)) {
StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
allDisplayEntities = ssdao.findAllWithStudyEvent(currentStudy);
} else {
StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
allDisplayEntities = seddao.findAllWithStudyEvent(currentStudy);
}
if (pageNum < 0) {
pageNum = 0;
} else if (pageNum > allDisplayEntities.size() / NUM_ENTITIES_PER_PAGE) {
pageNum = allDisplayEntities.size() / NUM_ENTITIES_PER_PAGE;
}
int firstIndex = NUM_ENTITIES_PER_PAGE * pageNum;
int lastIndex = NUM_ENTITIES_PER_PAGE * (pageNum + 1);
if (allDisplayEntities.size() > lastIndex) {
request.setAttribute(BEAN_DISPLAY_NEXT_PAGE, ARG_DISPLAY_NEXT_PAGE_YES);
} else {
request.setAttribute(BEAN_DISPLAY_NEXT_PAGE, ARG_DISPLAY_NEXT_PAGE_NO);
lastIndex = allDisplayEntities.size();
}
List displayEntities = allDisplayEntities.subList(firstIndex, lastIndex);
request.setAttribute(INPUT_BROWSEBY, browseBy);
request.setAttribute(BEAN_DISPLAY_ENTITIES, displayEntities);
request.setAttribute(INPUT_PAGENUM, new Integer(pageNum));
forwardPage(Page.FIND_STUDY_EVENTS_STEP2);
} else // User is coming from Step 2, is going to Step 3
{
StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
ArrayList events = new ArrayList();
EntityBean entityWithStudyEvents;
if (browseBy.equals(ARG_BROWSEBY_SUBJECT)) {
events = sedao.findAllByStudyAndStudySubjectId(currentStudy, id);
StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
entityWithStudyEvents = ssdao.findByPK(id);
} else {
events = sedao.findAllByStudyAndEventDefinitionId(currentStudy, id);
StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
entityWithStudyEvents = seddao.findByPK(id);
}
request.setAttribute(INPUT_BROWSEBY, browseBy);
request.setAttribute(BEAN_DISPLAY_ENTITIES, events);
request.setAttribute(BEAN_ENTITY_WITH_STUDY_EVENTS, entityWithStudyEvents);
forwardPage(Page.FIND_STUDY_EVENTS_STEP3);
}
}
use of org.akaza.openclinica.dao.managestudy.StudySubjectDAO in project OpenClinica by OpenClinica.
the class ChangeCRFVersionController method changeCRFVersionAction.
@RequestMapping("/managestudy/changeCRFVersion")
public // @RequestMapping("/managestudy/changeCRFVersionAction")
ModelMap changeCRFVersionAction(HttpServletRequest request, HttpServletResponse response, @RequestParam("crfId") int crfId, @RequestParam("crfName") String crfName, @RequestParam("formLayoutId") int formLayoutId, @RequestParam("formLayoutName") String formLayoutName, @RequestParam("studySubjectLabel") String studySubjectLabel, @RequestParam("studySubjectId") int studySubjectId, @RequestParam("eventCRFId") int eventCRFId, @RequestParam("eventDefinitionCRFId") int eventDefinitionCRFId, @RequestParam(value = "newFormLayoutId", required = true) int newFormLayoutId) {
// to be removed for aquamarine
if (!mayProceed(request)) {
if (redirect(request, response, "/MainMenu?message=authentication_failed") == null)
return null;
}
ArrayList<String> pageMessages = initPageMessages(request);
setupResource(request);
// update event_crf_id table
try {
EventCRFDAO event_crf_dao = new EventCRFDAO(dataSource);
StudyEventDAO sedao = new StudyEventDAO(dataSource);
EventCRFBean ev_bean = (EventCRFBean) event_crf_dao.findByPK(eventCRFId);
StudyEventBean st_event_bean = (StudyEventBean) sedao.findByPK(ev_bean.getStudyEventId());
Connection con = dataSource.getConnection();
CoreResources.setSchema(con);
con.setAutoCommit(false);
event_crf_dao.updateFormLayoutID(eventCRFId, newFormLayoutId, getCurrentUser(request).getId(), con);
String status_before_update = null;
SubjectEventStatus eventStatus = null;
Status subjectStatus = null;
AuditDAO auditDao = new AuditDAO(dataSource);
// event signed, check if subject is signed as well
StudySubjectDAO studySubDao = new StudySubjectDAO(dataSource);
StudySubjectBean studySubBean = (StudySubjectBean) studySubDao.findByPK(st_event_bean.getStudySubjectId());
if (studySubBean.getStatus().isSigned()) {
status_before_update = auditDao.findLastStatus("study_subject", studySubBean.getId(), "8");
if (status_before_update != null && status_before_update.length() == 1) {
int subject_status = Integer.parseInt(status_before_update);
subjectStatus = Status.get(subject_status);
studySubBean.setStatus(subjectStatus);
}
studySubBean.setUpdater(getCurrentUser(request));
studySubDao.update(studySubBean, con);
}
st_event_bean.setUpdater(getCurrentUser(request));
st_event_bean.setUpdatedDate(new Date());
status_before_update = auditDao.findLastStatus("study_event", st_event_bean.getId(), "8");
if (status_before_update != null && status_before_update.length() == 1) {
int status = Integer.parseInt(status_before_update);
eventStatus = SubjectEventStatus.get(status);
st_event_bean.setSubjectEventStatus(eventStatus);
}
sedao.update(st_event_bean, con);
con.commit();
con.setAutoCommit(true);
con.close();
pageMessages.add(resword.getString("confirm_crf_version_ms"));
String msg = resword.getString("confirm_crf_version_ms");
redirect(request, response, "/ViewStudySubject?isFromCRFVersionChange=" + msg + "&id=" + studySubjectId);
} catch (Exception e) {
pageMessages.add(resword.getString("error_message_cannot_update_crf_version"));
}
return null;
}
Aggregations