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 Severity class, which is the core of the entire application.
066: *
067: *
068: * @version: $Id: Severity.java,v 1.5 2001/03/13 07:43:44 manik Exp $<BR>
069: * @author: Manik Surtani<BR>
070: **/
071:
072: public class Severity {
073:
074: public int severityID;
075:
076: public String severity;
077:
078: public int weight;
079:
080: public boolean def;
081:
082: public Severity() {
083:
084: //Default values
085:
086: }
087:
088: public Severity(int id) {
089: try {
090:
091: Connection d = DatabaseConnectionPool.getConnection();
092: Statement st = d.createStatement();
093: ResultSet rs = st
094: .executeQuery("select * from severity where severity_id="
095: + id);
096:
097: while (rs.next()) {
098:
099: severityID = id;
100:
101: severity = rs.getString(1);
102:
103: weight = rs.getInt(2);
104:
105: def = rs.getInt(3) == 1;
106:
107: }
108:
109: st.close();
110: DatabaseConnectionPool.freeConnection(d);
111:
112: }
113:
114: catch (Exception E) {
115:
116: //Exception handling
117:
118: }
119: } //end of method Severity
120:
121: public String getName() {
122:
123: return severity;
124:
125: } //end of method getName
126:
127: public int getID() {
128:
129: return severityID;
130:
131: } //end of method getID
132:
133: public int getWeight() {
134:
135: return weight;
136:
137: } //end of method getWeight
138:
139: public boolean isDefault() {
140:
141: return def;
142:
143: } //end of method isDefault
144:
145: /**
146: * Returns a Vector of all severities available.
147: **/
148: public static Vector getSeverities() {
149:
150: Vector v = new Vector();
151:
152: try {
153: Connection d = DatabaseConnectionPool.getConnection();
154: Statement st = d.createStatement();
155: ResultSet rs = st
156: .executeQuery("select severity_id from severity order by def");
157:
158: while (rs.next()) {
159:
160: v.add(new Severity(rs.getInt(1)));
161:
162: }
163:
164: st.close();
165: DatabaseConnectionPool.freeConnection(d);
166: return v;
167: }
168:
169: catch (Exception E) {
170:
171: E.printStackTrace();
172: v.add(new String("Error"));
173: v.add(E.getMessage());
174: return v;
175:
176: }
177:
178: } // end method.
179:
180: } //end of class
|