use of org.jmesa.facade.TableFacade in project OpenClinica by OpenClinica.
the class AbstractTableFactory method createTable.
public TableFacade createTable(HttpServletRequest request, HttpServletResponse response) {
locale = LocaleResolver.getLocale(request);
session = request.getSession();
TableFacade tableFacade = getTableFacadeImpl(request, response);
setStateAttr(tableFacade);
setDataAndLimitVariables(tableFacade);
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;
}
use of org.jmesa.facade.TableFacade in project OpenClinica by OpenClinica.
the class AbstractTableFactory method exportCSVTable.
/**
* Use this method to export all data from table. 1. filters/sorts will be ignored 2. Whole table will be exported
* page by page 3. Configure getSize(Limit limit)
*
* @param request
* @param response
* @see getSize(Limit limit), createLimits()
* @see filter & sort methods in implementations
*/
public void exportCSVTable(HttpServletRequest request, HttpServletResponse response, String path) {
locale = LocaleResolver.getLocale(request);
String DATE_FORMAT = "yyyyMMddHHmmss";
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
String fileName = getTableName() + "_" + sdf.format(new Date());
for (Limit limit : createLimits()) {
TableFacade tableFacade = new OCTableFacadeImpl(getTableName(), request, response, path + File.separator + fileName);
tableFacade.setStateAttr("restore");
tableFacade.setLimit(limit);
tableFacade.autoFilterAndSort(false);
setDataAndLimitVariables(tableFacade);
configureTableFacade(response, tableFacade);
configureExportColumns(tableFacade, locale);
tableFacade.render();
}
}
use of org.jmesa.facade.TableFacade in project OpenClinica by OpenClinica.
the class ListNotesTableFactory method getTableFacadeImpl.
@Override
public TableFacade getTableFacadeImpl(HttpServletRequest request, HttpServletResponse response) {
TableFacade facade = super.getTableFacadeImpl(request, response);
// Filtering and sorting performed on the DB layer
facade.autoFilterAndSort(false);
return facade;
}
use of org.jmesa.facade.TableFacade in project OpenClinica by OpenClinica.
the class SDVUtil method renderSubjectsTableWithLimit.
public String renderSubjectsTableWithLimit(HttpServletRequest request, int studyId, int studySubjectId) {
TableFacade tableFacade = createTableFacade("sdv", request);
tableFacade.setStateAttr("restore");
/*
* StudySubjectDAO studySubjectDAO = new StudySubjectDAO(dataSource);
* StudySubjectBean subjectBean = (StudySubjectBean) studySubjectDAO.findByPK(studySubjectId);
*/
String[] allColumns = new String[] { "studySubjectId", "studyIdentifier", "personId", "secondaryId", "eventName", "eventDate", "enrollmentDate", "studySubjectStatus", "crfNameVersion", "sdvRequirementDefinition", "crfStatus", "lastUpdatedDate", "lastUpdatedBy", "studyEventStatus", "sdvStatusActions" };
tableFacade.setColumnProperties("studySubjectId", "studyIdentifier", "personId", "secondaryId", "eventName", "eventDate", "enrollmentDate", "studySubjectStatus", "crfNameVersion", "sdvRequirementDefinition", "crfStatus", "lastUpdatedDate", "lastUpdatedBy", "studyEventStatus", "sdvStatusActions");
tableFacade.addFilterMatcher(new MatcherKey(String.class, "studySubjectStatus"), new SubjectStatusMatcher());
tableFacade.addFilterMatcher(new MatcherKey(String.class, "crfStatus"), new CrfStatusMatcher());
tableFacade.addFilterMatcher(new MatcherKey(String.class, "sdvStatusActions"), new SdvStatusMatcher());
tableFacade.addFilterMatcher(new MatcherKey(String.class, "sdvRequirementDefinition"), new SDVRequirementMatcher());
int totalRowCount = 0;
totalRowCount = setDataAndLimitVariablesSubjects(tableFacade, studyId, studySubjectId, request);
// tableFacade.setItems(items);
HtmlRow row = (HtmlRow) tableFacade.getTable().getRow();
HtmlColumn studySubjectStatus = row.getColumn("studySubjectStatus");
studySubjectStatus.getFilterRenderer().setFilterEditor(new SubjectStatusFilter());
HtmlColumn crfStatus = row.getColumn("crfStatus");
crfStatus.getFilterRenderer().setFilterEditor(new CrfStatusFilter());
HtmlColumn sdvStatus = row.getColumn("sdvStatusActions");
sdvStatus.getFilterRenderer().setFilterEditor(new SdvStatusFilter());
HtmlColumn sdvRequirementDefinition = row.getColumn("sdvRequirementDefinition");
sdvRequirementDefinition.getFilterRenderer().setFilterEditor(new SDVRequirementFilter());
// fix HTML in columns
setHtmlCellEditors(tableFacade, allColumns, true);
// temporarily disable some of the filters for now
turnOffFilters(tableFacade, new String[] { "personId", "secondaryId", "enrollmentDate", "studySubjectStatus", "crfNameVersion", "lastUpdatedDate", "lastUpdatedBy" });
// Create the custom toolbar
SDVToolbar sDVToolbar = new SDVToolbar(true);
// if(totalRowCount > 0){
sDVToolbar.setMaxRowsIncrements(new int[] { 15, 50, totalRowCount });
tableFacade.setToolbar(sDVToolbar);
// 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("site_id"), resword.getString("person_ID"), resword.getString("secondary_ID"), resword.getString("event_name"), resword.getString("event_date"), resword.getString("enrollment_date"), resword.getString("subject_status"), resword.getString("CRF_name") + " / " + resword.getString("version"), resword.getString("SDV_requirement"), resword.getString("CRF_status"), resword.getString("last_updated_date"), resword.getString("last_updated_by"), resword.getString("study_event_status"), resword.getString("SDV_status") + " / " + resword.getString("actions") };
setTitles(allTitles, table);
// format column dates
formatColumns(table, new String[] { "eventDate", "enrollmentDate", "lastUpdatedDate" }, request);
table.getTableRenderer().setWidth("800");
return tableFacade.render();
}
use of org.jmesa.facade.TableFacade in project OpenClinica by OpenClinica.
the class SDVUtil method renderEventCRFTableWithLimit.
/*
* private int getTotalRowCount(FilterSet filterSet, int studyId) {
*
*
* EventCRFDAO eventCRFDAO = new EventCRFDAO(dataSource);
*
* if (filterSet.getFilters().size() == 0) {
* return eventCRFDAO.countEventCRFsByStudy(studyId, studyId);
* }
*
* int count = 0;
* //Filter for study subject label
* StudySubjectDAO studySubjectDAO = new StudySubjectDAO(dataSource);
* StudySubjectBean studySubjectBean = new StudySubjectBean();
* StudyDAO studyDAO = new StudyDAO(dataSource);
* StudyBean studyBean = (StudyBean) studyDAO.findByPK(studyId);
* String subjectValue = "";
* String eventNameValue = "";
* String eventDateValue = "";
* String crfStatus = "";
* String sdvStatus = "";
* String studyIdentifier = "";
* String sdvRequirement = "";
*
* for (Filter filter : filterSet.getFilters()) {
*
* if (filter.getProperty().equalsIgnoreCase("studySubjectId")) {
* subjectValue = filter.getValue();
* continue;
* }
* if (filter.getProperty().equalsIgnoreCase("eventName")) {
* eventNameValue = filter.getValue();
* continue;
* }
*
* if (filter.getProperty().equalsIgnoreCase("eventDate")) {
* eventDateValue = filter.getValue();
* continue;
* }
*
* if (filter.getProperty().equalsIgnoreCase("crfStatus")) {
* crfStatus = filter.getValue();
* continue;
* }
*
* if (filter.getProperty().equalsIgnoreCase("sdvStatus")) {
* sdvStatus = filter.getValue();
* }
*
* if (filter.getProperty().equalsIgnoreCase("studyIdentifier")) {
* studyIdentifier = filter.getValue();
* }
*
* if (filter.getProperty().equalsIgnoreCase("sdvRequirementDefinition")) {
* sdvRequirement = filter.getValue();
* }
* }
*
* SourceDataVerification sourceDataVerification = null;
*
* if (subjectValue.length() > 0) {
* return eventCRFDAO.countEventCRFsByStudySubjectLabel(subjectValue, studyId, studyId);
* }
*
* if (eventNameValue.length() > 0) {
* return eventCRFDAO.countEventCRFsByEventName(eventNameValue);
* }
*
* if (eventDateValue.length() > 0) {
* return eventCRFDAO.countEventCRFsByEventDate(studyId, eventDateValue);
* }
* //SubjectEventStatus.getSubjectEventStatusIdByName(crfStatus)
* if (crfStatus.length() > 0) {
* return eventCRFDAO.countEventCRFsByCRFStatus(studyId, Integer.parseInt(crfStatus));
* }
*
* if (sdvStatus.length() > 0) {
* return eventCRFDAO.countEventCRFsByStudySDV(studyId, ("complete".equalsIgnoreCase(sdvStatus)));
* }
*
* if (studyIdentifier.length() > 0) {
* return eventCRFDAO.countEventCRFsByStudyIdentifier(studyId, studyId, studyIdentifier);
* }
*
* if (sdvRequirement.length() > 0) {
* ArrayList<Integer> reqs = new ArrayList<Integer>();
* if (sdvRequirement.contains("&")) {
* for (String requirement : sdvRequirement.split("&")) {
* reqs.add(SourceDataVerification.getByI18nDescription(requirement.trim()).getCode());
* }
* } else {
* reqs.add(SourceDataVerification.getByI18nDescription(sdvRequirement.trim()).getCode());
* }
* if (reqs.size() > 0) {
* Integer[] a = { 1 };
* return eventCRFDAO.countEventCRFsBySDVRequirement(studyId, studyId, reqs.toArray(a));
* }
* }
*
* return eventCRFDAO.countEventCRFsByStudy(studyId, studyId);
* }
*/
/*
* public String renderAllEventCRFTable(List<EventCRFBean> eventCRFBeans,
* HttpServletRequest request){
*
* Collection<SubjectSDVContainer> items = getSubjectRows(eventCRFBeans,request);
*
* //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);
* tableFacade.setStateAttr("restore");
*
* String[] allColumns = new String[]{"studySubjectId","personId","secondaryId",
* "eventName", "eventDate","enrollmentDate","studySubjectStatus","crfNameVersion","crfStatus",
* "lastUpdatedDate","lastUpdatedBy","sdvStatusActions"};
*
* tableFacade.setColumnProperties("studySubjectId","personId","secondaryId",
* "eventName",
* "eventDate","enrollmentDate","studySubjectStatus","crfNameVersion","crfStatus",
* "lastUpdatedDate",
* "lastUpdatedBy","sdvStatusActions");
*
* tableFacade.addFilterMatcher(new MatcherKey(String.class, "studySubjectStatus"),
* new SubjectStatusMatcher());
* tableFacade.setItems(items);
*
* HtmlRow row = (HtmlRow) tableFacade.getTable().getRow();
* HtmlColumn studySubjectStatus = row.getColumn("studySubjectStatus");
* studySubjectStatus.getFilterRenderer().setFilterEditor(new SubjectStatusFilter());
*
*
* //fix HTML in columns
* setHtmlCellEditors(tableFacade,allColumns,true);
*
*
* //Create the custom toolbar
* SDVToolbar sDVToolbar = new SDVToolbar();
*
* // if(totalRowCount > 0){
* if(totalRowCount <= 25){
* sDVToolbar.setMaxRowsIncrements(new int[]{10,15,totalRowCount});}
* else if(totalRowCount <= 50){
* sDVToolbar.setMaxRowsIncrements(new int[]{10,25,totalRowCount});
* } else if(totalRowCount > 0) {
* sDVToolbar.setMaxRowsIncrements(new int[]{15,50,100});
* }
* tableFacade.setToolbar(sDVToolbar);
*
* //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[] allTitles = {"Study Subject Id","Person Id","Secondary Id" ,"Event Name",
* "Event Date","Enrollment Date","Subject Status","CRF Name / Version","CRF Status",
* "Last Updated Date",
* "Last Updated By","SDV Status / Actions"};
*
* setTitles(allTitles,table);
*
* //format column dates
* formatColumns(table,new String[]{"eventDate","enrollmentDate","lastUpdatedDate"},
* request);
*
* table.getTableRenderer().setWidth("800");
* return tableFacade.render();
* }
*/
public String renderEventCRFTableWithLimit(HttpServletRequest request, int studyId, String pathPrefix) {
// boolean showMoreLink = Boolean.parseBoolean(request.getAttribute("showMoreLink").toString());//commented by
// Jamuna, throwing null pointer exception
boolean showMoreLink = Boolean.parseBoolean(request.getAttribute("showMoreLink") == null ? "false" : request.getAttribute("showMoreLink").toString());
TableFacade tableFacade = createTableFacade("sdv", request);
tableFacade.setStateAttr("sdv_restore");
resformat = ResourceBundleProvider.getFormatBundle(LocaleResolver.getLocale(request));
this.pathPrefix = pathPrefix;
String[] allColumns = new String[] { "sdvStatus", "studySubjectId", "studyIdentifier", "personId", "secondaryId", "eventName", "eventDate", "enrollmentDate", "studySubjectStatus", "crfNameVersion", "sdvRequirementDefinition", "crfStatus", "lastUpdatedDate", "lastUpdatedBy", "studyEventStatus", "sdvStatusActions" };
tableFacade.setColumnProperties("sdvStatus", "studySubjectId", "studyIdentifier", "personId", "secondaryId", "eventName", "eventDate", "enrollmentDate", "studySubjectStatus", "crfNameVersion", "sdvRequirementDefinition", "crfStatus", "lastUpdatedDate", "lastUpdatedBy", "studyEventStatus", "sdvStatusActions");
tableFacade.addFilterMatcher(new MatcherKey(String.class, "studySubjectStatus"), new SubjectStatusMatcher());
tableFacade.addFilterMatcher(new MatcherKey(String.class, "crfStatus"), new CrfStatusMatcher());
tableFacade.addFilterMatcher(new MatcherKey(String.class, "sdvStatus"), new SdvStatusMatcher());
tableFacade.addFilterMatcher(new MatcherKey(String.class, "sdvRequirementDefinition"), new SDVRequirementMatcher());
this.setDataAndLimitVariables(tableFacade, studyId, request);
// tableFacade.setItems(items);
HtmlRow row = (HtmlRow) tableFacade.getTable().getRow();
HtmlColumn studySubjectStatus = row.getColumn("studySubjectStatus");
studySubjectStatus.getFilterRenderer().setFilterEditor(new SubjectStatusFilter());
HtmlColumn crfStatus = row.getColumn("crfStatus");
crfStatus.getFilterRenderer().setFilterEditor(new CrfStatusFilter());
HtmlColumn actions = row.getColumn("sdvStatusActions");
actions.getFilterRenderer().setFilterEditor(new DefaultActionsEditor(LocaleResolver.getLocale(request)));
HtmlColumn sdvStatus = row.getColumn("sdvStatus");
sdvStatus.getFilterRenderer().setFilterEditor(new SdvStatusFilter());
HtmlColumn sdvRequirementDefinition = row.getColumn("sdvRequirementDefinition");
sdvRequirementDefinition.getFilterRenderer().setFilterEditor(new SDVRequirementFilter());
// fix HTML in columns
setHtmlCellEditors(tableFacade, allColumns, true);
// temporarily disable some of the filters for now
turnOffFilters(tableFacade, new String[] { "personId", "secondaryId", "enrollmentDate", "studySubjectStatus", "crfNameVersion", "lastUpdatedDate", "lastUpdatedBy", "eventDate", "studyEventStatus" });
turnOffSorts(tableFacade, new String[] { "sdvStatus", "studySubjectId", "studyIdentifier", "personId", "secondaryId", "eventName", "eventDate", "enrollmentDate", "studySubjectStatus", "crfNameVersion", "sdvRequirementDefinition", "crfStatus", "lastUpdatedDate", "lastUpdatedBy", "studyEventStatus", "sdvStatusActions" });
// Create the custom toolbar
SDVToolbar sDVToolbar = new SDVToolbar(showMoreLink);
// if(totalRowCount > 0){
sDVToolbar.setMaxRowsIncrements(new int[] { 15, 25, 50 });
tableFacade.setToolbar(sDVToolbar);
tableFacade.setView(new SDVView(LocaleResolver.getLocale(request), request));
// 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("SDV_status"), resword.getString("study_subject_ID"), resword.getString("site_id"), resword.getString("person_ID"), resword.getString("secondary_ID"), resword.getString("event_name"), resword.getString("event_date"), resword.getString("enrollment_date"), resword.getString("subject_status"), resword.getString("CRF_name") + " / " + resword.getString("version"), resword.getString("SDV_requirement"), resword.getString("CRF_status"), resword.getString("last_updated_date"), resword.getString("last_updated_by"), resword.getString("study_event_status"), resword.getString("actions") };
setTitles(allTitles, table);
// format column dates
formatColumns(table, new String[] { "eventDate", "enrollmentDate", "lastUpdatedDate" }, request);
table.getTableRenderer().setWidth("800");
return tableFacade.render();
}
Aggregations