use of org.akaza.openclinica.dao.managestudy.StudyGroupDAO in project OpenClinica by OpenClinica.
the class RemoveSubjectGroupClassServlet method processRequest.
@Override
public void processRequest() throws Exception {
String action = request.getParameter("action");
FormProcessor fp = new FormProcessor(request);
int classId = fp.getInt("id");
if (classId == 0) {
addPageMessage(respage.getString("please_choose_a_subject_group_class_to_remove"));
forwardPage(Page.SUBJECT_GROUP_CLASS_LIST_SERVLET);
} else {
StudyGroupClassDAO sgcdao = new StudyGroupClassDAO(sm.getDataSource());
StudyGroupDAO sgdao = new StudyGroupDAO(sm.getDataSource());
SubjectGroupMapDAO sgmdao = new SubjectGroupMapDAO(sm.getDataSource());
if (action.equalsIgnoreCase("confirm")) {
StudyGroupClassBean sgcb = (StudyGroupClassBean) sgcdao.findByPK(classId);
if (sgcb.getStatus().equals(Status.DELETED)) {
addPageMessage(respage.getString("this_subject_group_class_has_been_deleted_already"));
forwardPage(Page.SUBJECT_GROUP_CLASS_LIST_SERVLET);
return;
}
ArrayList groups = sgdao.findAllByGroupClass(sgcb);
for (int i = 0; i < groups.size(); i++) {
StudyGroupBean sg = (StudyGroupBean) groups.get(i);
ArrayList subjectMaps = sgmdao.findAllByStudyGroupClassAndGroup(sgcb.getId(), sg.getId());
sg.setSubjectMaps(subjectMaps);
}
session.setAttribute("group", sgcb);
session.setAttribute("studyGroups", groups);
forwardPage(Page.REMOVE_SUBJECT_GROUP_CLASS);
} else if (action.equalsIgnoreCase("submit")) {
StudyGroupClassBean group = (StudyGroupClassBean) session.getAttribute("group");
group.setStatus(Status.DELETED);
group.setUpdater(ub);
sgcdao.update(group);
ArrayList subjectMaps = sgmdao.findAllByStudyGroupClassId(group.getId());
for (int i = 0; i < subjectMaps.size(); i++) {
SubjectGroupMapBean sgmb = (SubjectGroupMapBean) subjectMaps.get(i);
if (!sgmb.getStatus().equals(Status.DELETED)) {
sgmb.setStatus(Status.AUTO_DELETED);
sgmb.setUpdater(ub);
sgmdao.update(sgmb);
}
}
addPageMessage(respage.getString("this_subject_group_class_was_removed_succesfully"));
forwardPage(Page.SUBJECT_GROUP_CLASS_LIST_SERVLET);
} else {
addPageMessage(respage.getString("no_action_specified"));
forwardPage(Page.SUBJECT_GROUP_CLASS_LIST_SERVLET);
}
}
}
use of org.akaza.openclinica.dao.managestudy.StudyGroupDAO 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.StudyGroupDAO in project OpenClinica by OpenClinica.
the class CreateSubjectGroupClassServlet method submitGroup.
/**
* Saves study group information into database
*
* @throws OpenClinicaException
*/
private void submitGroup() throws OpenClinicaException, IOException {
StudyGroupClassBean group = (StudyGroupClassBean) session.getAttribute("group");
ArrayList studyGroups = (ArrayList) session.getAttribute("studyGroups");
StudyGroupClassDAO sgcdao = new StudyGroupClassDAO(sm.getDataSource());
group.setStudyId(currentStudy.getId());
group.setOwner(ub);
group.setStatus(Status.AVAILABLE);
group = (StudyGroupClassBean) sgcdao.create(group);
if (!group.isActive()) {
addPageMessage(respage.getString("the_subject_group_class_not_created_database"));
} else {
StudyGroupDAO sgdao = new StudyGroupDAO(sm.getDataSource());
for (int i = 0; i < studyGroups.size(); i++) {
StudyGroupBean sg = (StudyGroupBean) studyGroups.get(i);
sg.setStudyGroupClassId(group.getId());
sg.setOwner(ub);
sg.setStatus(Status.AVAILABLE);
sgdao.create(sg);
}
addPageMessage(respage.getString("the_subject_group_class_created_succesfully"));
}
ArrayList pageMessages = (ArrayList) request.getAttribute(PAGE_MESSAGE);
session.setAttribute("pageMessages", pageMessages);
response.sendRedirect(request.getContextPath() + Page.MANAGE_STUDY_MODULE.getFileName());
}
use of org.akaza.openclinica.dao.managestudy.StudyGroupDAO in project OpenClinica by OpenClinica.
the class CoreSecureController method getStudyGroupClassesByCurrentStudy.
public ArrayList getStudyGroupClassesByCurrentStudy(HttpServletRequest request) {
StudyDAO studyDAO = new StudyDAO(getDataSource());
StudyGroupClassDAO studyGroupClassDAO = new StudyGroupClassDAO(getDataSource());
StudyGroupDAO studyGroupDAO = new StudyGroupDAO(getDataSource());
StudyBean currentStudy = (StudyBean) request.getSession().getAttribute("study");
int parentStudyId = currentStudy.getParentStudyId();
ArrayList studyGroupClasses = new ArrayList();
if (parentStudyId > 0) {
StudyBean parentStudy = (StudyBean) studyDAO.findByPK(parentStudyId);
studyGroupClasses = studyGroupClassDAO.findAllActiveByStudy(parentStudy);
} else {
parentStudyId = currentStudy.getId();
studyGroupClasses = studyGroupClassDAO.findAllActiveByStudy(currentStudy);
}
for (int i = 0; i < studyGroupClasses.size(); i++) {
StudyGroupClassBean sgc = (StudyGroupClassBean) studyGroupClasses.get(i);
ArrayList groups = studyGroupDAO.findAllByGroupClass(sgc);
sgc.setStudyGroups(groups);
}
return studyGroupClasses;
}
use of org.akaza.openclinica.dao.managestudy.StudyGroupDAO in project OpenClinica by OpenClinica.
the class UpdateSubjectGroupClassServlet method submitGroup.
private void submitGroup() throws OpenClinicaException {
StudyGroupClassBean group = (StudyGroupClassBean) session.getAttribute("group");
ArrayList studyGroups = (ArrayList) session.getAttribute("studyGroups");
ArrayList newStudyGroups = (ArrayList) session.getAttribute("newStudyGroups");
StudyGroupClassDAO sgcdao = new StudyGroupClassDAO(sm.getDataSource());
group.setUpdater(ub);
group.setUpdatedDate(new Date());
group = (StudyGroupClassBean) sgcdao.update(group);
if (!group.isActive()) {
addPageMessage(respage.getString("the_subject_group_class_no_updated_database"));
} else {
StudyGroupDAO sgdao = new StudyGroupDAO(sm.getDataSource());
for (int i = 0; i < studyGroups.size(); i++) {
StudyGroupBean sg = (StudyGroupBean) studyGroups.get(i);
sg.setStudyGroupClassId(group.getId());
if (sg.getId() == 0) {
sg.setOwner(ub);
sg.setStatus(Status.AVAILABLE);
sgdao.create(sg);
} else {
sg.setUpdater(ub);
sg.setStatus(Status.AVAILABLE);
sgdao.update(sg);
}
}
addPageMessage(respage.getString("the_subject_group_class_updated_succesfully"));
}
forwardPage(Page.SUBJECT_GROUP_CLASS_LIST_SERVLET);
}
Aggregations