KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Copyright (C) 2006 Erik Swenson - erik@oreports.com
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
24 public class ReportUserAlert implements Comparable JavaDoc, Serializable JavaDoc
25 {
26     private static final long serialVersionUID = 6833718935442336961L;
27     
28     private ReportUser user;
29     private ReportAlert alert;
30     private Report report;
31     private int limit;
32     private String JavaDoc operator;
33     
34     private int count;
35     
36     public String JavaDoc getCondition()
37     {
38         return getOperator() + " " + limit;
39     }
40     
41     public ReportAlert getAlert()
42     {
43         return alert;
44     }
45
46     public void setAlert(ReportAlert alert)
47     {
48         this.alert = alert;
49     }
50
51     public int getLimit()
52     {
53         return limit;
54     }
55
56     public void setLimit(int limit)
57     {
58         this.limit = limit;
59     }
60
61     public String JavaDoc getOperator()
62     {
63         if (operator == null || operator.trim().length() < 1) return ReportAlert.OPERATOR_EQUAL;
64         return operator;
65     }
66
67     public void setOperator(String JavaDoc operator)
68     {
69         this.operator = operator;
70     }
71
72     public ReportUser getUser()
73     {
74         return user;
75     }
76
77     public void setUser(ReportUser user)
78     {
79         this.user = user;
80     }
81
82     public int compareTo(Object JavaDoc object)
83     {
84         ReportUserAlert map = (ReportUserAlert) object;
85         return alert.getName().compareTo(map.getAlert().getName());
86     }
87
88     public int getCount()
89     {
90         return count;
91     }
92
93     public void setCount(int count)
94     {
95         this.count = count;
96     }
97
98     public boolean isTriggered()
99     {
100         if ("=".equals(operator))
101         {
102             if (limit == count) return true;
103         }
104         else if (">".equals(operator))
105         {
106             if (count > limit) return true;
107         }
108         else if ("<".equals(operator))
109         {
110             if (count < limit) return true;
111         }
112         
113         return false;
114     }
115
116     public Report getReport()
117     {
118         return report;
119     }
120
121     public void setReport(Report report)
122     {
123         this.report = report;
124     }
125 }
Popular Tags