private void populateScreenFromData(TemplateForReportTemplateSearchVoCollection coll) { if (coll == null) return; for (int i = 0; i < coll.size(); i++) { TemplateForReportTemplateSearchVo template = coll.get(i); grdResultRow row = form.grdResult().getRows().newRow(); row.setcolReport(template.getReport().getReportName()); row.setcolTemplate(template.getName()); row.setValue(template); } }
private void doSearch() { clearControls(); TemplateForReportTemplateSearchVoCollection coll = domain.listTemplates(form.txtReportName().getValue(), form.txtTemplateName().getValue()); if (coll == null || coll.size() == 0) { engine.showMessage("No results matching your search criteria were found !"); return; } populateScreenFromData(coll); }
public TemplateForReportTemplateSearchVoCollection listTemplates(String reportSearchText, String templateSearchText) { StringBuffer hql = new StringBuffer(); StringBuffer cond = new StringBuffer(); ArrayList<String> markers = new ArrayList<String>(); ArrayList<Object> values = new ArrayList<Object>(); if (reportSearchText == null || reportSearchText.length() == 0) { reportSearchText = "%"; } else { if(!reportSearchText.startsWith("%")) reportSearchText = "%" + reportSearchText; if(!reportSearchText.endsWith("%")) reportSearchText = reportSearchText + "%"; } if (templateSearchText == null || templateSearchText.length() == 0) { templateSearchText = "%"; } else { if(!templateSearchText.startsWith("%")) templateSearchText = "%" + templateSearchText; if(!templateSearchText.endsWith("%")) templateSearchText = templateSearchText + "%"; } String andStr = " "; hql.append("select template from TemplateBo as template left join template.report as report "); cond.append(andStr + "report.isActive = :isActive"); markers.add("isActive"); values.add(Boolean.TRUE); andStr = " and "; cond.append(andStr + "UPPER(report.reportName) like UPPER(:reportName)"); markers.add("reportName"); values.add(reportSearchText); andStr = " and "; cond.append(andStr + "template.isActive = :isActive"); markers.add("isActive"); values.add(Boolean.TRUE); andStr = " and "; cond.append(andStr + "UPPER(template.name) like UPPER(:templateName)"); markers.add("templateName"); values.add(templateSearchText); andStr = " and "; if (andStr.equals(" and ")) { hql.append(" where "); } hql.append(cond.toString()); DomainFactory factory = getDomainFactory(); List <?>list = factory.find(hql.toString(), markers, values); return TemplateForReportTemplateSearchVoAssembler.createTemplateForReportTemplateSearchVoCollectionFromTemplateBo(list).sort(); }