Source Code Cross Referenced for UserProviderImpl.java in  » Report » openreports » org » efs » openreports » providers » impl » 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 » Report » openreports » org.efs.openreports.providers.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) 2002 Erik Swenson - erik@oreports.com
003:         * 
004:         * This program is free software; you can redistribute it and/or modify it
005:         * under the terms of the GNU General Public License as published by the Free
006:         * Software Foundation; either version 2 of the License, or (at your option)
007:         * any later version.
008:         * 
009:         * This program is distributed in the hope that it will be useful, but WITHOUT
010:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
011:         * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
012:         * more details.
013:         * 
014:         * You should have received a copy of the GNU General Public License along with
015:         * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
016:         * Place - Suite 330, Boston, MA 02111-1307, USA.
017:         *  
018:         */
019:
020:        package org.efs.openreports.providers.impl;
021:
022:        import java.util.List;
023:
024:        import org.apache.log4j.Logger;
025:        import org.efs.openreports.objects.ReportGroup;
026:        import org.efs.openreports.objects.ReportUser;
027:        import org.efs.openreports.providers.HibernateProvider;
028:        import org.efs.openreports.providers.ProviderException;
029:        import org.efs.openreports.providers.UserProvider;
030:        import org.hibernate.HibernateException;
031:        import org.hibernate.Session;
032:        import org.hibernate.Transaction;
033:
034:        public class UserProviderImpl implements  UserProvider {
035:            protected static Logger log = Logger
036:                    .getLogger(UserProviderImpl.class.getName());
037:
038:            private HibernateProvider hibernateProvider;
039:
040:            public UserProviderImpl(HibernateProvider hibernateProvider)
041:                    throws ProviderException {
042:                this .hibernateProvider = hibernateProvider;
043:
044:                log.info("UserProviderImpl created");
045:            }
046:
047:            @SuppressWarnings("unchecked")
048:            public ReportUser getUser(String name) throws ProviderException {
049:                try {
050:                    Session session = hibernateProvider.openSession();
051:
052:                    try {
053:                        List<ReportUser> list = session.createQuery(
054:                                "from org.efs.openreports.objects.ReportUser as user "
055:                                        + "where user.name = ?").setString(0,
056:                                name).list();
057:
058:                        if (list.size() == 0)
059:                            return null;
060:
061:                        ReportUser user = list.get(0);
062:
063:                        return user;
064:                    } catch (HibernateException he) {
065:                        throw he;
066:                    } finally {
067:                        session.close();
068:                    }
069:                } catch (HibernateException he) {
070:                    throw new ProviderException(he);
071:                }
072:            }
073:
074:            public ReportUser getUser(Integer id) throws ProviderException {
075:                return (ReportUser) hibernateProvider
076:                        .load(ReportUser.class, id);
077:            }
078:
079:            @SuppressWarnings("unchecked")
080:            public List<ReportUser> getUsers() throws ProviderException {
081:                String fromClause = "from org.efs.openreports.objects.ReportUser reportUser order by reportUser.name ";
082:
083:                return (List<ReportUser>) hibernateProvider.query(fromClause);
084:            }
085:
086:            public ReportUser insertUser(ReportUser user)
087:                    throws ProviderException {
088:                return (ReportUser) hibernateProvider.save(user);
089:            }
090:
091:            public void updateUser(ReportUser user) throws ProviderException {
092:                hibernateProvider.update(user);
093:            }
094:
095:            public void deleteUser(ReportUser user) throws ProviderException {
096:                Session session = hibernateProvider.openSession();
097:                Transaction tx = null;
098:
099:                try {
100:                    tx = session.beginTransaction();
101:
102:                    //delete user			
103:                    session.delete(user);
104:
105:                    //delete report log entries for user
106:                    session
107:                            .createQuery(
108:                                    "DELETE org.efs.openreports.objects.ReportLog reportLog where reportLog.user.id = ? ")
109:                            .setInteger(0, user.getId().intValue())
110:                            .executeUpdate();
111:
112:                    tx.commit();
113:                } catch (HibernateException he) {
114:                    hibernateProvider.rollbackTransaction(tx);
115:
116:                    throw new ProviderException(he.getMessage());
117:                } finally {
118:                    hibernateProvider.closeSession(session);
119:                }
120:            }
121:
122:            @SuppressWarnings("unchecked")
123:            public List<ReportUser> getUsersForGroup(ReportGroup reportGroup)
124:                    throws ProviderException {
125:                try {
126:                    Session session = hibernateProvider.openSession();
127:
128:                    try {
129:                        List<ReportUser> list = session
130:                                .createQuery(
131:                                        "from org.efs.openreports.objects.ReportUser as reportUser "
132:                                                + "where ? in elements(reportUser.groups)")
133:                                .setEntity(0, reportGroup).list();
134:
135:                        if (list.size() == 0)
136:                            return null;
137:
138:                        return list;
139:                    } catch (HibernateException he) {
140:                        throw he;
141:                    } finally {
142:                        session.close();
143:                    }
144:                } catch (HibernateException he) {
145:                    throw new ProviderException(he);
146:                }
147:            }
148:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.