Source Code Cross Referenced for SearchBuilderItemDaoImpl.java in  » ERP-CRM-Financial » sakai » org » sakaiproject » search » component » dao » 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 » ERP CRM Financial » sakai » org.sakaiproject.search.component.dao.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************************
002:         * $URL: https://source.sakaiproject.org/svn/search/tags/sakai_2-4-1/search-impl/impl/src/java/org/sakaiproject/search/component/dao/impl/SearchBuilderItemDaoImpl.java $
003:         * $Id: SearchBuilderItemDaoImpl.java 29601 2007-04-26 13:53:34Z ajpoland@iupui.edu $
004:         ***********************************************************************************
005:         *
006:         * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation.
007:         *
008:         * Licensed under the Educational Community License, Version 1.0 (the "License");
009:         * you may not use this file except in compliance with the License.
010:         * You may obtain a copy of the License at
011:         *
012:         *      http://www.opensource.org/licenses/ecl1.php
013:         *
014:         * Unless required by applicable law or agreed to in writing, software
015:         * distributed under the License is distributed on an "AS IS" BASIS,
016:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:         * See the License for the specific language governing permissions and
018:         * limitations under the License.
019:         *
020:         **********************************************************************************/package org.sakaiproject.search.component.dao.impl;
021:
022:        import java.sql.Connection;
023:        import java.sql.PreparedStatement;
024:        import java.sql.ResultSet;
025:        import java.sql.SQLException;
026:        import java.text.MessageFormat;
027:        import java.util.List;
028:
029:        import org.apache.commons.logging.Log;
030:        import org.apache.commons.logging.LogFactory;
031:        import org.hibernate.HibernateException;
032:        import org.hibernate.Session;
033:        import org.hibernate.criterion.Expression;
034:        import org.sakaiproject.search.dao.SearchBuilderItemDao;
035:        import org.sakaiproject.search.model.SearchBuilderItem;
036:        import org.sakaiproject.search.model.impl.SearchBuilderItemImpl;
037:        import org.springframework.orm.hibernate3.HibernateCallback;
038:        import org.springframework.orm.hibernate3.HibernateTemplate;
039:        import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
040:        import org.springframework.transaction.support.TransactionSynchronizationManager;
041:
042:        /**
043:         * @author ieb
044:         */
045:        public class SearchBuilderItemDaoImpl extends HibernateDaoSupport
046:                implements  SearchBuilderItemDao {
047:
048:            /**
049:             * debug logger
050:             */
051:            private static Log dlog = LogFactory
052:                    .getLog(SearchBuilderItemDaoImpl.class);
053:
054:            /**
055:             * create a new search builder item {@inheritDoc}
056:             */
057:            public SearchBuilderItem create() {
058:                return new SearchBuilderItemImpl();
059:            }
060:
061:            /**
062:             * update a search Builder item
063:             * 
064:             * @{inheritDoc}
065:             */
066:            public void update(SearchBuilderItem sb) {
067:                HibernateTemplate ht = getHibernateTemplate();
068:                ht.saveOrUpdate(sb);
069:                ht.flush();
070:
071:            }
072:
073:            /**
074:             * reset all the documents to cause a reload of current state
075:             * 
076:             * @{inheritDoc}
077:             */
078:            public List getAll() {
079:                HibernateCallback callback = new HibernateCallback() {
080:                    public Object doInHibernate(Session session)
081:                            throws HibernateException {
082:                        return session.createCriteria(
083:                                SearchBuilderItemImpl.class).list();
084:                    }
085:                };
086:
087:                return (List) getHibernateTemplate().execute(callback);
088:            }
089:
090:            /**
091:             * locate a document by name, to modify it
092:             * 
093:             * @{inheritDoc}
094:             */
095:            public SearchBuilderItem findByName(final String resourceName) {
096:                if (resourceName != null && resourceName.length() > 255) {
097:                    dlog.warn("Entity Reference longer than 255 characters :"
098:                            + resourceName);
099:                    return null;
100:                }
101:                HibernateCallback callback = new HibernateCallback() {
102:                    public Object doInHibernate(Session session)
103:                            throws HibernateException {
104:                        return session.createCriteria(
105:                                SearchBuilderItemImpl.class).add(
106:                                Expression.eq("name", resourceName)).list();
107:                    }
108:
109:                };
110:                List l = (List) getHibernateTemplate().execute(callback);
111:                if (l.size() == 0) {
112:                    return null;
113:                } else {
114:                    return (SearchBuilderItem) l.get(0);
115:                }
116:
117:            }
118:
119:            private int countPending(Connection connection) {
120:
121:                PreparedStatement pst = null;
122:                ResultSet rst = null;
123:                try {
124:                    pst = connection
125:                            .prepareStatement("select count(*) from searchbuilderitem where searchstate = ? and searchaction <> ?");
126:                    pst.clearParameters();
127:                    pst.setInt(1, SearchBuilderItem.STATE_PENDING.intValue());
128:                    pst.setInt(2, SearchBuilderItem.ACTION_UNKNOWN.intValue());
129:                    rst = pst.executeQuery();
130:                    if (rst.next()) {
131:                        return rst.getInt(1);
132:                    }
133:                    return 0;
134:                } catch (SQLException sqlex) {
135:                    return 0;
136:                } finally {
137:                    try {
138:                        pst.close();
139:                    } catch (Exception ex) {
140:                    }
141:                    ;
142:                }
143:
144:            }
145:
146:            public int countPending() {
147:
148:                HibernateCallback callback = new HibernateCallback() {
149:                    public Object doInHibernate(Session session)
150:                            throws HibernateException {
151:                        return new Integer(countPending(session.connection()));
152:                    }
153:                };
154:
155:                return ((Integer) getHibernateTemplate().execute(callback))
156:                        .intValue();
157:            }
158:
159:            public List getGlobalMasters() {
160:                HibernateCallback callback = new HibernateCallback() {
161:                    public Object doInHibernate(Session session)
162:                            throws HibernateException {
163:                        return session.createCriteria(
164:                                SearchBuilderItemImpl.class).add(
165:                                Expression.eq("name",
166:                                        SearchBuilderItem.GLOBAL_MASTER))
167:                                .list();
168:                    }
169:                };
170:
171:                return (List) getHibernateTemplate().execute(callback);
172:            }
173:
174:            public List getSiteMasters() {
175:                HibernateCallback callback = new HibernateCallback() {
176:                    public Object doInHibernate(Session session)
177:                            throws HibernateException {
178:                        return session
179:                                .createCriteria(SearchBuilderItemImpl.class)
180:                                .add(
181:                                        Expression
182:                                                .like(
183:                                                        "name",
184:                                                        SearchBuilderItem.SITE_MASTER_PATTERN))
185:                                .add(
186:                                        Expression
187:                                                .not(Expression
188:                                                        .eq(
189:                                                                "context",
190:                                                                SearchBuilderItem.GLOBAL_CONTEXT)))
191:                                .list();
192:                    }
193:                };
194:
195:                return (List) getHibernateTemplate().execute(callback);
196:            }
197:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.