use of org.jmesa.facade.TableFacade in project OpenClinica by OpenClinica.
the class ViewCRFServlet method renderStudiesTable.
/*
* Create a JMesa-based table for showing the studies associated with a CRF.
*/
private String renderStudiesTable(List<StudyBean> studyBeans) {
Collection<StudyRowContainer> items = getStudyRows(studyBeans);
TableFacade tableFacade = createTableFacade("studies", request);
tableFacade.setColumnProperties("name", "uniqueProtocolid", "actions");
tableFacade.setItems(items);
// Fix column titles
HtmlTable table = (HtmlTable) tableFacade.getTable();
// i18n caption; TODO: convert to Spring messages
/*
* ResourceBundle resourceBundle = ResourceBundle.getBundle("org.akaza.openclinica.i18n.words",
* LocaleResolver.getLocale(request));
* String captionText = resourceBundle.getString("studies_using_crf");
* if (captionText == null || "".equalsIgnoreCase(captionText)) {
* captionText = "Studies Using this CRF for Data Entry";
* }
* table.setCaption(captionText);
*/
HtmlRow row = table.getRow();
SDVUtil sDVUtil = new SDVUtil();
String[] colNames = new String[] { "name", "uniqueProtocolid", "actions" };
sDVUtil.setHtmlCellEditors(tableFacade, colNames, true);
HtmlColumn firstName = row.getColumn("name");
firstName.setTitle("Study Name");
HtmlColumn protocol = row.getColumn("uniqueProtocolid");
protocol.setTitle("Unique Protocol Id");
HtmlColumn actions = row.getColumn("actions");
actions.setTitle("Actions");
return tableFacade.render();
}
use of org.jmesa.facade.TableFacade in project OpenClinica by OpenClinica.
the class ViewNotesServlet method processRequest.
/*
* (non-Javadoc)
*
* @see org.akaza.openclinica.control.core.SecureController#processRequest()
*/
@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");
}
}
FormProcessor fp = new FormProcessor(request);
if (fp.getString("showMoreLink").equals("")) {
showMoreLink = true;
} else {
showMoreLink = Boolean.parseBoolean(fp.getString("showMoreLink"));
}
int oneSubjectId = fp.getInt("id");
// BWP 11/03/2008 3029: This session attribute in removed in
// ResolveDiscrepancyServlet.mayProceed() >>
session.setAttribute("subjectId", oneSubjectId);
// >>
int resolutionStatusSubj = fp.getInt(RESOLUTION_STATUS);
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);
boolean removeSession = fp.getBoolean("removeSession");
// BWP 11/03/2008 3029: This session attribute in removed in
// ResolveDiscrepancyServlet.mayProceed() >>
session.setAttribute("module", module);
// >>
// Do we only want to view the notes for 1 subject?
String viewForOne = fp.getString("viewForOne");
boolean isForOneSubjectsNotes = "y".equalsIgnoreCase(viewForOne);
DiscrepancyNoteDAO dndao = new DiscrepancyNoteDAO(sm.getDataSource());
StudyDAO studyDAO = new StudyDAO(sm.getDataSource());
dndao.setFetchMapping(true);
int resolutionStatus = 0;
try {
resolutionStatus = Integer.parseInt(request.getParameter("resolutionStatus"));
} catch (NumberFormatException nfe) {
// Show all DN's
resolutionStatus = -1;
}
if (removeSession) {
session.removeAttribute(WIN_LOCATION);
session.removeAttribute(NOTES_TABLE);
}
// after resolving a note, user wants to go back to view notes page, we
// save the current URL
// so we can go back later
session.setAttribute(WIN_LOCATION, "ViewNotes?viewForOne=" + viewForOne + "&id=" + oneSubjectId + "&module=" + module + " &removeSession=1");
boolean hasAResolutionStatus = resolutionStatus >= 1 && resolutionStatus <= 6;
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);
}
StudySubjectDAO subdao = new StudySubjectDAO(sm.getDataSource());
StudyDAO studyDao = new StudyDAO(sm.getDataSource());
SubjectDAO sdao = new SubjectDAO(sm.getDataSource());
UserAccountDAO uadao = new UserAccountDAO(sm.getDataSource());
CRFVersionDAO crfVersionDao = new CRFVersionDAO(sm.getDataSource());
CRFDAO crfDao = new CRFDAO(sm.getDataSource());
StudyEventDAO studyEventDao = new StudyEventDAO(sm.getDataSource());
StudyEventDefinitionDAO studyEventDefinitionDao = new StudyEventDefinitionDAO(sm.getDataSource());
EventDefinitionCRFDAO eventDefinitionCRFDao = new EventDefinitionCRFDAO(sm.getDataSource());
ItemDataDAO itemDataDao = new ItemDataDAO(sm.getDataSource());
ItemDAO itemDao = new ItemDAO(sm.getDataSource());
EventCRFDAO eventCRFDao = new EventCRFDAO(sm.getDataSource());
ListNotesTableFactory factory = new ListNotesTableFactory(showMoreLink);
factory.setSubjectDao(sdao);
factory.setStudySubjectDao(subdao);
factory.setUserAccountDao(uadao);
factory.setStudyDao(studyDao);
factory.setCurrentStudy(currentStudy);
factory.setDiscrepancyNoteDao(dndao);
factory.setCrfDao(crfDao);
factory.setCrfVersionDao(crfVersionDao);
factory.setStudyEventDao(studyEventDao);
factory.setStudyEventDefinitionDao(studyEventDefinitionDao);
factory.setEventDefinitionCRFDao(eventDefinitionCRFDao);
factory.setItemDao(itemDao);
factory.setItemDataDao(itemDataDao);
factory.setEventCRFDao(eventCRFDao);
factory.setModule(moduleStr);
factory.setDiscNoteType(discNoteType);
factory.setResolutionStatus(resolutionStatus);
factory.setViewNotesService(resolveViewNotesService());
// factory.setResolutionStatusIds(resolutionStatusIds);
TableFacade tf = factory.createTable(request, response);
Map<String, Map<String, String>> stats = generateDiscrepancyNotesSummary(factory.getNotesSummary());
Map<String, String> totalMap = generateDiscrepancyNotesTotal(stats);
int grandTotal = 0;
for (String typeName : totalMap.keySet()) {
String total = totalMap.get(typeName);
grandTotal = total.equals("--") ? grandTotal + 0 : grandTotal + Integer.parseInt(total);
}
request.setAttribute("summaryMap", stats);
tf.setTotalRows(grandTotal);
String viewNotesHtml = tf.render();
request.setAttribute("viewNotesHtml", viewNotesHtml);
String viewNotesURL = this.getPageURL();
session.setAttribute("viewNotesURL", viewNotesURL);
String viewNotesPageFileName = this.getPageServletFileName();
session.setAttribute("viewNotesPageFileName", viewNotesPageFileName);
request.setAttribute("mapKeys", ResolutionStatus.getMembers());
request.setAttribute("typeNames", DiscrepancyNoteUtil.getTypeNames());
request.setAttribute("typeKeys", totalMap);
request.setAttribute("grandTotal", grandTotal);
if ("yes".equalsIgnoreCase(fp.getString(PRINT))) {
List<DiscrepancyNoteBean> allNotes = factory.findAllNotes(tf);
request.setAttribute("allNotes", allNotes);
forwardPage(Page.VIEW_DISCREPANCY_NOTES_IN_STUDY_PRINT);
} else {
forwardPage(Page.VIEW_DISCREPANCY_NOTES_IN_STUDY);
}
}
use of org.jmesa.facade.TableFacade in project OpenClinica by OpenClinica.
the class ListStudySubjectTableFactory method createTable.
@Override
public // To avoid showing title in other pages, the request element is used to determine where the request came from.
TableFacade createTable(HttpServletRequest request, HttpServletResponse response) {
locale = LocaleResolver.getLocale(request);
session = request.getSession();
TableFacade tableFacade = getTableFacadeImpl(request, response);
tableFacade.setStateAttr("restore");
setDataAndLimitVariables(tableFacade);
configureTableFacade(response, tableFacade);
if (!tableFacade.getLimit().isExported()) {
configureColumns(tableFacade, locale);
tableFacade.setMaxRowsIncrements(getMaxRowIncrements());
configureTableFacadePostColumnConfiguration(tableFacade);
configureTableFacadeCustomView(tableFacade, request);
configureUnexportedTable(tableFacade, locale);
} else {
configureExportColumns(tableFacade, locale);
}
return tableFacade;
}
use of org.jmesa.facade.TableFacade in project OpenClinica by OpenClinica.
the class SDVUtil method renderSubjectsAggregateTable.
public String renderSubjectsAggregateTable(int studyId, HttpServletRequest request) {
List<StudySubjectBean> studySubjectBeans = new ArrayList<StudySubjectBean>();
StudySubjectDAO studySubjectDAO = new StudySubjectDAO(dataSource);
studySubjectBeans = studySubjectDAO.findAllByStudyId(studyId);
Collection<SubjectSDVContainer> items = getSubjectAggregateRows(studySubjectBeans);
//The number of items represents the total number of returned rows
int totalRowCount = 0;
if (items != null && items.size() > 0) {
totalRowCount = items.size();
}
TableFacade tableFacade = createTableFacade("sdv", request);
//set to the total row count
if (totalRowCount > 1) {
tableFacade.setMaxRowsIncrements(15, 50, totalRowCount);
}
tableFacade.setColumnProperties("studySubjectId", "studySubjectStatus", "numberOfCRFsSDV", "percentageOfCRFsSDV", "group", "sdvStatusActions");
tableFacade.setItems(items);
//Fix column titles
HtmlTable table = (HtmlTable) tableFacade.getTable();
//i18n caption; TODO: convert to Spring messages
ResourceBundle resword = ResourceBundle.getBundle("org.akaza.openclinica.i18n.words", LocaleResolver.getLocale(request));
String[] allTitles = { resword.getString("study_subject_ID"), resword.getString("study_subject_status"), resword.getString("num_CRFs_SDV"), resword.getString("porc_CRFs_SDV"), resword.getString("group") };
setTitles(allTitles, table);
table.getTableRenderer().setWidth("800");
return tableFacade.render();
}
use of org.jmesa.facade.TableFacade in project OpenClinica by OpenClinica.
the class ScheduledJobTableFactory method createTable.
/**
* Creating table
*/
@Override
public TableFacade createTable(HttpServletRequest request, HttpServletResponse response) {
locale = LocaleResolver.getLocale(request);
TableFacade tableFacade = getTableFacadeImpl(request, response);
tableFacade.setStateAttr("restore");
int maxJobs = (Integer) request.getAttribute("totalJobs");
tableFacade.setTotalRows(maxJobs);
Limit limit = tableFacade.getLimit();
List<ScheduledJobs> jobs = (List<ScheduledJobs>) request.getAttribute("jobs");
int rowStart = limit.getRowSelect().getRowStart();
int rowEnd = limit.getRowSelect().getRowEnd();
// Collection<SubjectAggregateContainer> items =
// getFilteredItems(studySubjectSDVFilter, studySubjectSDVSort,
// rowStart, rowEnd);
// setDataAndLimitVariables(tableFacade, jobs);
tableFacade.setItems(jobs);
configureTableFacade(response, tableFacade);
if (!tableFacade.getLimit().isExported()) {
configureColumns(tableFacade, locale);
tableFacade.setMaxRowsIncrements(getMaxRowIncrements());
configureTableFacadePostColumnConfiguration(tableFacade);
configureTableFacadeCustomView(tableFacade);
configureUnexportedTable(tableFacade, locale);
} else {
configureExportColumns(tableFacade, locale);
}
return tableFacade;
}
Aggregations