Source Code Cross Referenced for EmployeeManagerImpl.java in  » J2EE » Enhydra-Demos » projectmanagement » business » employee » 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 » J2EE » Enhydra Demos » projectmanagement.business.employee 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package projectmanagement.business.employee;
002:
003:        import projectmanagement.business.ProjectManagementBusinessException;
004:        import projectmanagement.data.employee.*;
005:        import com.lutris.appserver.server.sql.DatabaseManagerException;
006:        import com.lutris.appserver.server.sql.ObjectId;
007:        import com.lutris.appserver.server.sql.ObjectIdException;
008:        import com.lutris.dods.builder.generator.query.*;
009:        import com.lutris.appserver.server.Enhydra;
010:        import com.lutris.logging.*;
011:
012:        import projectmanagement.spec.employee.*;
013:
014:        /**
015:         * Used to find the instance of Employee.
016:         *
017:         * @author Sasa Bojanic
018:         * @version 1.0
019:         */
020:        public class EmployeeManagerImpl implements  EmployeeManager {
021:
022:            /**
023:             * The getAllEmployees method performs a database query to
024:             * return all <CODE>Employee</CODE> objects representing the
025:             * row in the <CODE>Employees</CODE> table.
026:             * @return all the employees, or null if there are no any.
027:             * @exception ProjectManagementBusinessException
028:             *    if there is a problem retrieving employee information.
029:             */
030:            public Employee[] getAllEmployees()
031:                    throws ProjectManagementBusinessException {
032:
033:                try {
034:                    EmployeeQuery query = new EmployeeQuery();
035:
036:                    EmployeeDO[] foundEmployees = query.getDOArray();
037:                    if (foundEmployees.length != 0) {
038:                        EmployeeImpl[] cs = new EmployeeImpl[foundEmployees.length];
039:                        for (int i = 0; i < foundEmployees.length; i++) {
040:                            cs[i] = new EmployeeImpl(foundEmployees[i]);
041:                        }
042:                        return cs;
043:                    } else {
044:                        return null;
045:                    }
046:                } catch (NonUniqueQueryException ex) {
047:                    Enhydra.getLogChannel().write(
048:                            Logger.DEBUG,
049:                            "Non-unique employee found in database: "
050:                                    + ex.getMessage());
051:                    throw new ProjectManagementBusinessException(
052:                            "Non unique employee found");
053:                } catch (DataObjectException ex) {
054:                    throw new ProjectManagementBusinessException(
055:                            "Database error retrieving employees: ", ex);
056:                }/*catch(QueryException ex) {
057:                         throw new ProjectManagementBusinessException("Query exception retrieving employees: ", ex);
058:                      }*/
059:
060:            }
061:
062:            /**
063:             * The findEmployeeByID method performs a database query to
064:             * return a <CODE>Employee</CODE> object
065:             * representing the row in the <CODE>employee</CODE> table
066:             * that matches the object id.
067:             *
068:             * @param id, the object id of the employee table.
069:             * @return
070:             *    the employee. null if there isn't a employee associated
071:             *    the id
072:             * @exception ProjectManagementBusinessException
073:             *    if there is a problem retrieving employee information.
074:             */
075:            public Employee findEmployeeByID(String id)
076:                    throws ProjectManagementBusinessException {
077:
078:                Employee theEmployee = null;
079:
080:                try {
081:                    EmployeeQuery query = new EmployeeQuery();
082:                    //set query
083:                    query.setQueryOId(new ObjectId(id));
084:                    // Throw an exception if more than one user by this name is found
085:                    query.requireUniqueInstance();
086:                    EmployeeDO theEmployeeDO = query.getNextDO();
087:                    theEmployee = new EmployeeImpl(theEmployeeDO);
088:                    return theEmployee;
089:                } catch (Exception ex) {
090:                    throw new ProjectManagementBusinessException(
091:                            "Exception in findEmployeeByID()", ex);
092:                }
093:            }
094:
095:            /**
096:             * The findEmployee method performs a database query to
097:             * return a <CODE>Employee</CODE> object
098:             * representing the row in the <CODE>employees</CODE> table
099:             * that matches login name with the username.
100:             *
101:             * @param username, the login name of the employee.
102:             * @return
103:             *    the employee. null if there isn't a employee associated
104:             *    the username
105:             * @exception ProjectManagementBusinessException
106:             *    if there is a problem retrieving employee information.
107:             */
108:            public Employee findEmployee(String username)
109:                    throws ProjectManagementBusinessException {
110:                try {
111:
112:                    EmployeeQuery query = new EmployeeQuery();
113:
114:                    // set query.
115:                    query.setQueryLogin(username);
116:                    // Throw an exception if more than one user by this name is found
117:                    query.requireUniqueInstance();
118:
119:                    EmployeeDO[] foundEmployee = query.getDOArray();
120:                    if (foundEmployee.length != 0) {
121:                        return new EmployeeImpl(foundEmployee[0]);
122:                    } else {
123:                        return null;
124:                    }
125:                } catch (NonUniqueQueryException ex) {
126:                    Enhydra.getLogChannel().write(
127:                            Logger.DEBUG,
128:                            "Non-unique user found in database: "
129:                                    + ex.getMessage());
130:                    throw new ProjectManagementBusinessException(
131:                            "More than one user found with username: "
132:                                    + username);
133:                } catch (DataObjectException ex) {
134:                    throw new ProjectManagementBusinessException(
135:                            "Database error retrieving user: ", ex);
136:                } catch (QueryException ex) {
137:                    throw new ProjectManagementBusinessException(
138:                            "Query exception retrieving user: ", ex);
139:                }
140:            }
141:
142:            public Employee getEmployee()
143:                    throws ProjectManagementBusinessException {
144:                return new EmployeeImpl();
145:            }
146:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.