public ProcessDirector(JasperReportsContext jasperReportsContext, ScriptManager scriptManager) { JRPropertiesUtil properties = JRPropertiesUtil.getInstance(jasperReportsContext); this.phantomjsExecutablePath = properties.getProperty(PhantomJS.PROPERTY_PHANTOMJS_EXECUTABLE_PATH); this.processStartTimeout = properties.getIntegerProperty(PhantomJS.PROPERTY_PHANTOMJS_START_TIMEOUT, PhantomJS.DEFAULT_PHANTOMJS_START_TIMEOUT); this.idlePingInterval = properties.getIntegerProperty(PhantomJS.PROPERTY_PHANTOMJS_IDLE_PING_INTERVAL, PhantomJS.DEFAULT_PHANTOMJS_IDLE_PING_INTERVAL); this.requestTimeout = properties.getIntegerProperty(PhantomJS.PROPERTY_PHANTOMJS_REQUEST_TIMEOUT, PhantomJS.DEFAULT_PHANTOMJS_REQUEST_TIMEOUT); this.scriptManager = scriptManager; if (this.phantomjsExecutablePath != null) { this.listenAddress = InetUtil.getIPv4Loopback(); if (this.listenAddress == null) { log.error("Unable to determine an IPv4 loopback address"); } } processPool = createProcessPool(properties); }
/** * Fills a report. * <p/> * The data source used to fill the report is determined in the following way: * <ul> * <li>If a non-null value of the {@link net.sf.jasperreports.engine.JRParameter#REPORT_DATA_SOURCE REPORT_DATA_SOURCE} * has been specified, it will be used as data source.</li> * <li>Otherwise, if the report has a query then a data source will be created based on the query and connection * parameter values.</li> * <li>Otherwise, the report will be filled without a data source.</li> * </ul> * * @param jasperReport the report * @param parameters the fill parameters * @return the filled report * @throws JRException */ public static JasperPrint fill( JasperReportsContext jasperReportsContext, JasperReport jasperReport, Map<String,Object> parameters ) throws JRException { ReportFiller filler = createReportFiller(jasperReportsContext, jasperReport); try { JasperPrint jasperPrint = filler.fill(parameters); return jasperPrint; } catch (JRFillInterruptedException e) { throw new JRException( EXCEPTION_MESSAGE_KEY_THREAD_INTERRUPTED, null, e); } }
@Override public byte[] getData(JasperReportsContext jasperReportsContext) throws JRException { ensureData(jasperReportsContext); if (svgText != null) { try { return svgText.getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { throw new JRRuntimeException(e); } } else { return svgData; } }
/** * Applies generic element transformers of a specific key to a filled report * by replacing generic elements with the transformed elements. * * @param report the report * @param transformerExportKey the key used to resolve element transformers * @see GenericElementTransformer * @see GenericElementHandlerBundle#getHandler(String, String) */ public static void transformGenericElements( JasperReportsContext jasperReportsContext, JasperPrint report, String transformerExportKey ) { TransformerContext transformerContext = new TransformerContext(jasperReportsContext, report); List<JRPrintPage> pages = report.getPages(); for (Iterator<JRPrintPage> pageIt = pages.iterator(); pageIt.hasNext();) { JRPrintPage page = pageIt.next(); transformElements(transformerContext, transformerExportKey, page.getElements()); } }
/** * */ protected DocxTableHelper( JasperReportsContext jasperReportsContext, Writer writer, CutsInfo xCuts, boolean pageBreak, PrintPageFormat pageFormat, JRPrintElementIndex frameIndex ) { super(jasperReportsContext, writer); this.xCuts = xCuts; this.cellHelper = new DocxCellHelper(jasperReportsContext, writer); this.paragraphHelper = new DocxParagraphHelper(jasperReportsContext, writer, pageBreak); this.pageFormat = pageFormat; this.frameIndex = frameIndex; }
private void initExcludeProperties() { JasperReportsContext context = jasperReportsContext == null ? DefaultJasperReportsContext.getInstance() : jasperReportsContext; List<PropertySuffix> excludeProperties = JRPropertiesUtil.getInstance(context).getProperties( PREFIX_EXCLUDE_PROPERTIES); excludePropertiesPattern = new ArrayList<Pattern>(excludeProperties.size()); for (PropertySuffix propertySuffix : excludeProperties) { String regex = propertySuffix.getValue(); Pattern pattern = Pattern.compile(regex); excludePropertiesPattern.add(pattern); } excludeUuids = JRPropertiesUtil.getInstance(context).getBooleanProperty(PROPERTY_EXCLUDE_UUIDS); }
@Override public Dimension2D getDimension(JasperReportsContext jasperReportsContext) { if (rotation != null) { switch(rotation) { case LEFT: case RIGHT: return new Dimension((int)barcode.getSize().getHeight(),(int)barcode.getSize().getWidth()); default: return barcode.getSize(); } } else { return barcode.getSize(); } }
/** * @deprecated Replaced by {@link #SimpleFontFace(JasperReportsContext)} and {@link #setTtf(String)}. */ public static SimpleFontFace getInstance(JasperReportsContext jasperReportsContext, String fontName) { SimpleFontFace fontFace = null; if (fontName != null) { fontFace = new SimpleFontFace(jasperReportsContext); fontFace.setTtf(fontName); } return fontFace; }
@Override protected void setJasperReportsContext(JasperReportsContext jasperReportsContext) { super.setJasperReportsContext(jasperReportsContext); this.styleResolver = new StyleResolver(jasperReportsContext); }
private List<FieldFilter> getExistingFiltersForField( JasperReportsContext jasperReportsContext, ReportContext reportContext, String uuid, String filterFieldName ) { JasperDesignCache cache = JasperDesignCache.getInstance(jasperReportsContext, reportContext); FilterAction action = new FilterAction(); action.init(jasperReportsContext, reportContext); CommandTarget target = action.getCommandTarget(UUID.fromString(uuid)); List<FieldFilter> result = new ArrayList<FieldFilter>(); if (target != null) { JasperDesign jasperDesign = cache.getJasperDesign(target.getUri()); JRDesignDataset dataset = (JRDesignDataset)jasperDesign.getMainDataset(); // get existing filter as JSON string String serializedFilters = "[]"; JRPropertiesMap propertiesMap = dataset.getPropertiesMap(); if (propertiesMap.getProperty(FilterCommand.DATASET_FILTER_PROPERTY) != null) { serializedFilters = propertiesMap.getProperty(FilterCommand.DATASET_FILTER_PROPERTY); } List<? extends DatasetFilter> existingFilters = JacksonUtil.getInstance(jasperReportsContext).loadList(serializedFilters, FieldFilter.class); if (existingFilters.size() > 0) { for (DatasetFilter filter: existingFilters) { if (((FieldFilter)filter).getField().equals(filterFieldName)) { result.add((FieldFilter)filter); break; } } } } return result; }
/** * */ public ParameterOverriddenResolver( JasperReportsContext jasperReportsContext, JasperPrint jasperPrint, Map<net.sf.jasperreports.engine.JRExporterParameter, Object> parameters ) { this.propertiesUtil = JRPropertiesUtil.getInstance(jasperReportsContext); this.jasperPrint = jasperPrint; this.parameters = parameters; }
protected List<ExporterFilterFactory> getAllFilterFactories(JasperReportsContext jasperReportsContext, JasperPrint report) throws JRException { List<JRPropertiesUtil.PropertySuffix> factoryProps = JRPropertiesUtil.getInstance(jasperReportsContext).getAllProperties(report, PROPERTY_EXPORTER_FILTER_FACTORY_PREFIX); List<ExporterFilterFactory> factories = new ArrayList<ExporterFilterFactory>(factoryProps.size()); for (Iterator<JRPropertiesUtil.PropertySuffix> it = factoryProps.iterator(); it.hasNext();) { JRPropertiesUtil.PropertySuffix prop = it.next(); ExporterFilterFactory factory = getFilterFactory(prop.getValue()); factories.add(factory); } return factories; }
/** * */ public static HtmlFont getInstance(JasperReportsContext jasperReportsContext, String htmlFontId) { int localeSeparatorPos = htmlFontId.lastIndexOf(LOCALE_SEPARATOR); String faceName = htmlFontId.substring(0, localeSeparatorPos); boolean isBold = false; boolean isItalic = false; if (faceName.endsWith("-Italic")) { faceName = faceName.substring(0, faceName.length() - "-Italic".length()); isItalic = true; } if (faceName.endsWith("-Bold")) { faceName = faceName.substring(0, faceName.length() - "-Bold".length()); isBold = true; } if (faceName.endsWith("-BoldItalic")) { faceName = faceName.substring(0, faceName.length() - "-BoldItalic".length()); isItalic = true; isBold = true; } String localeCode = htmlFontId.substring(localeSeparatorPos + LOCALE_SEPARATOR.length()); Locale locale = JRDataUtils.getLocale(localeCode); FontInfo fontInfo = FontUtil.getInstance(jasperReportsContext).getFontInfo(faceName, locale); return getInstance(locale, fontInfo, isBold, isItalic); }
private EditTextElementData setColumnValueData(Integer columnIndex, CommandTarget target, Map<String, Object> contextMap, JasperReportsContext jasperReportsContext, ReportContext reportContext, Locale locale) { EditTextElementData textElementData = new EditTextElementData(); if (target != null){ JRIdentifiable identifiable = target.getIdentifiable(); JRDesignComponentElement componentElement = identifiable instanceof JRDesignComponentElement ? (JRDesignComponentElement)identifiable : null; StandardTable table = componentElement == null ? null : (StandardTable)componentElement.getComponent(); List<BaseColumn> tableColumns = TableUtil.getAllColumns(table); if (columnIndex != null) { StandardColumn column = (StandardColumn) tableColumns.get(columnIndex); JRDesignTextField textElement = TableUtil.getCellElement(JRDesignTextField.class, column.getDetailCell(), true); if (textElement != null) { textElementData.setColumnIndex(columnIndex); JRDesignTextElement styledElement = resolveElementStyle(textElement, reportContext, target); HeaderToolbarElementUtils.copyTextElementStyle(textElementData, styledElement, locale); } } } contextMap.put("colValueData", JacksonUtil.getInstance(jasperReportsContext).getJsonString(textElementData)); return textElementData; }
@Override public void performAction() throws ActionException { if (searchData != null && searchData.getSearchString() != null && searchData.getSearchString().length() > 0) { JasperReportsContext jasperReportsContext = getJasperReportsContext(); ReportContext reportContext = getReportContext(); JasperPrintAccessor jasperPrintAccessor = (JasperPrintAccessor) reportContext.getParameterValue( WebReportContext.REPORT_CONTEXT_PARAMETER_JASPER_PRINT_ACCESSOR); JasperPrint jasperPrint = jasperPrintAccessor.getFinalJasperPrint(); LuceneUtil luceneUtil = new LuceneUtil(jasperReportsContext, searchData.isCaseSensitive(), searchData.isWholeWordsOnly(), searchData.isRemoveAccents()); try { SpansInfo spansInfo = luceneUtil.getSpansInfo(jasperPrint, searchData.getSearchString()); reportContext.setParameterValue("net.sf.jasperreports.search.term.highlighter", spansInfo); ObjectMapper mapper = new ObjectMapper(); ObjectNode result = mapper.createObjectNode(); Map<String, Integer> hitTermsPerPage = spansInfo.getHitTermsPerPage(); result.put("searchString", searchData.getSearchString()); if (hitTermsPerPage.size() > 0) { ArrayNode arrayNode = mapper.createArrayNode(); ObjectNode item; result.put("searchResults", arrayNode); for (Map.Entry<String, Integer> entry: hitTermsPerPage.entrySet()) { item = mapper.createObjectNode(); item.put("page", Integer.parseInt(entry.getKey()) + 1); item.put("hitCount", entry.getValue()/spansInfo.getTermsPerQuery()); arrayNode.add(item); } } reportContext.setParameterValue("net.sf.jasperreports.web.actions.result.json", result); } catch (Exception e) { throw new ActionException(e); } } }
/** * */ protected JRCsvQueryExecuter( JasperReportsContext jasperReportsContext, JRDataset dataset, Map<String, ? extends JRValueParameter> parametersMap ) { super(jasperReportsContext, dataset, parametersMap); }
/** * */ public JRCsvMetadataExporter(JasperReportsContext jasperReportsContext) { super(jasperReportsContext); exporterContext = new ExporterContext(); }
/** * */ public XlsxDrawingHelper(JasperReportsContext jasperReportsContext, Writer writer, XlsxDrawingRelsHelper drawingRelsHelper) { super(jasperReportsContext, writer); this.drawingRelsHelper = drawingRelsHelper; }
public JRXmlDataSource( JasperReportsContext jasperReportsContext, InputStream in, String selectExpression, boolean isNamespaceAware ) throws JRException { this(jasperReportsContext, JRXmlUtils.parse(new InputSource(in), isNamespaceAware), selectExpression); this.inputStream = in; this.closeInputStream = false; }
@Override public JRQueryExecuter createQueryExecuter( JasperReportsContext jasperReportsContext, JRDataset dataset, Map<String,? extends JRValueParameter> parameters ) throws JRException { return new JRXPathQueryExecuter(jasperReportsContext, dataset, parameters); }
/** * */ public JRSingleSheetXlsSaveContributor( JasperReportsContext jasperReportsContext, Locale locale, ResourceBundle resBundle ) { super(jasperReportsContext, locale, resBundle); }
/** * */ protected AbstractXlsQueryExecuter( JasperReportsContext jasperReportsContext, JRDataset dataset, Map<String,? extends JRValueParameter> parametersMap ) { super(jasperReportsContext, dataset, parametersMap); }
/** * */ public XlsxStyleHelper( JasperReportsContext jasperReportsContext, Writer writer, String exporterKey ) { super(jasperReportsContext, writer); formatHelper = new XlsxFormatHelper(jasperReportsContext, formatsWriter); fontHelper = new XlsxFontHelper(jasperReportsContext, fontsWriter, exporterKey); borderHelper = new XlsxBorderHelper(jasperReportsContext ,bordersWriter); }
@Override public JRQueryExecuter createQueryExecuter( JasperReportsContext jasperReportsContext, JRDataset dataset, Map<String,? extends JRValueParameter> parameters ) throws JRException { return new JRMondrianQueryExecuter(jasperReportsContext, dataset, parameters); }
/** * */ public JRCsvSaveContributor( JasperReportsContext jasperReportsContext, Locale locale, ResourceBundle resBundle ) { super(jasperReportsContext, locale, resBundle); }
/** * */ public List<FontFamily> loadFontFamilies(JasperReportsContext jasperReportsContext, InputStream is) { FontExtensionsCollector collector = new FontExtensionsCollector(); loadFontExtensions(jasperReportsContext, is, collector); return collector.getFontFamilies(); }
/** * */ public JROdsExporter(JasperReportsContext jasperReportsContext) { super(jasperReportsContext); exporterContext = new ExporterContext(null); }
protected SAXParser createParser(JasperReportsContext jasperReportsContext) { String parserFactoryClass = JRPropertiesUtil.getInstance(jasperReportsContext).getProperty( JRSaxParserFactory.PROPERTY_TEMPLATE_PARSER_FACTORY); if (log.isDebugEnabled()) { log.debug("Using template SAX parser factory class " + parserFactoryClass); } JRSaxParserFactory factory = BaseSaxParserFactory.getFactory(jasperReportsContext, parserFactoryClass); return factory.createParser(); }
/** * */ public static void viewReportDesign( JasperReportsContext jasperReportsContext, InputStream is, boolean isXML ) throws JRException { JasperDesignViewer jasperDesignViewer = new JasperDesignViewer(jasperReportsContext, is, isXML); jasperDesignViewer.setVisible(true); }
/** * */ public static void viewReportDesign( JasperReportsContext jasperReportsContext, JRReport report ) throws JRException { JasperDesignViewer jasperDesignViewer = new JasperDesignViewer(jasperReportsContext, report); jasperDesignViewer.setVisible(true); }
public JsonQLDataSourceProvider(JasperReportsContext jasperReportsContext, String jsonSource, String queryString, TextDataSourceAttributes textAttributes) { this.jasperReportsContext = jasperReportsContext; this.jsonSource = jsonSource; this.queryString = queryString; this.textAttributes = textAttributes; }
/** * */ public JasperViewer( JasperReportsContext jasperReportsContext, String sourceFile, boolean isXMLFile, boolean isExitOnClose ) throws JRException { this(jasperReportsContext, sourceFile, isXMLFile, isExitOnClose, null, null); }
@Override public JRQueryExecuter createQueryExecuter( JasperReportsContext jasperReportsContext, JRDataset dataset, Map<String, ? extends JRValueParameter> parameters ) throws JRException { return new Olap4jXmlaQueryExecuter(jasperReportsContext, dataset, parameters); }
public BatikAWTFontFamily( JasperReportsContext jasperReportsContext, String familyName ) { super(familyName); this.jasperReportsContext = jasperReportsContext; }
public void setJasperReportsContext(JasperReportsContext jasperReportsContext) { this.jasperReportsContext = jasperReportsContext; if (jasperReportsContext != null) { this.propertiesUtil = JRPropertiesUtil.getInstance(jasperReportsContext); } }
/** * */ public JRTextExporter(JasperReportsContext jasperReportsContext) { super(jasperReportsContext); exporterContext = new ExporterContext(); }
/** * */ public FrameDrawer( JasperReportsContext jasperReportsContext, ExporterFilter filter, PrintDrawVisitor drawVisitor ) { super(jasperReportsContext); this.filter = filter; this.drawVisitor = drawVisitor; }
@Override public void render( JasperReportsContext jasperReportsContext, Graphics2D grx, Rectangle2D rectangle ) throws JRException { grxRenderable.render(jasperReportsContext, grx, rectangle); }
/** * */ protected JRXlsxQueryExecuter( JasperReportsContext jasperReportsContext, JRDataset dataset, Map<String,? extends JRValueParameter> parametersMap ) { super(jasperReportsContext, dataset, parametersMap); }
/** * */ public XYChartXmlWriter(JasperReportsContext jasperReportsContext) { super(jasperReportsContext); }