net.sf.jasperreports.engine.JRParameter Java Examples
The following examples show how to use
net.sf.jasperreports.engine.JRParameter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JRBaseFiller.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
protected int getMaxPageHeight(Map<String,Object> parameterValues) { Integer maxPageHeightParam = (Integer) parameterValues.get(JRParameter.MAX_PAGE_HEIGHT); int maxPageHeight = maxPageHeightParam != null ? maxPageHeightParam : PAGE_HEIGHT_PAGINATION_IGNORED; if (maxPageHeight < pageHeight) { if (log.isDebugEnabled()) { log.debug("max page height " + maxPageHeight + " smaller than report page height " + pageHeight); } //use the report page height maxPageHeight = pageHeight; } if (log.isDebugEnabled()) { log.debug("max page height is " + maxPageHeight); } return maxPageHeight; }
Example #2
Source File: AbstractJasperReportsView.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * Expose current Spring-managed Locale and MessageSource to JasperReports i18n * ($R expressions etc). The MessageSource should only be exposed as JasperReports * resource bundle if no such bundle is defined in the report itself. * <p>The default implementation exposes the Spring RequestContext Locale and a * MessageSourceResourceBundle adapter for the Spring ApplicationContext, * analogous to the {@code JstlUtils.exposeLocalizationContext} method. * @see org.springframework.web.servlet.support.RequestContextUtils#getLocale * @see org.springframework.context.support.MessageSourceResourceBundle * @see #getApplicationContext() * @see net.sf.jasperreports.engine.JRParameter#REPORT_LOCALE * @see net.sf.jasperreports.engine.JRParameter#REPORT_RESOURCE_BUNDLE * @see org.springframework.web.servlet.support.JstlUtils#exposeLocalizationContext */ protected void exposeLocalizationContext(Map<String, Object> model, HttpServletRequest request) { RequestContext rc = new RequestContext(request, getServletContext()); Locale locale = rc.getLocale(); if (!model.containsKey(JRParameter.REPORT_LOCALE)) { model.put(JRParameter.REPORT_LOCALE, locale); } TimeZone timeZone = rc.getTimeZone(); if (timeZone != null && !model.containsKey(JRParameter.REPORT_TIME_ZONE)) { model.put(JRParameter.REPORT_TIME_ZONE, timeZone); } JasperReport report = getReport(); if ((report == null || report.getResourceBundle() == null) && !model.containsKey(JRParameter.REPORT_RESOURCE_BUNDLE)) { model.put(JRParameter.REPORT_RESOURCE_BUNDLE, new MessageSourceResourceBundle(rc.getMessageSource(), locale)); } }
Example #3
Source File: JndiDataAdapterService.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void contributeParameters(Map<String, Object> parameters) throws JRException { JndiDataAdapter jndiDataAdapter = getJndiDataAdapter(); if (jndiDataAdapter != null) { try { Context ctx = new InitialContext(); DataSource dataSource = (DataSource) ctx.lookup("java:comp/env/" + jndiDataAdapter.getDataSourceName()); connection = dataSource.getConnection(); } catch (Exception ex) { throw new JRException(ex); } parameters.put(JRParameter.REPORT_CONNECTION, connection); } }
Example #4
Source File: VirtualizerApp.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
private static JasperPrint fillReport(JRFileVirtualizer virtualizer) throws JRException { long start = System.currentTimeMillis(); // Virtualization works only with in memory JasperPrint objects. // All the operations will first fill the report and then export // the filled object. // creating the data source JRDataSource dataSource = new JREmptyDataSource(1000); // Preparing parameters Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put(JRParameter.REPORT_VIRTUALIZER, virtualizer); // filling the report JasperPrint jasperPrint = JasperFillManager.fillReport("build/reports/VirtualizerReport.jasper", parameters, dataSource); virtualizer.setReadOnly(true); System.err.println("Filling time : " + (System.currentTimeMillis() - start)); return jasperPrint; }
Example #5
Source File: ReportGenerationServiceTest.java From kfs with GNU Affero General Public License v3.0 | 6 votes |
public void testGenerateReportToPdfFile_WithDataSource() throws Exception { String reportFileName = infoForDataSourceReport.getReportFileName(); String reportDirectoty = infoForDataSourceReport.getReportsDirectory(); String reportTemplateClassPath = infoForDataSourceReport.getReportTemplateClassPath(); String reportTemplateName = infoForDataSourceReport.getReportTemplateName(); ResourceBundle resourceBundle = infoForDataSourceReport.getResourceBundle(); String subReportTemplateClassPath = infoForDataSourceReport.getSubReportTemplateClassPath(); Map<String, String> subReports = infoForDataSourceReport.getSubReports(); Map<String, Object> reportData = new HashMap<String, Object>(); reportData.put(JRParameter.REPORT_RESOURCE_BUNDLE, resourceBundle); reportData.put(ReportGeneration.PARAMETER_NAME_SUBREPORT_DIR, subReportTemplateClassPath); reportData.put(ReportGeneration.PARAMETER_NAME_SUBREPORT_TEMPLATE_NAME, subReports); try { String template = reportTemplateClassPath + reportTemplateName; String fullReportFileName = reportDirectoty + reportFileName; Collection<Account> accountDataSource = this.getAccounts(); reportGenerationService.generateReportToPdfFile(reportData, accountDataSource, template, fullReportFileName); } catch (Exception e) { LOG.error("fail to generate PDF file", e); fail("fail to generate PDF file." + e); } }
Example #6
Source File: QueryApp.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
/** * */ private void fill(boolean ignorePagination) throws JRException { long start = System.currentTimeMillis(); //Preparing parameters Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("ReportTitle", "Address Report"); List<String> excludedCities = new ArrayList<String>(); excludedCities.add("Boston"); excludedCities.add("Chicago"); excludedCities.add("Oslo"); parameters.put("ExcludedCities", excludedCities); parameters.put("OrderClause", "City"); if (ignorePagination) { parameters.put(JRParameter.IS_IGNORE_PAGINATION, Boolean.TRUE); } JasperFillManager.fillReportToFile("build/reports/QueryReport.jasper", parameters, getDemoHsqldbConnection()); System.err.println("Filling time : " + (System.currentTimeMillis() - start)); }
Example #7
Source File: EffortCertificationReportServiceImpl.java From kfs with GNU Affero General Public License v3.0 | 6 votes |
/** * @see org.kuali.kfs.module.ec.service.EffortCertificationReportService#generateReportForExtractProcess(org.kuali.kfs.module.ec.util.ExtractProcessReportDataHolder, java.util.Date) */ public void generateReportForExtractProcess(ExtractProcessReportDataHolder reportDataHolder, Date runDate) { String reportFileName = effortExtractProcessReportInfo.getReportFileName(); String reportDirectory = effortExtractProcessReportInfo.getReportsDirectory(); String reportTemplateClassPath = effortExtractProcessReportInfo.getReportTemplateClassPath(); String reportTemplateName = effortExtractProcessReportInfo.getReportTemplateName(); ResourceBundle resourceBundle = effortExtractProcessReportInfo.getResourceBundle(); String subReportTemplateClassPath = effortExtractProcessReportInfo.getSubReportTemplateClassPath(); Map<String, String> subReports = effortExtractProcessReportInfo.getSubReports(); Map<String, Object> reportData = reportDataHolder.getReportData(); reportData.put(JRParameter.REPORT_RESOURCE_BUNDLE, resourceBundle); reportData.put(ReportGeneration.PARAMETER_NAME_SUBREPORT_DIR, subReportTemplateClassPath); reportData.put(ReportGeneration.PARAMETER_NAME_SUBREPORT_TEMPLATE_NAME, subReports); String template = reportTemplateClassPath + reportTemplateName; String fullReportFileName = reportGenerationService.buildFullFileName(runDate, reportDirectory, reportFileName, ""); reportGenerationService.generateReportToPdfFile(reportData, template, fullReportFileName); }
Example #8
Source File: AbstractJasperReportsView.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Expose current Spring-managed Locale and MessageSource to JasperReports i18n * ($R expressions etc). The MessageSource should only be exposed as JasperReports * resource bundle if no such bundle is defined in the report itself. * <p>The default implementation exposes the Spring RequestContext Locale and a * MessageSourceResourceBundle adapter for the Spring ApplicationContext, * analogous to the {@code JstlUtils.exposeLocalizationContext} method. * @see org.springframework.web.servlet.support.RequestContextUtils#getLocale * @see org.springframework.context.support.MessageSourceResourceBundle * @see #getApplicationContext() * @see net.sf.jasperreports.engine.JRParameter#REPORT_LOCALE * @see net.sf.jasperreports.engine.JRParameter#REPORT_RESOURCE_BUNDLE * @see org.springframework.web.servlet.support.JstlUtils#exposeLocalizationContext */ protected void exposeLocalizationContext(Map<String, Object> model, HttpServletRequest request) { RequestContext rc = new RequestContext(request, getServletContext()); Locale locale = rc.getLocale(); if (!model.containsKey(JRParameter.REPORT_LOCALE)) { model.put(JRParameter.REPORT_LOCALE, locale); } TimeZone timeZone = rc.getTimeZone(); if (timeZone != null && !model.containsKey(JRParameter.REPORT_TIME_ZONE)) { model.put(JRParameter.REPORT_TIME_ZONE, timeZone); } JasperReport report = getReport(); if ((report == null || report.getResourceBundle() == null) && !model.containsKey(JRParameter.REPORT_RESOURCE_BUNDLE)) { model.put(JRParameter.REPORT_RESOURCE_BUNDLE, new MessageSourceResourceBundle(rc.getMessageSource(), locale)); } }
Example #9
Source File: SubreportFillPart.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
private void setBookmarksParameter() { JRPart part = fillContext.getPart(); String bookmarksParameter = part.hasProperties() ? part.getPropertiesMap().getProperty(PROPERTY_BOOKMARKS_DATA_SOURCE_PARAMETER) : null; if (bookmarksParameter == null) { return; } if (bookmarksParameter.equals(JRParameter.REPORT_DATA_SOURCE)) { // if the bookmarks data source is created as main data source for the part report, // automatically exclude it from data snapshots as jive actions might result in different bookmarks. // if the data source is not the main report data source people will have to manually inhibit data caching. cacheIncluded = false; } BookmarkHelper bookmarks = fillContext.getFiller().getFirstBookmarkHelper(); BookmarksFlatDataSource bookmarksDataSource = new BookmarksFlatDataSource(bookmarks); parameterValues.put(bookmarksParameter, bookmarksDataSource); }
Example #10
Source File: JRBaseObjectFactory.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
/** * */ protected JRBaseParameter getParameter(JRParameter parameter) { JRBaseParameter baseParameter = null; if (parameter != null) { baseParameter = (JRBaseParameter)get(parameter); if (baseParameter == null) { baseParameter = new JRBaseParameter(parameter, this); } } return baseParameter; }
Example #11
Source File: JRBaseParameter.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
/** * */ protected JRBaseParameter(JRParameter parameter, JRBaseObjectFactory factory) { factory.put(parameter, this); name = parameter.getName(); description = parameter.getDescription(); valueClassName = parameter.getValueClassName(); nestedTypeName = parameter.getNestedTypeName(); isSystemDefined = parameter.isSystemDefined(); isForPrompting = parameter.isForPrompting(); evaluationTime = parameter.getEvaluationTime(); defaultValueExpression = factory.getExpression(parameter.getDefaultValueExpression()); propertiesMap = parameter.getPropertiesMap().cloneProperties(); }
Example #12
Source File: JRJpaQueryExecuter.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
/** * */ public JRJpaQueryExecuter( JasperReportsContext jasperReportsContext, JRDataset dataset, Map<String,? extends JRValueParameter> parameters ) { super(jasperReportsContext, dataset, parameters); em = (EntityManager)getParameterValue(JRJpaQueryExecuterFactory.PARAMETER_JPA_ENTITY_MANAGER); reportMaxCount = (Integer)getParameterValue(JRParameter.REPORT_MAX_COUNT); if (em == null) { log.warn("The supplied javax.persistence.EntityManager object is null."); } parseQuery(); }
Example #13
Source File: JRHibernateQueryExecuter.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
/** * */ public JRHibernateQueryExecuter( JasperReportsContext jasperReportsContext, JRDataset dataset, Map<String, ? extends JRValueParameter> parameters ) { super(jasperReportsContext, dataset, parameters); session = (Session) getParameterValue(JRHibernateQueryExecuterFactory.PARAMETER_HIBERNATE_SESSION); reportMaxCount = (Integer) getParameterValue(JRParameter.REPORT_MAX_COUNT); isClearCache = getPropertiesUtil().getBooleanProperty(dataset, JRHibernateQueryExecuterFactory.PROPERTY_HIBERNATE_CLEAR_CACHE, false); if (session == null) { log.warn("The supplied org.hibernate.Session object is null."); } parseQuery(); }
Example #14
Source File: JRXmlWriter.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
/** * */ private void writeParameter(JRParameter parameter) throws IOException { writer.startElement(JRXmlConstants.ELEMENT_parameter); writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_name, parameter.getName()); writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_class, parameter.getValueClassName()); if(isNewerVersionOrEqual(JRConstants.VERSION_3_1_4)) { writer.addAttribute(JRXmlConstants.ATTRIBUTE_nestedType, parameter.getNestedTypeName()); } writer.addAttribute(JRXmlConstants.ATTRIBUTE_isForPrompting, parameter.isForPrompting(), true); if(isNewerVersionOrEqual(JRConstants.VERSION_6_3_1)) { writer.addAttribute(JRXmlConstants.ATTRIBUTE_evaluationTime, parameter.getEvaluationTime()); } writeProperties(parameter); writer.writeCDATAElement(JRXmlConstants.ELEMENT_parameterDescription, parameter.getDescription()); writeExpression(JRXmlConstants.ELEMENT_defaultValueExpression, parameter.getDefaultValueExpression(), false); writer.closeElement(); }
Example #15
Source File: JRApiWriter.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
/** * */ private void writeParameter( JRParameter parameter, String parameterName) { if(parameter != null) { write( "JRDesignParameter " + parameterName + " = new JRDesignParameter();\n"); write( parameterName + ".setName(\"{0}\");\n", JRStringUtil.escapeJavaStringLiteral(parameter.getName())); write( parameterName + ".setDescription(\"{0}\");\n", JRStringUtil.escapeJavaStringLiteral(parameter.getDescription())); write( parameterName + ".setValueClassName(\"{0}\");\n", parameter.getValueClassName()); write( parameterName + ".setNestedTypeName(\"{0}\");\n", JRStringUtil.escapeJavaStringLiteral(parameter.getNestedTypeName())); write( parameterName + ".setForPrompting({0});\n", parameter.isForPrompting(), true); write( parameterName + ".setEvaluationTime({0});\n", parameter.getEvaluationTime()); writeProperties( parameter, parameterName); writeExpression( parameter.getDefaultValueExpression(), parameterName, "DefaultValueExpression"); flush(); } }
Example #16
Source File: BatchExtractReportServiceImpl.java From kfs with GNU Affero General Public License v3.0 | 6 votes |
/** * @see org.kuali.kfs.module.cab.batch.service.BatchExtractReportService#generateStatusReportPDF(org.kuali.kfs.module.cab.batch.ExtractProcessLog) */ public File generateStatusReportPDF(ExtractProcessLog extractProcessLog) { String reportFileName = cabBatchStatusReportInfo.getReportFileName(); String reportDirectoty = cabBatchStatusReportInfo.getReportsDirectory(); String reportTemplateClassPath = cabBatchStatusReportInfo.getReportTemplateClassPath(); String reportTemplateName = cabBatchStatusReportInfo.getReportTemplateName(); ResourceBundle resourceBundle = cabBatchStatusReportInfo.getResourceBundle(); String subReportTemplateClassPath = cabBatchStatusReportInfo.getSubReportTemplateClassPath(); Map<String, String> subReports = cabBatchStatusReportInfo.getSubReports(); Map<String, Object> reportData = new HashMap<String, Object>(); reportData.put(JRParameter.REPORT_RESOURCE_BUNDLE, resourceBundle); reportData.put(ReportGeneration.PARAMETER_NAME_SUBREPORT_DIR, subReportTemplateClassPath); reportData.put(ReportGeneration.PARAMETER_NAME_SUBREPORT_TEMPLATE_NAME, subReports); String template = reportTemplateClassPath + reportTemplateName; String fullReportFileName = reportGenerationService.buildFullFileName(dateTimeService.getCurrentDate(), reportDirectoty, reportFileName, ""); List<ExtractProcessLog> dataSource = new ArrayList<ExtractProcessLog>(); dataSource.add(extractProcessLog); reportGenerationService.generateReportToPdfFile(reportData, dataSource, template, fullReportFileName); return new File(fullReportFileName + ".pdf"); }
Example #17
Source File: InputStreamImageTest.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void test() { Report report = new Report("net/sf/jasperreports/bands/splittypeprevent/repo/InputStreamImage.jrxml", "net/sf/jasperreports/bands/splittypeprevent/repo/InputStreamImage.reference.jrpxml"); report.init(); Map<String, Object> params = new HashMap<>(); List<Map<String, ?>> records = new ArrayList<>(); records.add(Collections.singletonMap("image", InputStreamImageTest.class.getResourceAsStream("/net/sf/jasperreports/images/tibcosoftware.png"))); records.add(Collections.singletonMap("image", InputStreamImageTest.class.getResourceAsStream("/net/sf/jasperreports/images/jasperreports.png"))); records.add(Collections.singletonMap("image", InputStreamImageTest.class.getResourceAsStream("/net/sf/jasperreports/virtualization/repo/dukesign.jpg"))); params.put(JRParameter.REPORT_DATA_SOURCE, new JRMapCollectionDataSource(records)); report.runReport(params); }
Example #18
Source File: ReportManager.java From jdal with Apache License 2.0 | 6 votes |
/** * Pre-process file. In case this report includes params, display it. * The fact a report has params can be determined at the moment of registering * it the system. At this point, it could be possible to have this information * thus making this process faster * @param report report to process */ public boolean preprocessFile(Report report){ if (log.isDebugEnabled()) log.debug("ReportManager. Preprocess file: hasQuery -> " + report.getHasQuery()); if (report.getHasQuery()) { JasperReport jasperReport = report.newJasperReport(); if (log.isDebugEnabled()) log.debug("Parameters in jasperReport"); Map<String, JRParameter> jrParameters = new HashMap<String, JRParameter>(); for (JRParameter param : jasperReport.getParameters()) { if (!param.isSystemDefined() && param.isForPrompting()){ if (log.isDebugEnabled()) log.debug("Param to fill from paramEntry: " + param.getName()); jrParameters.put(param.getName(), param); } } if (!jrParameters.isEmpty() && interactive) { if (!showParameterDialog(jrParameters)) return false; } } return true; }
Example #19
Source File: JRDesignDataset.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
/** * Inserts a parameter at the specified position into the dataset. * @param index the parameter position * @param parameter the parameter to insert * @throws JRException * @see net.sf.jasperreports.engine.JRDataset#getParameters() */ public void addParameter(int index, JRParameter parameter) throws JRException { if (parametersMap.containsKey(parameter.getName())) { throw new JRException( EXCEPTION_MESSAGE_KEY_DUPLICATE_PARAMETER, new Object[]{parameter.getName()}); } parametersList.add(index, parameter); parametersMap.put(parameter.getName(), parameter); getEventSupport().fireCollectionElementAddedEvent(PROPERTY_PARAMETERS, parameter, index); }
Example #20
Source File: JRDesignDataset.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
/** * Removes a parameter from the dataset. * * @param parameter the parameter to be removed * @return the parameter to be removed */ public JRParameter removeParameter(JRParameter parameter) { if (parameter != null) { int idx = parametersList.indexOf(parameter); if (idx >= 0) { parametersList.remove(idx); parametersMap.remove(parameter.getName()); getEventSupport().fireCollectionElementRemovedEvent(PROPERTY_PARAMETERS, parameter, idx); } } return parameter; }
Example #21
Source File: JRDesignDataset.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
private void sortSystemParamsFirst() { Collections.sort(parametersList, new Comparator<JRParameter>() { @Override public int compare(JRParameter p1, JRParameter p2) { // JRParameter p1 = (JRParameter) o1; // JRParameter p2 = (JRParameter) o2; boolean s1 = p1.isSystemDefined(); boolean s2 = p2.isSystemDefined(); return s1 ? (s2 ? 0 : -1) : (s2 ? 1 : 0); } }); }
Example #22
Source File: JRAbstractCompiler.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
private JRCompilationUnit createCompileUnit(JasperDesign jasperDesign, JRDesignDataset dataset, JRExpressionCollector expressionCollector, File saveSourceDir, String nameSuffix) throws JRException { String unitName = JRAbstractCompiler.getUnitName(jasperDesign, dataset, nameSuffix); JRExpressionCollector datasetCollector = expressionCollector.getCollector(dataset); ReportExpressionsCompilation expressions = expressionsCompiler.getExpressionsCompilation(datasetCollector); JRCompilationUnit compilationUnit = new JRCompilationUnit(unitName); compilationUnit.setDirectEvaluations(expressions.getDirectEvaluations()); ReportSourceCompilation<JRParameter> sourceCompilation = new ReportSourceCompilation<>( jasperReportsContext, jasperDesign, expressions, dataset.getParametersMap(), dataset.getFieldsMap(), dataset.getVariablesMap(), dataset.getVariables()); if (sourceCompilation.hasSource()) { JRSourceCompileTask sourceTask = new JRSourceCompileTask(jasperDesign, unitName, datasetCollector, sourceCompilation, false); JRCompilationSourceCode sourceCode = generateSourceCode(sourceTask); File sourceFile = getSourceFile(saveSourceDir, unitName, sourceCode); compilationUnit.setSource(sourceCode, sourceFile, sourceTask); } return compilationUnit; }
Example #23
Source File: JasperReportsUtil.java From nextreports-server with Apache License 2.0 | 6 votes |
public static LinkedHashMap<String, Serializable> getJasperReportUserParameters(JasperReport jr) { LinkedHashMap<String, Serializable> result = new LinkedHashMap<String, Serializable>(); JRParameter[] params = jr.getParameters(); for (JRParameter p : params) { if (!p.isSystemDefined() && p.isForPrompting()) { JasperParameter jp = new JasperParameter(); jp.setDescription(p.getDescription()); jp.setName(p.getName()); jp.setSystemDefined(p.isSystemDefined()); jp.setValueClassName(p.getValueClassName()); result.put(p.getName(), jp); } } return result; }
Example #24
Source File: BaseReportFiller.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
protected Boolean getOwnIgnorePagination(Map<String,Object> parameterValues, boolean onlySetAttribute) { Boolean isIgnorePaginationParam = (Boolean) parameterValues.get(JRParameter.IS_IGNORE_PAGINATION); if (isIgnorePaginationParam != null) { return isIgnorePaginationParam; } boolean ignorePaginationAttribute = jasperReport.isIgnorePagination(); if (ignorePaginationAttribute) { return ignorePaginationAttribute; } return onlySetAttribute ? null : false; }
Example #25
Source File: JREvaluator.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
/** * Initializes the evaluator by setting the parameter, field and variable objects. * * @param parametersMap the parameters indexed by name * @param fieldsMap the fields indexed by name * @param variablesMap the variables indexed by name * @param resourceMissingType the resource missing type * @throws JRException */ @Override public void init( Map<String, JRFillParameter> parametersMap, Map<String, JRFillField> fieldsMap, Map<String, JRFillVariable> variablesMap, WhenResourceMissingTypeEnum resourceMissingType, boolean ignoreNPE ) throws JRException { whenResourceMissingType = resourceMissingType; this.ignoreNPE = ignoreNPE; resourceBundle = parametersMap.get(JRParameter.REPORT_RESOURCE_BUNDLE); locale = parametersMap.get(JRParameter.REPORT_LOCALE); functions = new HashMap<String, FunctionSupport>(); functionContext = new FillFunctionContext(parametersMap); customizedInit(parametersMap, fieldsMap, variablesMap); if (directExpressionEvaluators != null) { directExpressionEvaluators.init(this, parametersMap, fieldsMap, variablesMap); } }
Example #26
Source File: DatasetSortUtil.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
/** * Returns all current sort field criteria, including the dynamic ones provided as report parameter. */ public static JRSortField[] getAllSortFields(JRFillDataset dataset) { List<JRSortField> allSortFields = new ArrayList<JRSortField>(); JRSortField[] staticSortFields = dataset.getSortFields(); if (staticSortFields != null) { allSortFields.addAll(Arrays.asList(staticSortFields)); } @SuppressWarnings("unchecked") List<JRSortField> dynamicSortFields = (List<JRSortField>)dataset.getParameterValue(JRParameter.SORT_FIELDS, true); if (dynamicSortFields != null) { allSortFields.addAll(dynamicSortFields); } return allSortFields.toArray(new JRSortField[allSortFields.size()]); }
Example #27
Source File: JasperReportEngineInstance.java From Knowage-Server with GNU Affero General Public License v3.0 | 6 votes |
public void setJRBuiltinParameters() { String resourcePath; String entity; resourcePath = EnginConf.getInstance().getResourcePath() + "/img/"; entity = (String) getEnv().get(SpagoBIConstants.SBI_ENTITY); if (entity != null && entity.length() > 0) { resourcePath = resourcePath.concat(entity + "/"); } getEnv().put("SBI_RESOURCE_PATH", resourcePath); // Create the virtualizer if (isVirtualizationEnabled()) { logger.debug("Virtualization of fill process is active"); getEnv().put(JRParameter.REPORT_VIRTUALIZER, getVirtualizer()); } }
Example #28
Source File: TimeoutGovernor.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void beforeDetailEval() throws JRScriptletException { long ellapsedTime = System.currentTimeMillis() - startTime; if (timeout < ellapsedTime) { throw new TimeoutGovernorException( ((JasperReport)getParameterValue(JRParameter.JASPER_REPORT, false)).getName(), timeout ); } }
Example #29
Source File: JRFillDataset.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
/** * Sets the JDBC connection to be used. * * @param parameterValues the parameter values * @param conn the connection */ public void setConnectionParameterValue(Map<String,Object> parameterValues, Connection conn) { useConnectionParamValue = true; if (conn != null) { parameterValues.put(JRParameter.REPORT_CONNECTION, conn); } }
Example #30
Source File: JRVerifier.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
/** * */ private void verifyParameters(JRDesignDataset dataset) { JRParameter[] parameters = dataset.getParameters(); if (parameters != null && parameters.length > 0) { for(int index = 0; index < parameters.length; index++) { JRParameter parameter = parameters[index]; Object errorSource = parameter; if (parameter.isSystemDefined()) { errorSource = jasperDesign; } if (parameter.getName() == null || parameter.getName().trim().length() == 0) { addBrokenRule("Parameter name missing.", errorSource); } if (parameter.getValueClassName() == null) { addBrokenRule("Class not set for parameter : " + parameter.getName(), errorSource); } } } }