⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 editchartaction.java

📁 The ability to create groups of reports, and grant users access to reports by group. The ability to
💻 JAVA
字号:
/*
 * Copyright (C) 2003 Erik Swenson - eswenson@opensourcesoft.net
 * 
 * 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 org.efs.openreports.actions.admin;

import java.util.*;
import java.util.HashMap;
import java.util.List;

import com.opensymphony.xwork.ActionSupport;

import org.apache.log4j.Logger;

import org.efs.openreports.objects.ReportChart;
import org.efs.openreports.objects.ReportParameter;
import org.efs.openreports.objects.chart.ChartValue;
import org.efs.openreports.providers.*;
import org.efs.openreports.util.ORUtil;

public class EditChartAction extends ActionSupport
		implements
			DataSourceProviderAware,
			ChartProviderAware,
			ParameterProviderAware
{
	protected static Logger log =
		Logger.getLogger(EditChartAction.class);

	private String command;
	
	private boolean submitOk;
	private boolean submitValidate;

	private int id;
	private String name;
	private String description;
	private String query;
	private int dataSourceId = Integer.MIN_VALUE;	
	private int chartType;
	private int width;
	private int height;
	private String xAxisLabel;
	private String yAxisLabel;

	private ReportChart reportChart;		
	private ChartValue[] chartValues;

	private DataSourceProvider dataSourceProvider;
	private ChartProvider chartProvider;
	private ParameterProvider parameterProvider;

	public String execute()
	{
		try
		{
			if (command.equals("edit"))
			{
				reportChart =
					chartProvider.getReportChart(new Integer(id));
			}
			else
			{
				reportChart = new ReportChart();
			}

			if (command.equals("edit") && !submitOk && !submitValidate)
			{
				name = reportChart.getName();
				description = reportChart.getDescription();
				query = reportChart.getQuery();				
				chartType = reportChart.getChartType();
				width = reportChart.getWidth();
				height = reportChart.getHeight();
				xAxisLabel = reportChart.getXAxisLabel();
				yAxisLabel = reportChart.getYAxisLabel();
				id = reportChart.getId().intValue();
				if (reportChart.getDataSource() != null)
				{
					dataSourceId =
						reportChart.getDataSource().getId().intValue();
				}			
			}

			if (!submitOk && !submitValidate)
				return INPUT;

			reportChart.setName(name);
			reportChart.setDescription(description);
			reportChart.setQuery(query);		
			reportChart.setChartType(chartType);
			reportChart.setWidth(width);
			reportChart.setHeight(height);
			reportChart.setXAxisLabel(xAxisLabel);
			reportChart.setYAxisLabel(yAxisLabel);
			if (dataSourceId != -1)
				reportChart.setDataSource(
					dataSourceProvider.getDataSource(
						new Integer(dataSourceId)));			
			
			if (submitValidate)
			{
				Map map = new HashMap();
				if (query.toUpperCase().indexOf("$P") > -1)
				{
					map = ORUtil.buildQueryParameterMap(query, parameterProvider);
				}
				
				chartValues = chartProvider.getChartValues(reportChart, map);

				return INPUT;
			}			

			if (command.equals("edit"))
			{
				chartProvider.updateReportChart(reportChart);
			}

			if (command.equals("add"))
			{
				chartProvider.insertReportChart(reportChart);
			}

			return SUCCESS;
		}
		catch (Exception e)
		{
			addActionError(e.getMessage());
			return INPUT;
		}
	}

	public String getCommand()
	{
		return command;
	}

	public void setCommand(String command)
	{
		this.command = command;
	}	
	
	public void setSubmitOk(String submitOk)
	{
		if (submitOk != null) this.submitOk = true;
	}
	
	public void setSubmitValidate(String submitValidate)
	{
		if (submitValidate != null) this.submitValidate = true;
	}
	
	public int getDataSourceId()
	{
		return dataSourceId;
	}

	public String getName()
	{
		return name;
	}

	public void setDataSourceId(int dataSourceId)
	{
		this.dataSourceId = dataSourceId;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public List getDataSources()
	{
		try
		{
			return dataSourceProvider.getDataSources();
		}
		catch (Exception e)
		{
			addActionError(e.getMessage());
			return null;
		}
	}

	public String[] getTypes()
	{
		return ReportParameter.TYPES;
	}

	public String[] getClassNames()
	{
		return ReportParameter.CLASS_NAMES;
	}

	public int getId()
	{
		return id;
	}

	public void setId(int id)
	{
		this.id = id;
	}	

	public void setDataSourceProvider(DataSourceProvider dataSourceProvider)
	{
		this.dataSourceProvider = dataSourceProvider;
	}	

	public String getDescription()
	{
		return description;
	}

	public void setDescription(String description)
	{
		this.description = description;
	}	

	public void setChartProvider(ChartProvider chartProvider)
	{
		this.chartProvider = chartProvider;
	}

	public String getQuery()
	{
		return query;
	}

	public void setQuery(String query)
	{
		this.query = query;
	}	

	public int getChartType()
	{
		return chartType;
	}

	public void setChartType(int chartType)
	{
		this.chartType = chartType;
	}

	public int getHeight()
	{
		return height;
	}

	public void setHeight(int height)
	{
		this.height = height;
	}

	public int getWidth()
	{
		return width;
	}

	public void setWidth(int width)
	{
		this.width = width;
	}

	public ChartValue[] getChartValues()
	{
		return chartValues;
	}

	public String getXAxisLabel()
	{
		return xAxisLabel;
	}

	public void setXAxisLabel(String axisLabel)
	{
		xAxisLabel = axisLabel;
	}

	public String getYAxisLabel()
	{
		return yAxisLabel;
	}

	public void setYAxisLabel(String axisLabel)
	{
		yAxisLabel = axisLabel;
	}

	public void setParameterProvider(ParameterProvider parameterProvider)
	{
		this.parameterProvider = parameterProvider;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -