/*
 * @(#)SingleTableGraphTag.java
 *
 * Copyright 2001-2002 by Oracle Corporation,
 * 500 Oracle Parkway, Redwood Shores, California, 94065, U.S.A.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information
 * of Oracle Corporation.
 */

package oracle.jbo.html.jsp.graph;

import oracle.dss.util.CubeDataDirector;
import oracle.dss.util.DataSource;
import oracle.dss.util.RelationalDataDirector;

import oracle.jbo.RowSetIterator;

/**
 *  Data source for the BI Graph bean. This binding may be used
 *  for Graph which requires one value per marker. A Pie chart 
 *  for example requires one value per marker. Each column in the 
 *  table (ViewObject) represents a Group in the Graph. Each row in
 *  table (ViewObject) represents a series in the Graph.
 * 
 *  @see MasterDetailGraphTag
 */
public class SingleTableGraphTag
      extends GraphDataFromRow
      implements DataSource
{
    protected BIBeanDataAccessAdapter mAdapter;

    public SingleTableGraphTag()
    {
       logDebug("SingleTableGraphTag");
    
	   init();
    }

    protected void init()
    {
	   mAdapter = createAdapter();
    }

  
    // Implement DataSource interface
    public RelationalDataDirector createRelationalDataDirector() 
    {
        return mAdapter;
    }
    
    public CubeDataDirector createCubeDataDirector() 
    {
        return mAdapter;
    }

    // abstract methods
    protected oracle.dss.util.DataSource getGraphDataSource()
    {
	    return this;
    }

    protected void refreshView()
    {
	   super.refreshBIBeanAdapter(getAdapter());
    }

    protected void rsiChanged(RowSetIterator rsi, GraphTagBase graphTag)
    {
  	   logDebug("SingleTableGraphTag"); 

	   super.setRowSetIterator(rsi);	

           rsi.setRangeSize(-1);
     }


    
    // private methods
    private BIBeanDataAccessAdapter createAdapter()
    {
	   return new BIBeanDataAccessAdapter(this);
    }

    private BIBeanDataAccessAdapter getAdapter()
    {
	   return mAdapter;
    }

}

