
package org.eclipse.birt.test.performance.parser;

import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * Configuration - initialize config. variables of this test suite
 */
public class Configuration
{

	private static Configuration instance = new Configuration( );

	private Map reportdesigns = new LinkedHashMap( );
	private Map testcases = new LinkedHashMap( );
	private String suiteName = null;

	private Configuration( )
	{
	}

	public static Configuration getInstance( )
	{
		return instance;
	}

	public void addReportDesign( ReportDesignNode report )
	{
		this.reportdesigns.put( report.id, report );
	}

	public ReportDesignNode getReportDesign( String id )
	{
		return (ReportDesignNode) this.reportdesigns.get( id );
	}

	public Map getReportDesigns( )
	{
		return this.reportdesigns;
	}

	/**
	 * Get a test case by the name.
	 * 
	 * @param name
	 * @return
	 */
	public TestCaseNode getTestCase( String name )
	{
		return (TestCaseNode) this.testcases.get( name );
	}

	public void addTestCase( TestCaseNode testcase )
	{
		this.testcases.put( testcase.getName( ), testcase );
	}

	/**
	 * Return all test cases.
	 * 
	 * @return case name to <code>TestCaseNode</code> map.
	 */
	public Map getTestCases( )
	{
		return this.testcases;
	}

	void build( )
	{
		for ( Iterator keys = testcases.keySet( ).iterator( ); keys.hasNext( ); )
		{
			String name = (String) keys.next( );
			TestCaseNode node = (TestCaseNode) testcases.get( name );
			node.build( );
		}
	}

	/**
	 * @return Returns the suiteName.
	 */
	public String getSuiteName( )
	{
		return suiteName;
	}

	/**
	 * @param suiteName
	 *            The suiteName to set.
	 */
	public void setSuiteName( String suiteName )
	{
		this.suiteName = suiteName;
	}

}