KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > espada > bugtracker > app > Severity


1
2 package com.espada.bugtracker.app;
3
4 // Java core packages:
5
import java.io.*;
6 import java.sql.*;
7 import java.util.*;
8
9 // Espada DB Pool API
10
import com.espada.bugtracker.persistence.*;
11
12 // Bugtracker API
13
import com.espada.bugtracker.app.*;
14
15 /**
16 * This is the Severity class, which is the core of the entire application.
17 *
18 *
19 * @version: $Id: Severity.java,v 1.7 2001/04/17 12:43:02 manik Exp $<BR>
20 * @author: Manik Surtani<BR>
21 **/

22
23 public class Severity
24 {
25
26 public int severityID;
27
28 public String JavaDoc severity;
29
30 public int weight;
31
32 public boolean def;
33
34   public Severity()
35   {
36   
37         //Default values
38

39   }
40
41
42   public Severity (int id)
43   {
44        try
45        {
46
47             Connection d = DatabaseConnectionPool.getConnection();
48             Statement st = d.createStatement();
49             ResultSet rs = st.executeQuery("select * from severity where severity_id=" + id);
50
51             while (rs.next())
52             {
53
54                 severityID = id;
55
56                 severity = rs.getString(1);
57
58                 weight = rs.getInt(2);
59
60                 def = rs.getInt(3) == 1;
61
62             }
63
64             st.close();
65             DatabaseConnectionPool.freeConnection(d);
66
67         }
68
69         catch (Exception JavaDoc E)
70         {
71
72             //Exception handling
73

74         }
75   } //end of method Severity
76

77
78   public String JavaDoc getName()
79   {
80
81         return severity;
82
83   } //end of method getName
84

85
86   public int getID()
87   {
88     
89         return severityID;
90
91   } //end of method getID
92

93
94   public int getWeight()
95   {
96     
97         return weight;
98
99   } //end of method getWeight
100

101
102   public boolean isDefault()
103   {
104         
105         return def;
106
107   } //end of method isDefault
108

109
110 /**
111 * Returns a Vector of all severities available.
112 **/

113   public static Vector getSeverities()
114   {
115     
116     Vector v = new Vector();
117         
118         try
119         {
120             Connection d = DatabaseConnectionPool.getConnection();
121             Statement st = d.createStatement();
122             ResultSet rs = st.executeQuery("select severity_id from severity order by def");
123
124             while (rs.next())
125             {
126
127                     v.add( new Severity( rs.getInt( 1 ) ) );
128
129             }
130
131             st.close();
132             DatabaseConnectionPool.freeConnection(d);
133             return v;
134         }
135
136         catch (Exception JavaDoc E)
137         {
138
139                 E.printStackTrace();
140                 v.add( new String JavaDoc("Error") );
141                 v.add( E.getMessage() );
142                 return v;
143
144         }
145
146        } // end method.
147

148
149 } //end of class
Popular Tags