Java Code Examples for org.eclipse.birt.report.engine.api.EngineConfig#setTempDir()

The following examples show how to use org.eclipse.birt.report.engine.api.EngineConfig#setTempDir() . 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: ReportEngineTest.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Test getConfig() method
 */
public void testGetConfig( )
{
	EngineConfig config = new EngineConfig( );
	config.setTempDir( "tempdir" );
	ReportEngine engine = new ReportEngine( config );
	EngineConfig configGet = engine.getConfig( );
	assertEquals( "getConfig() fail", config.getTempDir( ), configGet
			.getTempDir( ) );
}
 
Example 2
Source File: ReportEngineTest.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Test openReportDesign(string)
 * 
 * @throws EngineException
 */
public void testOpenReportDesign( ) throws EngineException
{
	EngineConfig config = new EngineConfig( );
	IReportRunnable reportRunner;
	config.setTempDir( "tempdir" );
	ReportEngine engine = new ReportEngine( config );
	/*
	 * String input =
	 * PLUGIN_PATH+System.getProperty("file.separator")+RESOURCE_BUNDLE
	 * .getString("CASE_INPUT"); input +=
	 * System.getProperty("file.separator") ; String
	 * designName=input+"report_engine.rptdesign";
	 */
	String designName = this.genInputFile( "report_engine.rptdesign" );

	try
	{
		reportRunner = engine.openReportDesign( designName );
		designName = "file:" + designName;
		designName = designName.replace( '/', '\\' );
		String reportName = reportRunner.getReportName( ).replace(
				'/',
				'\\' );
		assertEquals( "openReportDesign(String) fail", designName
				.substring( designName.indexOf( "org" ), designName
						.length( ) ), reportName.substring( reportName
				.indexOf( "org" ), reportName.length( ) ) );
		assertNotNull( "openReportDesign(String) fail", reportRunner
				.getImage( "23.gif" ) );
	}
	catch ( EngineException ee )
	{
		ee.printStackTrace( );
		fail( "openReportDesign(String) fail" );
	}
	engine.destroy( );

}
 
Example 3
Source File: ReportEngineTest.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Test openReportDesign(inputStream)
 */
public void testOpenReportDesign1( )
{
	EngineConfig config = new EngineConfig( );
	IReportRunnable reportRunner;
	config.setTempDir( "tempdir" );
	ReportEngine engine = new ReportEngine( config );
	/*
	 * String input =
	 * PLUGIN_PATH+System.getProperty("file.separator")+RESOURCE_BUNDLE
	 * .getString("CASE_INPUT"); input +=
	 * System.getProperty("file.separator") ; String
	 * designName=input+"report_engine.rptdesign";
	 */

	String designName = this.genInputFile( "report_engine.rptdesign" );

	try
	{
		File file = new File( designName );
		FileInputStream fis = new FileInputStream( file );
		reportRunner = engine.openReportDesign( fis );
		assertEquals(
				"openReportDesign(InputStream) fail",
				"<stream>",
				reportRunner.getReportName( ) );
		assertNotNull( "openReportDesign(InputStream) fail", reportRunner
				.getImage( "23.gif" ) );
	}
	catch ( EngineException ee )
	{
		ee.printStackTrace( );
	}
	catch ( FileNotFoundException fe )
	{
		fe.printStackTrace( );
	}
	engine.destroy( );

}
 
Example 4
Source File: BirtEngine.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Gets the birt engine.
 *
 * @param request
 *            the request
 * @param sc
 *            the sc
 *
 * @return the birt engine
 */
public static synchronized IReportEngine getBirtEngine(HttpServletRequest request, ServletContext sc) {
	logger.debug("IN");
	// birtEngine = null;
	if (birtEngine == null) {
		EngineConfig config = new EngineConfig();
		if (configProps != null && !configProps.isEmpty()) {
			String logLevel = configProps.getProperty("logLevel");
			Level level = Level.OFF;
			if ("SEVERE".equalsIgnoreCase(logLevel)) {
				level = Level.SEVERE;
			} else if ("WARNING".equalsIgnoreCase(logLevel)) {
				level = Level.WARNING;
			} else if ("INFO".equalsIgnoreCase(logLevel)) {
				level = Level.INFO;
			} else if ("CONFIG".equalsIgnoreCase(logLevel)) {
				level = Level.CONFIG;
			} else if ("FINE".equalsIgnoreCase(logLevel)) {
				level = Level.FINE;
			} else if ("FINER".equalsIgnoreCase(logLevel)) {
				level = Level.FINER;
			} else if ("FINEST".equalsIgnoreCase(logLevel)) {
				level = Level.FINEST;
			} else if ("ALL".equalsIgnoreCase(logLevel)) {
				level = Level.ALL;
			} else if ("OFF".equalsIgnoreCase(logLevel)) {
				level = Level.OFF;
			}

			String logDir = configProps.getProperty("logDirectory");
			logDir = Utils.resolveSystemProperties(logDir);
			logger.debug("Birt LOG Dir:" + logDir);
			logger.debug("Log config: logDirectory = [" + logDir + "]; level = [" + level + "]");
			config.setLogConfig(logDir, level);
		}

		/*
		 * DefaultResourceLocator drl=new DefaultResourceLocator(); drl.findResource(birtEngine.openReportDesign(arg0), "messages_it_IT.properties",
		 * DefaultResourceLocator.MESSAGE_FILE);
		 */
		// Commented for Birt 3.7 Upgrade see: http://wiki.eclipse.org/Birt_3.7_Migration_Guide#BIRT_3.7_API_Changes
		// config.setEngineHome("");
		IPlatformContext context = new PlatformServletContext(sc);
		config.setPlatformContext(context);
		config.setTempDir(System.getProperty("java.io.tmpdir") + "/birt/");

		// ParameterAccessor.initParameters(sc);
		// config.setResourcePath(ParameterAccessor.getResourceFolder(request));
		// Prepare ScriptLib location
		String scriptLibDir = ParameterAccessor.scriptLibDir;
		ArrayList jarFileList = new ArrayList();
		if (scriptLibDir != null) {
			File dir = new File(scriptLibDir);
			getAllJarFiles(dir, jarFileList);
		}
		String scriptlibClassPath = ""; //$NON-NLS-1$
		for (int i = 0; i < jarFileList.size(); i++)
			scriptlibClassPath += EngineConstants.PROPERTYSEPARATOR + ((File) jarFileList.get(i)).getAbsolutePath();
		if (scriptlibClassPath.startsWith(EngineConstants.PROPERTYSEPARATOR))
			scriptlibClassPath = scriptlibClassPath.substring(EngineConstants.PROPERTYSEPARATOR.length());
		config.setProperty(EngineConstants.WEBAPP_CLASSPATH_KEY, scriptlibClassPath);

		try {
			Platform.startup(config);
			logger.debug("Birt Platform started");
		} catch (BirtException e) {
			logger.error("Error during Birt Platform start-up", e);
		}

		IReportEngineFactory factory = (IReportEngineFactory) Platform.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);
		birtEngine = factory.createReportEngine(config);
		logger.debug("Report engine created");

	}
	return birtEngine;
}