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

📄 editreportparameteraction.java

📁 OpenReports是一个完整的基于Web的报表方案
💻 JAVA
字号:
/*
 * Copyright (C) 2002 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.List;

import com.opensymphony.xwork.ActionSupport;

import org.apache.log4j.Logger;

import org.efs.openreports.objects.ReportParameter;
import org.efs.openreports.objects.ReportParameterValue;
import org.efs.openreports.providers.*;

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

	private String command;
	private String submitType;

	private int id;
	private String name;
	private String type;
	private String className;
	private String data;
	private int dataSourceId = Integer.MIN_VALUE;
	private String description;
	private boolean required;
	private boolean multipleSelect;

	private ReportParameter reportParameter;

	private ReportParameterValue[] parameterValues;

	private DataSourceProvider dataSourceProvider;
	private ParameterProvider parameterProvider;

	public String execute()
	{
		try
		{
			if (command.equals("edit"))
			{
				reportParameter =
					parameterProvider.getReportParameter(new Integer(id));
			}
			else
			{
				reportParameter = new ReportParameter();
			}

			if (command.equals("edit") && submitType == null)
			{
				name = reportParameter.getName();
				type = reportParameter.getType();
				className = reportParameter.getClassName();
				data = reportParameter.getData();
				id = reportParameter.getId().intValue();
				if (reportParameter.getDataSource() != null)
				{
					dataSourceId =
						reportParameter.getDataSource().getId().intValue();
				}
				description = reportParameter.getDescription();
				required = reportParameter.isRequired();
				multipleSelect = reportParameter.isMultipleSelect();
			}

			if (submitType == null)
				return INPUT;

			reportParameter.setName(name);
			reportParameter.setType(type);
			reportParameter.setClassName(className);
			reportParameter.setData(data);
			if (dataSourceId != -1)
				reportParameter.setDataSource(
					dataSourceProvider.getDataSource(
						new Integer(dataSourceId)));
			reportParameter.setDescription(description);
			reportParameter.setRequired(required);
			reportParameter.setMultipleSelect(multipleSelect);

			if (submitType.equals("Validate"))
			{
				if (type.equals(ReportParameter.LIST_PARAM)
					|| type.equals(ReportParameter.QUERY_PARAM))
				{
					parameterValues =
						parameterProvider.getParamValues(reportParameter, null);
				}

				return INPUT;
			}

			if (command.equals("edit"))
			{
				parameterProvider.updateReportParameter(reportParameter);
			}

			if (command.equals("add"))
			{
				parameterProvider.insertReportParameter(reportParameter);
			}

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

	public String getCommand()
	{
		return command;
	}

	public void setCommand(String command)
	{
		this.command = command;
	}

	public String getSubmitType()
	{
		return submitType;
	}

	public void setSubmitType(String submitType)
	{
		this.submitType = submitType;
	}

	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 String getClassName()
	{
		return className;
	}

	public String getData()
	{
		return data;
	}

	public String getType()
	{
		return type;
	}

	public void setClassName(String className)
	{
		this.className = className;
	}

	public void setData(String data)
	{
		this.data = data;
	}

	public void setType(String type)
	{
		this.type = type;
	}

	public ReportParameterValue[] getParameterValues()
	{
		return parameterValues;
	}

	public void setParameterValues(ReportParameterValue[] parameterValues)
	{
		this.parameterValues = parameterValues;
	}

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

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

	public String getDescription()
	{
		return description;
	}

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

	public boolean isRequired()
	{
		return required;
	}

	public void setRequired(boolean required)
	{
		this.required = required;
	}

	public boolean isMultipleSelect()
	{
		return multipleSelect;
	}

	public void setMultipleSelect(boolean multipleSelect)
	{
		this.multipleSelect = multipleSelect;
	}

}

⌨️ 快捷键说明

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