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

📄 reportdetailaction.java

📁 The ability to create groups of reports, and grant users access to reports by group. The ability to
💻 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;

import java.util.*;

import com.opensymphony.xwork.ActionContext;
import com.opensymphony.xwork.ActionSupport;

import org.efs.openreports.ORStatics;
import org.efs.openreports.objects.*;
import org.efs.openreports.providers.*;
import org.efs.openreports.util.LocalStrings;

public class ReportDetailAction extends ActionSupport
		implements
			ReportProviderAware,
			ParameterProviderAware
{
	private Report report;
	private int reportId = Integer.MIN_VALUE;

	private String reportName;
	private String submitType;

	private ParameterProvider parameterProvider;
	private ReportProvider reportProvider;

	private List reportParameters;
	private int step = 0;

	public Report getReport()
	{
		return report;
	}

	public void setReport(Report report)
	{
		this.report = report;
	}

	public String execute()
	{
		try
		{
			ReportGroup reportGroup = (ReportGroup) ActionContext.getContext().getSession()
					.get(ORStatics.REPORT_GROUP);

			report = reportProvider.getReport(new Integer(reportId));

			if (report == null)
			{
				addActionError(LocalStrings.getString(LocalStrings.ERROR_REPORT_INVALID));
				return ERROR;
			}

			if (!reportGroup.isValidReport(report))
			{
				addActionError(LocalStrings.getString(LocalStrings.ERROR_REPORT_NOTAUTHORIZED));
				return ERROR;
			}

			ActionContext.getContext().getSession().put(ORStatics.REPORT, report);

			reportParameters = report.getReportParametersByStep(step);

			if (submitType == null)
			{
				ReportUser user = (ReportUser) ActionContext.getContext().getSession().get(
						ORStatics.REPORT_USER);

				// first time through create new map and add standard report parameters
				HashMap newMap = new HashMap();
				newMap.put(ORStatics.USER_ID, user.getId());
				newMap.put(ORStatics.EXTERNAL_ID, user.getExternalId());
				newMap.put(ORStatics.USER_NAME, user.getName());

				ActionContext.getContext().getSession().remove(ORStatics.REPORT_PARAMETERS);
				ActionContext.getContext().getSession().put(ORStatics.REPORT_PARAMETERS, newMap);

				if (report.getParameters().size() > 0 && report.getParameters().size() != report.getSubReportParameters().size())
				{					
					parameterProvider.loadReportParameterValues(reportParameters, newMap);

					return INPUT;
				}
				else
				{
					return SUCCESS;
				}
			}

			parameterProvider.validateParameters(reportParameters, ActionContext.getContext()
					.getParameters());

			Map map = (Map) ActionContext.getContext().getSession().get(
					ORStatics.REPORT_PARAMETERS);

			Map currentMap = parameterProvider.getReportParametersMap(reportParameters,
					ActionContext.getContext().getParameters());

			map.putAll(currentMap);

			ActionContext.getContext().getSession().put(ORStatics.REPORT_PARAMETERS, map);

			step++;

			reportParameters = report.getReportParametersByStep(step);

			if (reportParameters.size() > 0)
			{
				parameterProvider.loadReportParameterValues(reportParameters, map);

				return INPUT;
			}

			return SUCCESS;
		}
		catch (Exception e)
		{
			Map map = (Map) ActionContext.getContext().getSession().get(
					ORStatics.REPORT_PARAMETERS);

			try
			{
				parameterProvider.loadReportParameterValues(reportParameters, map);
			}
			catch (ProviderException pe)
			{
				addActionError(pe.getMessage());
			}

			addActionError(e.getMessage());
			return INPUT;
		}
	}

	public String getSubmitType()
	{
		return submitType;
	}

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

	public int getReportId()
	{
		return reportId;
	}

	public void setReportId(int reportId)
	{
		this.reportId = reportId;
	}

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

	public void setReportProvider(ReportProvider reportProvider)
	{
		this.reportProvider = reportProvider;
	}

	public List getReportParameters()
	{
		return reportParameters;
	}

	public int getStep()
	{
		return step;
	}

	public void setStep(int step)
	{
		this.step = step;
	}

}

⌨️ 快捷键说明

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