View Javadoc

1   /**
2    * 
3    */
4   package ar.com.jiji.kaya.reports;
5   
6   import ognl.Ognl;
7   import ognl.OgnlException;
8   
9   import org.apache.commons.lang.StringUtils;
10  
11  import ar.com.jiji.kaya.utils.ValidateUtils;
12  
13  /**
14   * Tiene una definicion de un reporte. No tiene el reporte en si, sino donde
15   * ubicarlo en el fs, nombre del reporte, etc. * TODO: documentar y hacer tests
16   * 
17   * @author lparra
18   * 
19   */
20  public class ReportSpec {
21  	private String name;
22  
23  	private Object dsExtractor;
24  
25  	private String location;
26  
27  	private String downloadName;
28  
29  	private String[] columns;
30  
31  	protected ReportSpec(String name) {
32  		setName(name);
33  	}
34  
35  	public ReportSpec(String name, String dsExtractor, String location)
36  			throws ReportException {
37  		this(name);
38  		setDsExtractor(dsExtractor);
39  		setLocation(location);
40  	}
41  
42  	public ReportSpec(String name, String dsExtractor, String location,
43  			String downloadName) throws ReportException {
44  		this(name, dsExtractor, location);
45  		setDownloadName(downloadName);
46  	}
47  
48  	public ReportSpec(String name, String dsExtractor, String location,
49  			String downloadName, String[] columns) throws ReportException {
50  		this(name, dsExtractor, location, downloadName);
51  		setColumns(columns);
52  	}
53  
54  	public String[] getColumns() {
55  		return columns;
56  	}
57  
58  	void setColumns(String[] columns) {
59  		this.columns = columns;
60  	}
61  
62  	public Object getDsExtractor() {
63  		return dsExtractor;
64  	}
65  
66  	void setDsExtractor(String dsExtractor) throws ReportException {
67  		ValidateUtils.notNull(dsExtractor);
68  		try {
69  			this.dsExtractor = Ognl.parseExpression(dsExtractor);
70  		} catch (OgnlException e) {
71  			throw new ReportException(e);
72  		}
73  	}
74  
75  	public String getLocation() {
76  		return location;
77  	}
78  
79  	void setLocation(String location) {
80  		ValidateUtils.notNull(location);
81  		this.location = location;
82  	}
83  
84  	public String getName() {
85  		return name;
86  	}
87  
88  	void setName(String name) {
89  		ValidateUtils.notNull(name);
90  		this.name = name;
91  	}
92  
93  	public String getDownloadName() {
94  		return StringUtils.defaultString(downloadName, getName());
95  	}
96  
97  	public void setDownloadName(String downloadName) {
98  		ValidateUtils.notNull(downloadName);
99  		this.downloadName = downloadName;
100 	}
101 
102 }