KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > efs > openreports > objects > ReportGroup


1 /*
2  * Copyright (C) 2002 Erik Swenson - eswenson@opensourcesoft.net
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the Free
6  * Software Foundation; either version 2 of the License, or (at your option)
7  * any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16  * Place - Suite 330, Boston, MA 02111-1307, USA.
17  *
18  */

19
20 package org.efs.openreports.objects;
21
22 import java.io.Serializable JavaDoc;
23 import java.util.ArrayList JavaDoc;
24 import java.util.Iterator JavaDoc;
25 import java.util.List JavaDoc;
26
27 public class ReportGroup implements Comparable JavaDoc, Serializable JavaDoc
28 {
29     private static final long serialVersionUID = 3591220643715469145L;
30     
31     private Integer JavaDoc id;
32     private String JavaDoc name;
33     private String JavaDoc description;
34
35     private List JavaDoc reports;
36
37     public ReportGroup()
38     {
39     }
40
41     public List JavaDoc getReports()
42     {
43         return reports;
44     }
45     
46     // does not include hidden reports
47
public List JavaDoc getReportsForDisplay()
48     {
49         ArrayList JavaDoc list = new ArrayList JavaDoc();
50         
51         Iterator JavaDoc iterator = reports.iterator();
52         while(iterator.hasNext())
53         {
54             Report report = (Report) iterator.next();
55             if (!report.isHidden()) list.add(report);
56         }
57         
58         return list;
59     }
60
61     public void setReports(List JavaDoc reports)
62     {
63         this.reports = reports;
64     }
65
66     public String JavaDoc toString()
67     {
68         return name;
69     }
70
71     public String JavaDoc getName()
72     {
73         return name;
74     }
75
76     public void setName(String JavaDoc name)
77     {
78         this.name = name;
79     }
80
81     public String JavaDoc getDescription()
82     {
83         return description;
84     }
85
86     public void setDescription(String JavaDoc description)
87     {
88         this.description = description;
89     }
90
91     public Integer JavaDoc getId()
92     {
93         return id;
94     }
95
96     public void setId(Integer JavaDoc id)
97     {
98         this.id = id;
99     }
100
101     public int compareTo(Object JavaDoc object)
102     {
103         ReportGroup reportGroup = (ReportGroup) object;
104         return name.compareTo(reportGroup.getName());
105     }
106
107     public boolean isValidReport(Report report)
108     {
109         if (reports != null && reports.size() > 0)
110         {
111             Iterator JavaDoc iterator = reports.iterator();
112             while (iterator.hasNext())
113             {
114                 Report r = (Report) iterator.next();
115                 if (r.getId().equals(report.getId()))
116                     return true;
117             }
118         }
119
120         return false;
121     }
122
123 }
Popular Tags