private void showHTMLReportViewer( RptMain report, String reportFileName, RptProperties properties, boolean showParams) { setupReportContext(context, properties); // документация по BIRT Viewer // http://www.eclipse.org/birt/phoenix/deploy/viewerUsage2.2.php StringBuilder sb = new StringBuilder(htmlReportViewerApp) .append("/frameset?__report=") .append(StringUtils.encodeBase64(reportFileName)) .append("&__encodedPaths=true") .append("&__format=html") .append("&__parameterpage=false") .append("&__title=") .append( encodeURL( !StringUtils.stringNullOrEmpty(report.getComment()) ? report.getComment() : report.getRptName())) .append("&__locale=") .append(ServerUtils.getUserLocale()) .append("&") .append(VIEWER_CONTEXT_PARAM_NAME) .append("=") .append(context.get(CONTEXT_ID)); // формирование параметров отчета for (String key : reportParams.keySet()) { ReportParameter param = reportParams.get(key); Object paramValue = null; if (param.getDataType() == ReportParameter.DataType.ENTITY) { Object obj = param.getValue(); if (obj != null) paramValue = ReportUtils.createEntityParam(obj); else sb.append("&__isnull=").append(key); } else paramValue = param.getValue(); if (paramValue != null) { String strParamValue = null; // this is a total hack, see org.eclipse.birt.report.utility.DataUtil#getDisplayValue if (paramValue instanceof Float || paramValue instanceof Double) strParamValue = paramValue.toString(); else if (paramValue instanceof BigDecimal || paramValue instanceof com.ibm.icu.math.BigDecimal) strParamValue = paramValue.toString().replaceFirst("E\\+", "E"); // $NON-NLS-1$//$NON-NLS-2$ else strParamValue = ParameterValidationUtil.getDisplayValue(paramValue); sb.append(PARAMETER_SEPARATOR) .append(key) .append(EQUALS_OPERATOR) .append(encodeURL(strParamValue)); } } UIUtils.showLocalDocument(sb.toString()); }
private void addReportParameter( RptProperties properties, String name, IScalarParameterDefn param, IParameterGroupDefn paramGroup, Object defaultValue) { if (RptProperties.ENTITY_IDS_DATASET_PARAMETER.equalsIgnoreCase(name)) defaultValue = ReportUtils.createEntityIdsParam(properties.getEntityIds()); else if (RptProperties.BUSINESS_SERVICE_DATASET_PARAMETER.equalsIgnoreCase(name)) { BusinessObjectService service = properties.getBusinessService(); if (service != null) defaultValue = service.getBusinessServiceMetadata().getName(); } else if (properties.hasParameterValue(name)) { defaultValue = properties.getParameterValue(name); externalParams.add(name); } reportParams.put(name, new ReportParameterImpl(param, paramGroup, defaultValue, this)); }
private void setupEngineTask(IEngineTask engineTask, RptProperties properties) { Map<String, Object> params = new HashMap<String, Object>(); for (String key : reportParams.keySet()) { ReportParameter param = reportParams.get(key); if (param.getDataType() == ReportParameter.DataType.ENTITY) params.put(key, ReportUtils.createEntityParam(param.getValue())); else params.put(key, param.getValue()); } engineTask.setParameterValues(params); setupReportContext(context, properties); Map<String, Object> appContext = new HashMap<String, Object>(); appContext.put(APP_REPORT_CONTEXT, context); engineTask.setAppContext(appContext); engineTask.setLocale(properties.getLocale()); }