Source Code Cross Referenced for CategoryManager.java in  » Portal » DLOG4J » dlog4j » 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 » Portal » DLOG4J » dlog4j 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  This program is free software; you can redistribute it and/or modify
003:         *  it under the terms of the GNU General Public License as published by
004:         *  the Free Software Foundation; either version 2 of the License, or
005:         *  (at your option) any later version.
006:         *
007:         *  This program is distributed in the hope that it will be useful,
008:         *  but WITHOUT ANY WARRANTY; without even the implied warranty of
009:         *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
010:         *  GNU Library General Public License for more details.
011:         *
012:         *  You should have received a copy of the GNU General Public License
013:         *  along with this program; if not, write to the Free Software
014:         *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
015:         */
016:        package dlog4j;
017:
018:        import java.util.Iterator;
019:        import java.util.List;
020:
021:        import dlog4j.formbean.CategoryForm;
022:        import dlog4j.formbean.SiteForm;
023:        import dlog4j.formbean.UserForm;
024:        import dlog4j.security.DlogRole;
025:
026:        import net.sf.hibernate.Criteria;
027:        import net.sf.hibernate.HibernateException;
028:        import net.sf.hibernate.Session;
029:        import net.sf.hibernate.expression.Expression;
030:        import net.sf.hibernate.expression.Order;
031:
032:        /**
033:         * 日记分类管理器
034:         * @author Liudong
035:         */
036:        public class CategoryManager {
037:
038:            /**
039:             * 读取日记分类的详细信息(管理级别的方法)
040:             * DlogCategoryAction的删除和更新分类方法用到该方法
041:             * @param ssn
042:             * @param site
043:             * @param loginUser
044:             * @param cat_id
045:             * @return
046:             * @throws HibernateException
047:             */
048:            public static CategoryForm getCategory(Session ssn, SiteForm site,
049:                    int cat_id) throws HibernateException {
050:                Criteria crit = ssn.createCriteria(CategoryForm.class);
051:                crit = crit.add(Expression.eq("site.id", new Integer(site
052:                        .getId())));
053:                crit = crit.add(Expression.eq("id", new Integer(cat_id)));
054:                try {
055:                    List cats = crit.list();
056:                    if (cats.size() > 0)
057:                        return (CategoryForm) cats.get(0);
058:                } catch (HibernateException e) {
059:                }
060:                return null;
061:            }
062:
063:            /**
064:             * 查询指定站点的所有日记分类(管理级别的方法)
065:             * DlogCategoryAction: doCreateCategory, doMoveDown, doMoveUp
066:             * @param ssn
067:             * @param site
068:             * @return
069:             * @throws SQLException
070:             * @throws HibernateException
071:             */
072:            public static List listCategories(Session ssn, SiteForm site)
073:                    throws HibernateException {
074:                Criteria crit = ssn.createCriteria(CategoryForm.class);
075:                crit = crit.add(Expression.eq("site.id", new Integer(site
076:                        .getId())));
077:                crit = crit.addOrder(Order.asc("order"));
078:                return crit.list();
079:            }
080:
081:            /**
082:             * 查询某个用户可见的所有日记分类,用于浏览日记而非添加日记
083:             * CategoryTag.java   (一般用途)
084:             * @param ssn
085:             * @param site
086:             * @return
087:             * @throws SQLException
088:             * @throws HibernateException
089:             */
090:            public static List listCategories(Session ssn, SiteForm site,
091:                    UserForm loginUser) throws HibernateException {
092:                Criteria crit = ssn.createCriteria(CategoryForm.class);
093:                crit = crit.add(Expression.eq("site.id", new Integer(site
094:                        .getId())));
095:                crit = crit.addOrder(Order.asc("order"));
096:                List cats = crit.list();
097:                Iterator icats = cats.iterator();
098:                int role = (loginUser != null) ? loginUser.getUserRole()
099:                        : DlogRole.ROLE_GUEST;
100:                int[] ncats = (loginUser != null) ? loginUser.getOwnerCatids()
101:                        : new int[0];
102:
103:                while (role != DlogRole.ROLE_MANAGER && icats.hasNext()) {
104:                    CategoryForm cat = (CategoryForm) icats.next();
105:                    if (role == DlogRole.ROLE_BUDDY) {
106:                        if (cat.getType() == CategoryForm.TYPE_OWNER) {
107:                            int i = 0;
108:                            for (; i < ncats.length; i++) {
109:                                if (cat.getId() == ncats[i])
110:                                    break;
111:                            }
112:                            if (i >= ncats.length)
113:                                icats.remove();
114:                        }
115:                    } else {
116:                        if (cat.getType() == CategoryForm.TYPE_OWNER)
117:                            icats.remove();
118:                    }
119:                }
120:                return cats;
121:            }
122:
123:            /**
124:             * 查询某个用户可见的所有日记分类,用于浏览日记而非添加日记
125:             * CategoryTag.java   (一般用途)
126:             * @param ssn
127:             * @param site
128:             * @return
129:             * @throws SQLException
130:             * @throws HibernateException
131:             */
132:            public static List listCategoriesForModify(Session ssn,
133:                    SiteForm site, UserForm loginUser)
134:                    throws HibernateException {
135:                Criteria crit = ssn.createCriteria(CategoryForm.class);
136:                crit = crit.add(Expression.eq("site.id", new Integer(site
137:                        .getId())));
138:                crit = crit.addOrder(Order.asc("order"));
139:                List cats = crit.list();
140:                Iterator icats = cats.iterator();
141:                int role = (loginUser != null) ? loginUser.getRole().getId()
142:                        : DlogRole.ROLE_GUEST;
143:                int[] ncats = (loginUser != null) ? loginUser.getOwnerCatids()
144:                        : new int[0];
145:
146:                while (role != DlogRole.ROLE_MANAGER && icats.hasNext()) {
147:                    CategoryForm cat = (CategoryForm) icats.next();
148:                    if (role == DlogRole.ROLE_BUDDY) {
149:                        if (cat.getType() == CategoryForm.TYPE_OWNER) {
150:                            int i = 0;
151:                            for (; i < ncats.length; i++) {
152:                                if (cat.getId() == ncats[i])
153:                                    break;
154:                            }
155:                            if (i < ncats.length)
156:                                continue;
157:                        } else if (cat.getType() == CategoryForm.TYPE_COMMON)
158:                            continue;
159:                    }
160:                    if (role == DlogRole.ROLE_FRIEND) {
161:                        if (cat.getType() == CategoryForm.TYPE_COMMON) {
162:                            int i = 0;
163:                            for (; i < ncats.length; i++) {
164:                                if (cat.getId() == ncats[i])
165:                                    break;
166:                            }
167:                            if (i < ncats.length)
168:                                continue;
169:                        }
170:                    }
171:                    icats.remove();
172:                }
173:                return cats;
174:            }
175:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.