BaseJDBCDataset.java :  » Portal » stringbeans-3.5 » com » nabhinc » portlet » chart » Java Open Source

Java Open Source » Portal » stringbeans 3.5 
stringbeans 3.5 » com » nabhinc » portlet » chart » BaseJDBCDataset.java
/* 
 * (C) Copyright 2000 - 2003 Nabh Information Systems, Inc. 
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License 
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 * 
 */

package com.nabhinc.portlet.chart;

import javax.portlet.PortletConfig;
import javax.portlet.PortletException;

import org.jfree.data.AbstractDataset;


/**
 * 
 *
 * @author Padmanabh Dabke
 * (c) 2002, 2003 Nabh Information Systems, Inc. All Rights Reserved.
 */
public abstract class BaseJDBCDataset extends AbstractDataset implements ChartDataSource {

  public static final String DATA_SOURCE_INIT_PARAM = "dataSource";
  public static final String SQL_INIT_PARAM = "sql";
  
  /**
   * JNDI name of the data source
   */
  protected String bjdsDataSource = null;
  
  /**
   * SQL query
   */
  protected String bjdsSQL = null;
  
  public abstract void executeQuery() throws PortletException;
  public abstract void createDummyData();
  
  public void retrieveChartData() throws PortletException {
    if (bjdsSQL != null) executeQuery();
    else createDummyData();
  }
  
  /**
   * Initalizes data and executes database query to populate the dataset.
   * @param datasource Database datasource, e.g. jdbc/sbtour
   * @param config SQL query command.
   */
  public void init(PortletConfig config) throws PortletException {
    
    // Get data source configuration.
    bjdsDataSource = config.getInitParameter(DATA_SOURCE_INIT_PARAM);
    if (bjdsDataSource == null) {
      
      throw new PortletException (
        "Missing required chart data source init parameter: " + 
        DATA_SOURCE_INIT_PARAM);
    
    }
    bjdsSQL = config.getInitParameter(SQL_INIT_PARAM);
    
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.