use of org.akaza.openclinica.bean.admin.DisplayStudyBean in project OpenClinica by OpenClinica.
the class DisplayStudyRow method compareColumn.
/*
* (non-Javadoc)
*
* @see
* org.akaza.openclinica.core.EntityBeanRow#compareColumn(java.lang.Object,
* int)
*/
@Override
protected int compareColumn(Object row, int sortingColumn) {
if (!row.getClass().equals(DisplayStudyRow.class)) {
return 0;
}
DisplayStudyBean thisStudy = (DisplayStudyBean) bean;
DisplayStudyBean argStudy = (DisplayStudyBean) ((DisplayStudyRow) row).bean;
int answer = 0;
switch(sortingColumn) {
case COL_NAME:
answer = thisStudy.getParent().getName().toLowerCase().compareTo(argStudy.getParent().getName().toLowerCase());
break;
case COL_OID:
answer = thisStudy.getParent().getOid().toLowerCase().compareTo(argStudy.getParent().getOid().toLowerCase());
break;
case COL_UNIQUEIDENTIFIER:
answer = thisStudy.getParent().getIdentifier().toLowerCase().compareTo(argStudy.getParent().getIdentifier().toLowerCase());
break;
case COL_PRINCIPAL_INVESTIGATOR:
answer = thisStudy.getParent().getPrincipalInvestigator().toLowerCase().compareTo(argStudy.getParent().getPrincipalInvestigator().toLowerCase());
break;
case COL_FACILITY_NAME:
answer = thisStudy.getParent().getFacilityName().toLowerCase().compareTo(argStudy.getParent().getFacilityName().toLowerCase());
break;
case COL_DATE_CREATED:
answer = compareDate(thisStudy.getParent().getCreatedDate(), argStudy.getParent().getCreatedDate());
break;
case COL_STATUS:
answer = thisStudy.getParent().getStatus().compareTo(argStudy.getParent().getStatus());
break;
}
return answer;
}
use of org.akaza.openclinica.bean.admin.DisplayStudyBean in project OpenClinica by OpenClinica.
the class ReassignStudySubjectServlet method processRequest.
@Override
public void processRequest() throws Exception {
String action = request.getParameter("action");
StudyDAO sdao = new StudyDAO(sm.getDataSource());
StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
SubjectDAO subdao = new SubjectDAO(sm.getDataSource());
FormProcessor fp = new FormProcessor(request);
int studySubId = fp.getInt("id");
if (studySubId == 0) {
addPageMessage(respage.getString("please_choose_a_subject_to_reassign"));
forwardPage(Page.LIST_STUDY_SUBJECTS_SERVLET);
return;
} else {
StudySubjectBean studySub = (StudySubjectBean) ssdao.findByPK(studySubId);
int subjectId = studySub.getSubjectId();
request.setAttribute("studySub", studySub);
SubjectBean subject = (SubjectBean) subdao.findByPK(subjectId);
request.setAttribute("subject", subject);
SubjectGroupMapDAO sgmdao = new SubjectGroupMapDAO(sm.getDataSource());
ArrayList groupMaps = (ArrayList) sgmdao.findAllByStudySubject(studySubId);
if (StringUtil.isBlank(action)) {
ArrayList studies = null;
DisplayStudyBean displayStudy = new DisplayStudyBean();
StudyBean study = (StudyBean) sdao.findByPK(studySub.getStudyId());
if (study.getParentStudyId() > 0) {
// current in site
studies = (ArrayList) sdao.findAllByParent(study.getParentStudyId());
StudyBean parent = (StudyBean) sdao.findByPK(study.getParentStudyId());
displayStudy.setParent(parent);
// studies.add(parent);
displayStudy.setChildren(studies);
} else {
studies = (ArrayList) sdao.findAllByParent(study.getId());
displayStudy.setParent(study);
displayStudy.setChildren(studies);
// studies.add(study);
}
// request.setAttribute("studies", studies);
request.setAttribute("displayStudy", displayStudy);
forwardPage(Page.REASSIGN_STUDY_SUBJECT);
} else {
int studyId = fp.getInt("studyId");
if (studyId == 0) {
addPageMessage(respage.getString("please_choose_a_study_site_to_reassign_the_subject"));
forwardPage(Page.REASSIGN_STUDY_SUBJECT);
return;
}
StudyBean st = (StudyBean) sdao.findByPK(studyId);
if ("confirm".equalsIgnoreCase(action)) {
StudySubjectBean sub1 = (StudySubjectBean) ssdao.findAnotherBySameLabel(studySub.getLabel(), studyId, studySub.getId());
if (sub1.getId() > 0) {
addPageMessage(respage.getString("the_study_subject_ID_used_by_another_in_study_site"));
forwardPage(Page.REASSIGN_STUDY_SUBJECT);
return;
}
// YW << comment out this message
// if (groupMaps.size() > 0) {
// addPageMessage("Warning: This subject has Group data
// assoicated with current study,"
// + "the group data will be lost if it is reassigned to
// another study.");
// }
// YW >>
request.setAttribute("newStudy", st);
forwardPage(Page.REASSIGN_STUDY_SUBJECT_CONFIRM);
} else {
logger.info("submit to reassign the subject");
studySub.setUpdatedDate(new Date());
studySub.setUpdater(ub);
studySub.setStudyId(studyId);
ssdao.update(studySub);
for (int i = 0; i < groupMaps.size(); i++) {
SubjectGroupMapBean sgm = (SubjectGroupMapBean) groupMaps.get(i);
sgm.setUpdatedDate(new Date());
sgm.setUpdater(ub);
sgm.setStatus(Status.DELETED);
sgmdao.update(sgm);
}
MessageFormat mf = new MessageFormat("");
mf.applyPattern(respage.getString("subject_reassigned"));
Object[] arguments = { studySub.getLabel(), st.getName() };
addPageMessage(mf.format(arguments));
forwardPage(Page.LIST_STUDY_SUBJECTS_SERVLET);
}
}
}
}
use of org.akaza.openclinica.bean.admin.DisplayStudyBean in project OpenClinica by OpenClinica.
the class ListStudyServlet method processRequest.
/**
* Finds all the studies
*
*/
@Override
public void processRequest() throws Exception {
StudyDAO sdao = new StudyDAO(sm.getDataSource());
ArrayList studies = (ArrayList) sdao.findAll();
// find all parent studies
ArrayList parents = (ArrayList) sdao.findAllParents();
ArrayList displayStudies = new ArrayList();
for (int i = 0; i < parents.size(); i++) {
StudyBean parent = (StudyBean) parents.get(i);
ArrayList children = (ArrayList) sdao.findAllByParent(parent.getId());
DisplayStudyBean displayStudy = new DisplayStudyBean();
displayStudy.setParent(parent);
displayStudy.setChildren(children);
displayStudies.add(displayStudy);
}
FormProcessor fp = new FormProcessor(request);
EntityBeanTable table = fp.getEntityBeanTable();
ArrayList allStudyRows = DisplayStudyRow.generateRowsFromBeans(displayStudies);
String[] columns = { resword.getString("name"), resword.getString("unique_identifier"), resword.getString("OID"), resword.getString("principal_investigator"), resword.getString("facility_name"), resword.getString("date_created"), resword.getString("status"), resword.getString("actions") };
table.setColumns(new ArrayList(Arrays.asList(columns)));
table.hideColumnLink(2);
table.hideColumnLink(6);
table.setQuery("ListStudy", new HashMap());
table.addLink(resword.getString("create_a_new_study"), "CreateStudy");
table.setRows(allStudyRows);
table.computeDisplay();
request.setAttribute("table", table);
// request.setAttribute("studies", studies);
session.setAttribute("fromListSite", "no");
resetPanel();
panel.setStudyInfoShown(false);
panel.setOrderedData(true);
setToPanel(resword.getString("in_the_application"), "");
if (parents.size() > 0) {
setToPanel(resword.getString("studies"), new Integer(parents.size()).toString());
}
if (studies.size() > 0) {
setToPanel(resword.getString("sites"), new Integer(studies.size() - parents.size()).toString());
}
forwardPage(Page.STUDY_LIST);
}
Aggregations