Source Code Cross Referenced for ReviewManagerImpl.java in  » ERP-CRM-Financial » sakai » org » theospi » portfolio » review » 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.theospi.portfolio.review.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************************
002:         * $URL: https://source.sakaiproject.org/svn/osp/tags/sakai_2-4-1/common/api-impl/src/java/org/theospi/portfolio/review/impl/ReviewManagerImpl.java $
003:         * $Id: ReviewManagerImpl.java 17193 2006-10-18 17:46:00Z andersjb@iupui.edu $
004:         ***********************************************************************************
005:         *
006:         * Copyright (c) 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.theospi.portfolio.review.impl;
021:
022:        import java.util.Iterator;
023:        import java.util.List;
024:
025:        import org.sakaiproject.authz.api.SecurityService;
026:        import org.sakaiproject.content.api.ContentHostingService;
027:        import org.sakaiproject.content.api.ContentResource;
028:        import org.sakaiproject.entity.api.EntityManager;
029:        import org.sakaiproject.entity.api.Reference;
030:        import org.sakaiproject.exception.IdUnusedException;
031:        import org.sakaiproject.exception.PermissionException;
032:        import org.sakaiproject.exception.TypeException;
033:        import org.sakaiproject.metaobj.shared.mgt.AgentManager;
034:        import org.sakaiproject.metaobj.shared.mgt.ContentEntityUtil;
035:        import org.sakaiproject.metaobj.shared.mgt.ContentEntityWrapper;
036:        import org.sakaiproject.metaobj.shared.mgt.IdManager;
037:        import org.sakaiproject.metaobj.shared.model.Agent;
038:        import org.sakaiproject.metaobj.shared.model.Id;
039:        import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
040:        import org.theospi.portfolio.review.mgt.ReviewManager;
041:        import org.theospi.portfolio.review.model.Review;
042:        import org.theospi.portfolio.security.AllowMapSecurityAdvisor;
043:        import org.theospi.portfolio.security.AuthorizationFacade;
044:        import org.theospi.portfolio.shared.model.Node;
045:
046:        public class ReviewManagerImpl extends HibernateDaoSupport implements 
047:                ReviewManager {
048:
049:            private AuthorizationFacade authorizationFacade;
050:            private SecurityService securityService;
051:            private EntityManager entityManager;
052:            private IdManager idManager;
053:            private ContentHostingService contentHosting = null;
054:            private AgentManager agentManager = null;
055:
056:            /**
057:             * This creates a new review with a generated id.  it also flags the review as being a new object
058:             * @param String description
059:             * @param String siteId
060:             * @return Review
061:             */
062:            public Review createNew(String description, String siteId) {
063:                Review review = new Review(getIdManager().createId(),
064:                        description, siteId);
065:
066:                return review;
067:            }
068:
069:            public Review getReview(Id reviewId) {
070:                Review review = (Review) getHibernateTemplate().get(
071:                        Review.class, reviewId);
072:
073:                if (review == null) {
074:                    return null;
075:                }
076:
077:                return review;
078:            }
079:
080:            public List getReviewsByParent(String parentId) {
081:                Object[] params = new Object[] { parentId };
082:                return getHibernateTemplate().findByNamedQuery(
083:                        "getReviewsByParent", params);
084:            }
085:
086:            /**
087:             * {@inheritDoc}
088:             */
089:            public List getReviewsByParent(String parentId, String siteId,
090:                    String producer) {
091:                Object[] params = new Object[] { parentId };
092:                return getReviewsByParent("getReviewsByParent", params,
093:                        parentId, siteId, producer);
094:            }
095:
096:            /**
097:             * {@inheritDoc}
098:             */
099:            public List getReviewsByParentAndType(String parentId, int type,
100:                    String siteId, String producer) {
101:                Object[] params = new Object[] { parentId, new Integer(type) };
102:                return getReviewsByParent("getReviewsByParentAndType", params,
103:                        parentId, siteId, producer);
104:            }
105:
106:            /**
107:             * the top function for getting the reviews.  This pushes these review content 
108:             * into the security advisor.
109:             * 
110:             * @param query
111:             * @param params
112:             * @param parentId
113:             * @param siteId
114:             * @param producer
115:             * @return List of Review classes
116:             */
117:            protected List getReviewsByParent(String query, Object[] params,
118:                    String parentId, String siteId, String producer) {
119:                List reviews = getHibernateTemplate().findByNamedQuery(query,
120:                        params);
121:                for (Iterator i = reviews.iterator(); i.hasNext();) {
122:                    Review review = (Review) i.next();
123:                    Node node = getNode(review.getReviewContent(), parentId,
124:                            siteId, producer);
125:                    review.setReviewContentNode(node);
126:                }
127:
128:                return reviews;
129:            }
130:
131:            public Review saveReview(Review review) {
132:                //review.setModified(now);
133:
134:                if (review.isNewObject()) {
135:                    review.setNewId(review.getId());
136:                    review.setId(null);
137:                    getHibernateTemplate().save(review);
138:                    review.setNewObject(false);
139:                } else {
140:                    getHibernateTemplate().saveOrUpdate(review);
141:                }
142:
143:                return review;
144:            }
145:
146:            public void deleteReview(Review review) {
147:                getHibernateTemplate().delete(review);
148:            }
149:
150:            public List listReviews(String siteId) {
151:                return getHibernateTemplate().findByNamedQuery(
152:                        "getReviewsBySite", siteId);
153:            }
154:
155:            public List getReviews() {
156:                return getHibernateTemplate().findByNamedQuery("getReviews");
157:            }
158:
159:            public Review getReview(String id) {
160:                return getReview(getIdManager().getId(id));
161:            }
162:
163:            protected Node getNode(Id artifactId, String parentId,
164:                    String siteId, String producer) {
165:                Node node = getNode(artifactId);
166:
167:                if (node == null) {
168:                    return null;
169:                }
170:                ContentResource wrapped = new ContentEntityWrapper(node
171:                        .getResource(), buildRef(siteId, parentId, node
172:                        .getResource(), producer));
173:
174:                return new Node(artifactId, wrapped, node
175:                        .getTechnicalMetadata().getOwner());
176:            }
177:
178:            /**
179:             * pushes the artifact into the security advisor.  It then gets the resource, properties, and owner
180:             * and places these into a Node.  
181:             * 
182:             * @param artifactId Id
183:             * @return Node
184:             * @throws RuntimeException on PermissionException, IdUnusedException, and TypeException
185:             */
186:            protected Node getNode(Id artifactId) {
187:                String id = getContentHosting().resolveUuid(
188:                        artifactId.getValue());
189:                if (id == null) {
190:                    return null;
191:                }
192:
193:                getSecurityService().pushAdvisor(
194:                        new AllowMapSecurityAdvisor(
195:                                ContentHostingService.EVENT_RESOURCE_READ,
196:                                getContentHosting().getReference(id)));
197:
198:                try {
199:                    ContentResource resource = getContentHosting().getResource(
200:                            id);
201:                    String ownerId = resource.getProperties().getProperty(
202:                            resource.getProperties().getNamePropCreator());
203:                    Agent owner = getAgentManager().getAgent(
204:                            (getIdManager().getId(ownerId)));
205:
206:                    return new Node(artifactId, resource, owner);
207:                } catch (PermissionException e) {
208:                    logger.error("", e);
209:                    throw new RuntimeException(e);
210:                } catch (IdUnusedException e) {
211:                    logger.error("", e);
212:                    throw new RuntimeException(e);
213:                } catch (TypeException e) {
214:                    logger.error("", e);
215:                    throw new RuntimeException(e);
216:                }
217:            }
218:
219:            /*  
220:              public Node getNode2(Reference ref, String parentId, String siteId) {
221:                 String nodeId = getContentHosting().getUuid(ref.getId());
222:
223:                 Node node = getNode(getIdManager().getId(nodeId), siteId);
224:                 
225:                 if (node == null) {
226:                    return null;
227:                 }
228:                 ContentResource wrapped = new ContentEntityWrapper(node.getResource(),
229:                       buildRef(siteId, parentId, node.getResource()));
230:
231:                 return new Node(artifactId, wrapped, node.getTechnicalMetadata().getOwner());
232:                 
233:                 
234:              }
235:             */
236:            protected String buildRef(String siteId, String contextId,
237:                    ContentResource resource, String producer) {
238:                return ContentEntityUtil.getInstance().buildRef(producer,
239:                        siteId, contextId, resource.getReference());
240:            }
241:
242:            public Node getNode(Reference ref) {
243:                String nodeId = getContentHosting().getUuid(ref.getId());
244:
245:                return getNode(getIdManager().getId(nodeId));
246:            }
247:
248:            /**
249:             * @return Returns the authorizationFacade.
250:             */
251:            public AuthorizationFacade getAuthorizationFacade() {
252:                return authorizationFacade;
253:            }
254:
255:            /**
256:             * @param authorizationFacade The authorizationFacade to set.
257:             */
258:            public void setAuthorizationFacade(
259:                    AuthorizationFacade authorizationFacade) {
260:                this .authorizationFacade = authorizationFacade;
261:            }
262:
263:            /**
264:             * @return Returns the entityManager.
265:             */
266:            public EntityManager getEntityManager() {
267:                return entityManager;
268:            }
269:
270:            /**
271:             * @param entityManager The entityManager to set.
272:             */
273:            public void setEntityManager(EntityManager entityManager) {
274:                this .entityManager = entityManager;
275:            }
276:
277:            /**
278:             * @return Returns the idManager.
279:             */
280:            public IdManager getIdManager() {
281:                return idManager;
282:            }
283:
284:            /**
285:             * @param idManager The idManager to set.
286:             */
287:            public void setIdManager(IdManager idManager) {
288:                this .idManager = idManager;
289:            }
290:
291:            /**
292:             * @return Returns the securityService.
293:             */
294:            public SecurityService getSecurityService() {
295:                return securityService;
296:            }
297:
298:            /**
299:             * @param securityService The securityService to set.
300:             */
301:            public void setSecurityService(SecurityService securityService) {
302:                this .securityService = securityService;
303:            }
304:
305:            /**
306:             * @return Returns the contentHosting.
307:             */
308:            public ContentHostingService getContentHosting() {
309:                return contentHosting;
310:            }
311:
312:            /**
313:             * @param contentHosting The contentHosting to set.
314:             */
315:            public void setContentHosting(ContentHostingService contentHosting) {
316:                this .contentHosting = contentHosting;
317:            }
318:
319:            /**
320:             * @return Returns the agentManager.
321:             */
322:            public AgentManager getAgentManager() {
323:                return agentManager;
324:            }
325:
326:            /**
327:             * @param agentManager The agentManager to set.
328:             */
329:            public void setAgentManager(AgentManager agentManager) {
330:                this.agentManager = agentManager;
331:            }
332:
333:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.