Source Code Cross Referenced for Project.java in  » Issue-Tracking » javafreedom-bugtracker » com » espada » bugtracker » app » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Issue Tracking » javafreedom bugtracker » com.espada.bugtracker.app 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.espada.bugtracker.app;
002:
003:        // Java core API
004:        import java.io.*;
005:        import java.sql.*;
006:        import java.util.*;
007:
008:        // Espada core API
009:        import com.espada.*;
010:
011:        // Espada DB Pool API
012:        import com.sr.espada.se.util.db.pool.*;
013:        import com.sr.espada.se.util.logwriter.*;
014:
015:        /**
016:         * This is the Project class.
017:         *
018:         * When an instance of Project is created, the class searches the database for an<BR>
019:         * existing project with the corresponding project id, and fills up the object properties.<BR>
020:         *
021:         * To create a new project in the database, the static method Project.createProject() must be used.<BR>
022:         *
023:         *
024:         * @version: $Id: Project.java,v 1.13 2001/04/16 09:26:58 manik Exp $<BR>
025:         * @author: Manik Surtani<BR>
026:         **/
027:
028:        public class Project {
029:
030:            private int pid;
031:
032:            private String pname;
033:
034:            public Project(int prid) {
035:                try {
036:
037:                    Connection d = DatabaseConnectionPool.getConnection();
038:                    Statement st = d.createStatement();
039:                    ResultSet rs = st
040:                            .executeQuery("select * from projects where pid="
041:                                    + prid);
042:
043:                    while (rs.next()) {
044:
045:                        pid = rs.getInt(1);
046:                        pname = rs.getString(2);
047:
048:                    }
049:
050:                    st.close();
051:                    DatabaseConnectionPool.freeConnection(d);
052:                }
053:
054:                catch (Exception E) {
055:
056:                    //Exception haddling
057:
058:                }
059:
060:            } //end of method Project
061:
062:            public Vector getProjectManagers() {
063:
064:                Vector v = new Vector();
065:                try {
066:                    Connection d = DatabaseConnectionPool.getConnection();
067:                    Statement st = d.createStatement();
068:                    ResultSet rs = st
069:                            .executeQuery("select uid from projectuser where pid="
070:                                    + pid + " and rid=2");
071:                    while (rs.next()) {
072:
073:                        v.add(new User(rs.getInt(1)));
074:                    }
075:
076:                    st.close();
077:                    DatabaseConnectionPool.freeConnection(d);
078:                }
079:
080:                catch (Exception E) {
081:                    LogWriter.write(E.getMessage());
082:
083:                    //Exception haddling
084:
085:                }
086:
087:                return v;
088:
089:            }
090:
091:            public String getRoleID(int uid) {
092:
093:                return getRole("select rid from projectuser where uid = " + uid
094:                        + " and pid=" + pid);
095:
096:            } //end of method getRoleID
097:
098:            public String getRoleName(String uid) {
099:
100:                String s = null;
101:                try {
102:                    s = getRole("select roleDesc from roles, projectuser where projectuser.rid = roles.rid and projectuser.uid = "
103:                            + uid + " and pid=" + pid);
104:                } catch (NullPointerException npex) {
105:
106:                } finally {
107:                    if (s == null)
108:                        s = "-- Not Assigned --";
109:                }
110:                return s;
111:
112:            } //end of method Project
113:
114:            private String getRole(String SQL) {
115:
116:                String v = null;
117:
118:                try {
119:
120:                    Connection d = DatabaseConnectionPool.getConnection();
121:                    Statement st = d.createStatement();
122:                    ResultSet rs = st.executeQuery(SQL);
123:
124:                    while (rs.next()) {
125:
126:                        v = rs.getString(1);
127:
128:                    }
129:
130:                    st.close();
131:                    DatabaseConnectionPool.freeConnection(d);
132:
133:                }
134:
135:                catch (Exception E) {
136:
137:                }
138:                return v;
139:
140:            } //end of method getRole
141:
142:            public boolean delete() {
143:
144:                try {
145:
146:                    Connection d = DatabaseConnectionPool.getConnection();
147:                    Statement st = d.createStatement();
148:                    int rs = st.executeUpdate("delete from projects where pid="
149:                            + pid);
150:                    st.close();
151:                    DatabaseConnectionPool.freeConnection(d);
152:                    return (rs != 0);
153:
154:                }
155:
156:                catch (Exception E) {
157:
158:                    return false;
159:
160:                }
161:
162:            } //end of method delete
163:
164:            public static Vector getProjects() {
165:
166:                return getProjectsDef("select * from projects order by pid");
167:
168:            } //end of method getProjects
169:
170:            public static Vector getProjectsByUser(int uid) {
171:
172:                return getProjectsDef("select projects.* from projects, projectuser where projectuser.uid="
173:                        + uid
174:                        + " and projectuser.pid=projects.pid order by projects.pid");
175:
176:            } //end of method getProjectsByUser
177:
178:            public static Vector getProjectsByUserRole(int uid, int rid) {
179:
180:                return getProjectsDef("select projects.pid from projects,projectuser where projectuser.uid="
181:                        + uid
182:                        + " and projectuser.rid="
183:                        + rid
184:                        + " and projectuser.pid=projects.pid");
185:
186:            } //end of method getProjectsByUserRole
187:
188:            private static Vector getProjectsDef(String SQL) {
189:
190:                Vector v = new Vector();
191:
192:                try {
193:
194:                    Connection d = DatabaseConnectionPool.getConnection();
195:                    Statement st = d.createStatement();
196:                    ResultSet rs = st.executeQuery(SQL);
197:
198:                    while (rs.next()) {
199:                        v.add(new Project(rs.getInt(1)));
200:                    }
201:
202:                    st.close();
203:                    DatabaseConnectionPool.freeConnection(d);
204:
205:                    return v;
206:                }
207:
208:                catch (Exception E) {
209:
210:                    E.printStackTrace();
211:                    return v;
212:
213:                }
214:
215:            } //end of method getProjectsDef
216:
217:            public int getPID() {
218:
219:                return pid;
220:
221:            } //end of method getPID
222:
223:            public String getName() {
224:
225:                return pname;
226:
227:            } //end of method getName
228:
229:            public static Project createProject(String pn, int uid)
230:                    throws CannotCreateProjectException {
231:
232:                Project p = null;
233:
234:                try {
235:
236:                    Connection d = DatabaseConnectionPool.getConnection();
237:
238:                    try {
239:
240:                        Statement st = d.createStatement();
241:                        st.executeQuery("insert into projects values(0, '" + pn
242:                                + "')");
243:                        ResultSet rs = st
244:                                .executeQuery("select pid from projects where pname='"
245:                                        + pn + "'");
246:
247:                        int pd = 0;
248:
249:                        while (rs.next()) {
250:
251:                            pd = rs.getInt(1);
252:                            p = new Project(pd);
253:
254:                        }
255:
256:                        /************ now lets update users and roles.  Make everyone a User/Bug Tester
257:                        String SQL = "insert into projectuser select " + pd + ", uid, 4 from user";***/
258:
259:                        /****** now lets make the user/UID as the site admin *******/
260:
261:                        String SQL = "insert into projectuser select " + pd
262:                                + " , " + uid + " , 1 from user";
263:
264:                        st.executeQuery(SQL);
265:                        st.close();
266:
267:                    }
268:
269:                    finally {
270:
271:                        if (d != null) {
272:
273:                            DatabaseConnectionPool.freeConnection(d);
274:                        }
275:
276:                    }
277:                }
278:
279:                catch (Exception e) {
280:
281:                    throw new CannotCreateProjectException(pn, e);
282:
283:                }
284:
285:                return p;
286:
287:            } //end of method createProject
288:
289:        } //end of class
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.