001: /*
002: * Copyright (c) 2000, Manik Surtani <manik@post1.com> All rights reserved.
003: *
004: * Redistribution and use in source and binary forms, with or without
005: * modification, are permitted provided that the following conditions
006: * are met:
007: *
008: * 1. Redistributions of source code must retain the above copyright
009: * notice, this list of conditions and the following disclaimer.
010: *
011: * 2. Redistributions in binary form must reproduce the above copyright
012: * notice, this list of conditions and the following disclaimer in
013: * the documentation and/or other materials provided with the
014: * distribution.
015: *
016: * 3. All advertising materials mentioning features or use of this
017: * software must display the following acknowledgment:
018: * "This product includes software developed by Manik Surtani
019: * for use in the "BugTracker" JSP/servlet application
020: * <http://loonix.espadanet.com/>."
021: *
022: * 4. The name "BugTracker" must not be used to endorse or promote products
023: * derived from this software without prior written permission.
024: *
025: * 5. Products derived from this software may not be called "BugTracker"
026: * nor may "BugTracker" nor "Loonix" appear in their names without
027: * prior written permission of Manik Surtani.
028: *
029: * 6. Redistributions of any form whatsoever must retain the following
030: * acknowledgment:
031: * "This product includes software developed by Manik Surtani
032: * for use in the "BugTracker" JSP/servlet application
033: * <http://loonix.espadanet.com/>."
034: *
035: * THIS SOFTWARE IS PROVIDED BY MANIK SURTANI PROJECT "AS IS" AND ANY
036: * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
037: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
038: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE JAVA APACHE PROJECT OR
039: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
040: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
041: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
042: * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
043: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
044: * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
045: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
046: * OF THE POSSIBILITY OF SUCH DAMAGE.
047: *
048: *
049: */
050:
051: package com.espada.bugtracker.app;
052:
053: // Java core packages:
054: import java.io.*;
055: import java.sql.*;
056: import java.util.*;
057:
058: // Espada DB Pool API
059: import com.sr.espada.se.util.db.pool.*;
060:
061: // Bugtracker API
062: import com.espada.bugtracker.app.*;
063:
064: /**
065: * This is the Status class, which is the core of the entire application.
066: *
067: *
068: * @version: $Id: Status.java,v 1.6 2001/03/13 07:43:44 manik Exp $<BR>
069: * @author: Manik Surtani<BR>
070: **/
071:
072: public class Status {
073: public int statusID;
074:
075: public String status;
076:
077: public boolean def;
078:
079: public Status() {
080:
081: //Default values
082:
083: } //end of method Status
084:
085: public Status(int id) {
086:
087: try {
088:
089: Connection d = DatabaseConnectionPool.getConnection();
090: Statement st = d.createStatement();
091: ResultSet rs = st
092: .executeQuery("select * from status where status_id="
093: + id);
094:
095: while (rs.next()) {
096:
097: statusID = id;
098:
099: status = rs.getString(1);
100:
101: def = rs.getInt(2) == 1;
102:
103: }
104:
105: st.close();
106: DatabaseConnectionPool.freeConnection(d);
107:
108: }
109:
110: catch (Exception E) {
111:
112: //Exception handling
113:
114: }
115: } //end of method Status
116:
117: public String getName() {
118:
119: return status;
120:
121: } //end of method getName
122:
123: public int getID() {
124:
125: return statusID;
126:
127: } //end of method getID
128:
129: public boolean isDefault() {
130:
131: return def;
132:
133: } //end of method isDefault
134:
135: /**
136: * Returns a Vector of all statii available.
137: **/
138: public static Vector getStatusList(boolean getDefaults) {
139:
140: Vector v = new Vector();
141:
142: try {
143:
144: Connection d = DatabaseConnectionPool.getConnection();
145: Statement st = d.createStatement();
146: String SQL = new String();
147:
148: if (getDefaults) {
149: SQL = "select status_id from status where def=1 order by status";
150: } else {
151: SQL = "select status_id from status where def=0 order by status";
152: }
153:
154: ResultSet rs = st.executeQuery(SQL);
155:
156: while (rs.next()) {
157:
158: v.add(new Status(rs.getInt(1)));
159:
160: }
161:
162: st.close();
163: DatabaseConnectionPool.freeConnection(d);
164: return v;
165: }
166:
167: catch (Exception E) {
168: E.printStackTrace();
169: v.add(new String("Error"));
170: v.add(E.getMessage());
171: return v;
172: }
173:
174: } //end of method getStatii
175:
176: public static Vector getStatusList() {
177:
178: Vector v = new Vector();
179:
180: try {
181:
182: Connection d = DatabaseConnectionPool.getConnection();
183: Statement st = d.createStatement();
184: String SQL = new String();
185:
186: ResultSet rs = st
187: .executeQuery("select status_id from status order by status");
188:
189: while (rs.next()) {
190:
191: v.add(new Status(rs.getInt(1)));
192:
193: }
194:
195: st.close();
196: DatabaseConnectionPool.freeConnection(d);
197: return v;
198: }
199:
200: catch (Exception E) {
201: E.printStackTrace();
202: v.add(new String("Error"));
203: v.add(E.getMessage());
204: return v;
205: }
206:
207: } //end of method getStatii
208:
209: } //end of class
|