use of org.jmesa.view.html.component.HtmlRow in project OpenClinica by OpenClinica.
the class ViewCRFServlet method html.
private String html(TableFacade tableFacade) {
// set the column properties
tableFacade.setColumnProperties("versionName", "ruleName", "ruleExpression", "executeOnPlaceHolder", "actionTypePlaceHolder", "actionSummaryPlaceHolder", "link");
HtmlTable table = (HtmlTable) tableFacade.getTable();
table.setCaption(resword.getString("rule_rules"));
table.getTableRenderer().setWidth("800px");
HtmlRow row = table.getRow();
HtmlColumn versionName = row.getColumn("versionName");
versionName.setTitle(resword.getString("CRF_version"));
HtmlColumn ruleName = row.getColumn("ruleName");
ruleName.setTitle(resword.getString("rule_name"));
HtmlColumn career = row.getColumn("ruleExpression");
career.setWidth("100px");
career.setTitle(resword.getString("rule_expression"));
HtmlColumn executeOn = row.getColumn("executeOnPlaceHolder");
executeOn.setSortable(false);
executeOn.setFilterable(false);
executeOn.setTitle(resword.getString("rule_execute_on"));
executeOn.getCellRenderer().setCellEditor(new CellEditor() {
@SuppressWarnings("unchecked")
public Object getValue(Object item, String property, int rowcount) {
String value = "";
List<RuleActionBean> ruleActions = (List<RuleActionBean>) new BasicCellEditor().getValue(item, "actions", rowcount);
for (int i = 0; i < ruleActions.size(); i++) {
value += ruleActions.get(i).getExpressionEvaluatesTo();
// Do not add horizontal line after last Summary
if (i != ruleActions.size() - 1) {
value += "<hr>";
}
}
return value;
}
});
HtmlColumn actionTypePlaceHolder = row.getColumn("actionTypePlaceHolder");
actionTypePlaceHolder.setSortable(false);
actionTypePlaceHolder.setFilterable(false);
actionTypePlaceHolder.setTitle(resword.getString("rule_action_type"));
actionTypePlaceHolder.getCellRenderer().setCellEditor(new CellEditor() {
@SuppressWarnings("unchecked")
public Object getValue(Object item, String property, int rowcount) {
String value = "";
List<RuleActionBean> ruleActions = (List<RuleActionBean>) new BasicCellEditor().getValue(item, "actions", rowcount);
for (int i = 0; i < ruleActions.size(); i++) {
value += ruleActions.get(i).getActionType().name();
// Do not add horizontal line after last Summary
if (i != ruleActions.size() - 1) {
value += "<hr>";
}
}
return value;
}
});
HtmlColumn actionSummaryPlaceHolder = row.getColumn("actionSummaryPlaceHolder");
actionSummaryPlaceHolder.setSortable(false);
actionSummaryPlaceHolder.setFilterable(false);
actionSummaryPlaceHolder.setTitle(resword.getString("rule_action_summary"));
actionSummaryPlaceHolder.getCellRenderer().setCellEditor(new CellEditor() {
@SuppressWarnings("unchecked")
public Object getValue(Object item, String property, int rowcount) {
String value = "";
List<RuleActionBean> ruleActions = (List<RuleActionBean>) new BasicCellEditor().getValue(item, "actions", rowcount);
for (int i = 0; i < ruleActions.size(); i++) {
value += ruleActions.get(i).getSummary();
// Do not add horizontal line after last Summary
if (i != ruleActions.size() - 1) {
value += "<hr>";
}
}
return value;
}
});
HtmlColumn link = row.getColumn("link");
link.setSortable(false);
link.setFilterable(false);
link.setTitle(resword.getString("action"));
link.getCellRenderer().setCellEditor(new CellEditor() {
@SuppressWarnings("unchecked")
public Object getValue(Object item, String property, int rowcount) {
String param1 = (String) new BasicCellEditor().getValue(item, "ruleSetRuleId", rowcount);
String param2 = (String) new BasicCellEditor().getValue(item, "versionId", rowcount);
HtmlBuilder html = new HtmlBuilder();
html.a().href().quote().append(request.getContextPath() + "/RunRule?ruleSetRuleId=" + param1 + "&versionId=" + param2 + "&action=dryRun").quote().close();
html.img().name("bt_View1").src("images/bt_ExexuteRules.gif").border("0").end();
html.aEnd();
return html.toString();
}
});
// Return the Html.
return tableFacade.render();
}
use of org.jmesa.view.html.component.HtmlRow in project OpenClinica by OpenClinica.
the class SubjectIdSDVFactory method configureColumns.
@Override
protected void configureColumns(TableFacade tableFacade, Locale locale) {
tableFacade.setColumnProperties("sdvStatus", "studySubjectId", "siteId", "personId", "studySubjectStatus", "group", "numberCRFComplete", "numberOfCRFsSDV", "totalEventCRF", "actions");
resword = ResourceBundleProvider.getWordsBundle(locale);
Row row = tableFacade.getTable().getRow();
SDVUtil sdvUtil = new SDVUtil();
String[] allTitles = new String[] { resword.getString("SDV_status"), resword.getString("study_subject_ID"), resword.getString("site_id"), resword.getString("person_ID"), resword.getString("study_subject_status"), resword.getString("group"), resword.getString("num_CRFs_completed"), resword.getString("num_CRFs_SDV"), resword.getString("total_events_CRF"), resword.getString("actions") };
sdvUtil.setTitles(allTitles, (HtmlTable) tableFacade.getTable());
sdvUtil.turnOffFilters(tableFacade, new String[] { "personId", "studySubjectStatus", "group", "numberCRFComplete", "numberOfCRFsSDV", "totalEventCRF", "actions" });
sdvUtil.turnOffSorts(tableFacade, new String[] { "sdvStatus", "studySubjectId", "siteId", "personId", "studySubjectStatus", "group", "numberCRFComplete", "numberOfCRFsSDV", "totalEventCRF" });
sdvUtil.setHtmlCellEditors(tableFacade, new String[] { "sdvStatus", "actions" }, false);
HtmlColumn sdvStatus = ((HtmlRow) row).getColumn("sdvStatus");
sdvStatus.getFilterRenderer().setFilterEditor(new SdvStatusFilter());
String actionsHeader = resword.getString("rule_actions") + "                            ";
configureColumn(row.getColumn("actions"), actionsHeader, sdvUtil.getCellEditorNoEscapes(), new DefaultActionsEditor(locale), true, false);
}
use of org.jmesa.view.html.component.HtmlRow in project OpenClinica by OpenClinica.
the class SDVUtil method setHtmlCellEditors.
public void setHtmlCellEditors(TableFacade tableFacade, String[] columnNames, boolean preventHtmlEscapes) {
HtmlRow row = ((HtmlTable) tableFacade.getTable()).getRow();
HtmlColumn column = null;
for (String col : columnNames) {
column = row.getColumn(col);
column.getCellRenderer().setCellEditor(this.getCellEditorNoEscapes());
}
}
use of org.jmesa.view.html.component.HtmlRow 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.view.html.component.HtmlRow 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