KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > cowsultants > itracker > ejb > client > models > IssueActivityModel


1 /*
2  * This software was designed and created by Jason Carroll.
3  * Copyright (c) 2002, 2003, 2004 Jason Carroll.
4  * The author can be reached at jcarroll@cowsultants.com
5  * ITracker website: http://www.cowsultants.com
6  * ITracker forums: http://www.cowsultants.com/phpBB/index.php
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it only under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  */

18
19 package cowsultants.itracker.ejb.client.models;
20
21 import java.util.Comparator JavaDoc;
22
23 public class IssueActivityModel extends GenericModel implements Comparator JavaDoc {
24     private int type;
25     private String JavaDoc description;
26     private boolean notificationSent;
27     private String JavaDoc userLogin;
28     private String JavaDoc firstName;
29     private String JavaDoc lastName;
30     private String JavaDoc email;
31     private Integer JavaDoc issueId;
32     private Integer JavaDoc userId;
33
34     public IssueActivityModel() {
35     }
36
37     public IssueActivityModel(int type, String JavaDoc description, Integer JavaDoc issueId, Integer JavaDoc userId) {
38         this.setType(type);
39         this.setDescription(description);
40         this.setIssueId(issueId);
41         this.setUserId(userId);
42     }
43
44     public IssueActivityModel(int type, String JavaDoc description, boolean notificationSent, Integer JavaDoc issueId, Integer JavaDoc userId) {
45         this(type, description, issueId, userId);
46         this.setNotificationSent(notificationSent);
47     }
48
49     public int getType() {
50         return type;
51     }
52
53     public void setType(int value) {
54          type = value;
55     }
56
57     public String JavaDoc getDescription() {
58         return description;
59     }
60
61     public void setDescription(String JavaDoc value) {
62          description = value;
63     }
64
65     public boolean getNotificationSent() {
66         return notificationSent;
67     }
68
69     public void setNotificationSent(boolean value) {
70          notificationSent = value;
71     }
72
73     public String JavaDoc getUserLogin() {
74         return userLogin;
75     }
76
77     public void setUserLogin(String JavaDoc value) {
78          userLogin = value;
79     }
80
81     public String JavaDoc getUserFirstName() {
82         return firstName;
83     }
84
85     public void setUserFirstName(String JavaDoc value) {
86          firstName = value;
87     }
88
89     public String JavaDoc getUserLastName() {
90         return lastName;
91     }
92
93     public void setUserLastName(String JavaDoc value) {
94          lastName = value;
95     }
96
97     public String JavaDoc getUserEmail() {
98         return email;
99     }
100
101     public void setUserEmail(String JavaDoc value) {
102          email = value;
103     }
104
105     public Integer JavaDoc getIssueId() {
106         return issueId;
107     }
108
109     public void setIssueId(Integer JavaDoc value) {
110          issueId = value;
111     }
112
113     public Integer JavaDoc getUserId() {
114         return userId;
115     }
116
117     public void setUserId(Integer JavaDoc value) {
118          userId = value;
119     }
120
121     public int compare(Object JavaDoc a, Object JavaDoc b) {
122         return this.new CompareByDate().compare(a, b);
123     }
124
125     public boolean equals(Object JavaDoc obj) {
126         return this.new CompareByDate().equals(obj);
127     }
128
129     public class CompareByDate implements Comparator JavaDoc {
130         protected boolean isAscending = true;
131
132         public CompareByDate() {
133         }
134
135         public CompareByDate(boolean isAscending) {
136             setAscending(isAscending);
137         }
138
139         public void setAscending(boolean value) {
140             this.isAscending = value;
141         }
142
143         public int compare(Object JavaDoc a, Object JavaDoc b) {
144             int result = 0;
145
146             if(! (a instanceof IssueActivityModel) || ! (b instanceof IssueActivityModel)) {
147                 throw new ClassCastException JavaDoc();
148             }
149
150             IssueActivityModel ma = (IssueActivityModel) a;
151             IssueActivityModel mb = (IssueActivityModel) b;
152
153             if(ma.getCreateDate() == null && mb.getCreateDate() == null) {
154                 result = 0;
155             } else if(ma.getCreateDate() == null) {
156                 result = 1;
157             } else if(mb.getCreateDate() == null) {
158                 result = -1;
159             } else {
160                 if(ma.getCreateDate().equals(mb.getCreateDate())) {
161                     result = 0;
162                 } else if(ma.getCreateDate().before(mb.getCreateDate())) {
163                     result = -1;
164                 } else {
165                     result = 1;
166                 }
167             }
168
169             return (isAscending ? result : result * -1);
170         }
171
172         public boolean equals(Object JavaDoc obj) {
173             if(! (obj instanceof IssueActivityModel)) {
174                 return false;
175             }
176
177             try {
178                 IssueActivityModel mo = (IssueActivityModel) obj;
179                 if(IssueActivityModel.this.getCreateDate().equals(mo.getCreateDate()) &&
180                    IssueActivityModel.this.getUserLogin().equals(mo.getUserLogin()) &&
181                    IssueActivityModel.this.getDescription().equals(mo.getDescription())) {
182                     return true;
183                 }
184             } catch(ClassCastException JavaDoc cce) {
185             }
186
187             return false;
188         }
189
190         public int hashCode() {
191             return ((IssueActivityModel.this.getCreateDate() == null ? 1 : IssueActivityModel.this.getCreateDate().hashCode()) ^
192                     (IssueActivityModel.this.getUserLogin() == null ? 1 : IssueActivityModel.this.getUserLogin().hashCode()) ^
193                     (IssueActivityModel.this.getDescription() == null ? 1 : IssueActivityModel.this.getDescription().hashCode()));
194         }
195     }
196 }
197
Popular Tags