KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > him > editors > report > rqom > ReportQuery


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19 package org.openharmonise.him.editors.report.rqom;
20
21 import java.util.ArrayList JavaDoc;
22 import java.util.Date JavaDoc;
23 import java.util.Iterator JavaDoc;
24 import java.util.List JavaDoc;
25
26 import org.openharmonise.him.harmonise.*;
27
28
29 /**
30  * Core report query object for the report query object model.
31  *
32  * @author Matthew Large
33  * @version $Revision: 1.1 $
34  *
35  */

36 public class ReportQuery {
37     
38     private ArrayList JavaDoc m_listeners = new ArrayList JavaDoc();
39
40     /**
41      * Path for scope of query.
42      */

43     private String JavaDoc m_sPath = HarmonisePaths.PATH_DOCUMENTS;
44
45     /**
46      * From date.
47      */

48     private Date JavaDoc m_dtFrom = new Date JavaDoc();
49     
50     /**
51      * To date.
52      */

53     private Date JavaDoc m_dtTo = new Date JavaDoc();
54
55     /**
56      * List of {@link WorkflowStage} objects.
57      */

58     private ArrayList JavaDoc m_aWorkflowStages = new ArrayList JavaDoc();
59     
60     /**
61      * List of {@link Metadata} objects.
62      */

63     private ArrayList JavaDoc m_aProperties = new ArrayList JavaDoc();
64     
65     /**
66      * List of {@link User} objects.
67      */

68     private ArrayList JavaDoc m_aUsers = new ArrayList JavaDoc();
69     
70     /**
71      * List of activity identifiers.
72      */

73     private ArrayList JavaDoc m_aActivities = new ArrayList JavaDoc();
74
75     /**
76      * Publish activity identifier.
77      */

78     public static final String JavaDoc ACTIVITY_PUBLISH = "ACTIVITY_PUBLISH";
79
80     /**
81      * Archive activity identifier.
82      */

83     public static final String JavaDoc ACTIVITY_ARCHIVE = "ACTIVITY_ARCHIVE";
84
85     /**
86      * Move activity identifier.
87      */

88     public static final String JavaDoc ACTIVITY_MOVE = "ACTIVITY_MOVE";
89
90     /**
91      * Retrieve activity identifier.
92      */

93     public static final String JavaDoc ACTIVITY_RETRIEVE = "ACTIVITY_RETRIEVE";
94
95     /**
96      * Workflow activity identifier.
97      */

98     public static final String JavaDoc ACTIVITY_WORKFLOW = "ACTIVITY_WORKFLOW";
99
100     private ArrayList JavaDoc m_aDisplayAttributes = new ArrayList JavaDoc();
101     
102     private ArrayList JavaDoc m_aOrderByAttributes = new ArrayList JavaDoc();
103
104     /**
105      * Constructs a new report query.
106      */

107     public ReportQuery() {
108         super();
109     }
110     
111     /**
112      * Returns the report scope path.
113      *
114      * @return Path
115      */

116     public String JavaDoc getPath() {
117         return this.m_sPath;
118     }
119     
120     /**
121      * Sets the report scope path.
122      *
123      * @param sPath Path
124      */

125     public void setPath(String JavaDoc sPath) {
126         this.m_sPath = sPath;
127         this.fireDataChangedMessage();
128     }
129     
130     /**
131      * Returns the from date.
132      *
133      * @return From date
134      */

135     public Date JavaDoc getPeriodFrom() {
136         return this.m_dtFrom;
137     }
138     
139     /**
140      * Sets the from date.
141      *
142      * @param dtFrom From date
143      */

144     public void setPeriodFrom(Date JavaDoc dtFrom) {
145         this.m_dtFrom = dtFrom;
146         this.fireDataChangedMessage();
147     }
148     
149     /**
150      * Returns the to date.
151      *
152      * @return To date
153      */

154     public Date JavaDoc getPeriodTo() {
155         return this.m_dtTo;
156     }
157     
158     /**
159      * Sets the to date.
160      *
161      * @param dtTo To date
162      */

163     public void setPeriodTo(Date JavaDoc dtTo) {
164         this.m_dtTo = dtTo;
165         this.fireDataChangedMessage();
166     }
167     
168     /**
169      * Returns a list of activities.
170      *
171      * @return List of activity identifiers
172      */

173     public List JavaDoc getActivities() {
174         return (List JavaDoc) this.m_aActivities.clone();
175     }
176     
177     /**
178      * Adds an activity.
179      *
180      * @param sActivity Activity identifier to add
181      */

182     public void addActivity(String JavaDoc sActivity) {
183         this.m_aActivities.add(sActivity);
184         this.fireDataChangedMessage();
185     }
186     
187     /**
188      * Removes an activity.
189      *
190      * @param sActivity Activity identifier to remove
191      */

192     public void removeActivity(String JavaDoc sActivity) {
193         this.m_aActivities.remove(sActivity);
194         this.fireDataChangedMessage();
195     }
196
197     /**
198      * Returns a list of workflow stages.
199      *
200      * @return List of {@link WorkflowStage} objects
201      */

202     public List JavaDoc getWorkflowStages() {
203         return (List JavaDoc) this.m_aWorkflowStages.clone();
204     }
205     
206     /**
207      * Adds a workflow stage.
208      *
209      * @param stage Workflow stage to add
210      */

211     public void addWorkflowStage(WorkflowStage stage) {
212         this.m_aWorkflowStages.add(stage);
213         this.fireDataChangedMessage();
214     }
215     
216     /**
217      * Removes a workflow stage.
218      *
219      * @param stage Workflow stage to remove
220      */

221     public void removeWorkflowStage(WorkflowStage stage) {
222         this.m_aWorkflowStages.remove(stage);
223         this.fireDataChangedMessage();
224     }
225     
226     /**
227      * Returns a list of metadata.
228      *
229      * @return List of {@link Metadata} objects
230      */

231     public List JavaDoc getMetadata() {
232         return (List JavaDoc) this.m_aProperties.clone();
233     }
234     
235     /**
236      * Adds a metadata item.
237      *
238      * @param metadata Metadata to add
239      */

240     public void addMetadata(Metadata metadata) {
241         this.m_aProperties.add(metadata);
242         this.fireDataChangedMessage();
243     }
244     
245     /**
246      * Removes a metadata item.
247      *
248      * @param metadata Metadata to remove
249      */

250     public void removeMetadata(Metadata metadata) {
251         this.m_aProperties.remove(metadata);
252         this.fireDataChangedMessage();
253     }
254     /**
255      * Adds a display attribute item.
256      *
257      * @param metadata Metadata to add
258      */

259     public void addDisplayAttributes(Metadata metadata) {
260         this.m_aDisplayAttributes.add(metadata);
261         this.fireDataChangedMessage();
262     }
263     public void clearDisplayAttributes(){
264         m_aDisplayAttributes = new ArrayList JavaDoc();
265     }
266     
267     /**
268      * Removes a display attribute item.
269      *
270      * @param metadata Metadata to remove
271      */

272     public void removeDisplayAttributes(Metadata metadata) {
273         this.m_aDisplayAttributes.remove(metadata);
274         this.fireDataChangedMessage();
275     }
276     /**
277      * Returns a list of display metadata.
278      *
279      * @return List of {@link Metadata} objects
280      */

281     public List JavaDoc getDisplayAttributes() {
282         return (List JavaDoc) this.m_aDisplayAttributes.clone();
283     }
284     /**
285      * Adds a display attribute item.
286      *
287      * @param metadata Metadata to add
288      */

289     public void addOrderByAttributes(Metadata metadata) {
290         this.m_aOrderByAttributes.add(metadata);
291         this.fireDataChangedMessage();
292     }
293     
294     /**
295      * Removes a display attribute item.
296      *
297      * @param metadata Metadata to remove
298      */

299     public void removeOrderByAttributes(Metadata metadata) {
300         this.m_aOrderByAttributes.remove(metadata);
301         this.fireDataChangedMessage();
302     }
303     /**
304      * Returns a list of display metadata.
305      *
306      * @return List of {@link Metadata} objects
307      */

308     public List JavaDoc getOrderByAttributes() {
309         return (List JavaDoc) this.m_aOrderByAttributes.clone();
310     }
311     
312     /**
313      * Returns a list of users.
314      *
315      * @return List of {@link User} objects
316      */

317     public List JavaDoc getUsers() {
318         return (List JavaDoc) this.m_aUsers.clone();
319     }
320     
321     /**
322      * Adds a user.
323      *
324      * @param user User to add
325      */

326     public void addUser(User user) {
327         this.m_aUsers.add(user);
328         this.fireDataChangedMessage();
329     }
330     
331     /**
332      * Removes a user.
333      *
334      * @param user User to remove
335      */

336     public void removeUser(User user) {
337         this.m_aUsers.remove(user);
338         this.fireDataChangedMessage();
339     }
340
341     public void addListener(ReportQueryListener listener) {
342         this.m_listeners.add(listener);
343     }
344     
345     public void removeListeners(ReportQueryListener listener) {
346         this.m_listeners.remove(listener);
347     }
348     
349     public void fireDataChangedMessage() {
350         Iterator JavaDoc itor = this.m_listeners.iterator();
351         while (itor.hasNext()) {
352             ReportQueryListener listener = (ReportQueryListener) itor.next();
353             listener.dataChanged();
354         }
355     }
356     public boolean isReportPanelEditable() {
357         boolean bEditable = true;
358         List JavaDoc metadata = this.getMetadata();
359         List JavaDoc attributes = this.getDisplayAttributes();
360         List JavaDoc order = this.getOrderByAttributes();
361         if(metadata.size()>0 || attributes.size()>0 || order.size()>0) {
362             bEditable = false;
363         }
364         return bEditable;
365     }
366 }
367
Popular Tags