Source Code Cross Referenced for ItemManager.java in  » J2EE » JOnAS-4.8.6 » olstore » domain » manager » 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 » JOnAS 4.8.6 » olstore.domain.manager 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Copyright (c) 2004 Red Hat, Inc. All rights reserved.
003:         *
004:         * This library is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License as published by the Free Software Foundation; either
007:         * version 2.1 of the License, or any later version.
008:         *
009:         * This library is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012:         * Lesser General Public License for more details.
013:         *
014:         * You should have received a copy of the GNU Lesser General Public
015:         * License along with this library; if not, write to the Free Software
016:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
017:         * USA
018:         *
019:         * Component of: Red Hat Application Server
020:         * 
021:         * Initial Developers: Greg Lapouchnian
022:         *                     Patrick Smith
023:         *
024:         */package olstore.domain.manager;
025:
026:        import java.util.ArrayList;
027:        import java.util.Collection;
028:        import java.util.Iterator;
029:
030:        import olstore.dto.ItemValue;
031:        import olstore.dto.PictureValue;
032:        import olstore.entity.ItemLocal;
033:        import olstore.entity.ItemLocalHome;
034:        import olstore.session.helper.ItemHelper;
035:
036:        /**
037:         * A wrapper class for item actions so that there is no need to reference the
038:         * beans directly, allowing us to swap out the backend beans for a different
039:         * implementation.
040:         */
041:        public class ItemManager {
042:
043:            // An item local home to use the finder methods.
044:            private ItemLocalHome home;
045:
046:            // A helper class for item bean operations.
047:            private ItemHelper helper;
048:
049:            /**
050:             * Constructs a new manager with the appropriate beans supplied via Spring.
051:             * @param home the ItemLocalHome that provides finder methods.
052:             * @param helper the ItemHelper which provides all other item methods.
053:             */
054:            public ItemManager(ItemLocalHome home, ItemHelper helper) {
055:                this .home = home;
056:                this .helper = helper;
057:            }
058:
059:            /**
060:             * Returns an ItemValue from the helper bean that matches the ID.
061:             * @param itemId the id of the item to return.
062:             * @return an ItemValue for the item requested.
063:             * @throws Exception
064:             */
065:            public ItemValue getItemById(String itemId) throws Exception {
066:                return helper.getItemValueForId(itemId);
067:            }
068:
069:            /**
070:             * Returns a PictureValue for the picture that belongs to the item
071:             * given by the itemId.
072:             * @param itemId the item whose picture we want to return.
073:             * @return the picture associated with the item given by itemId.
074:             * @throws Exception
075:             */
076:            public PictureValue getPictureById(String itemId) throws Exception {
077:                return helper.getPicture(itemId);
078:            }
079:
080:            /**
081:             * Returns a collection of DTOs that have the same content as the collection of
082:             * given locals.
083:             * @param locals a collection of locals that need to be converted to DTOs.
084:             * @return a Collection of DTOs that have the same content as the collection of locals given.
085:             * @throws Exception
086:             */
087:            private Collection convertToDTOs(Collection locals)
088:                    throws Exception {
089:                Iterator i = locals.iterator();
090:                Collection dtos = new ArrayList();
091:
092:                while (i.hasNext()) {
093:                    dtos.add(helper.convertToDTO((ItemLocal) i.next()));
094:                }
095:
096:                return dtos;
097:            }
098:
099:            /**
100:             * Returns a collection of all items in the database.
101:             * @return a collectio of all items in the database.
102:             */
103:            public Collection getAllItems() {
104:                try {
105:                    return convertToDTOs(home.findAll());
106:                } catch (Exception e) {
107:                    return null;
108:                }
109:            }
110:
111:            /**
112:             * Returns a collection of all items whose type matches the supplied type.
113:             * @param type the type of items that will be returned.
114:             * @return a collection of all items whose type matches the supplied type.
115:             */
116:            public Collection getItemsByType(String type) {
117:                try {
118:                    return convertToDTOs(home.findByType(type));
119:                } catch (Exception e) {
120:                    return null;
121:                }
122:            }
123:
124:            /**
125:             * Return a collection of all items that have been marked for the main page and
126:             * whose friends of username have purchased.
127:             * @param username the user whose friends are considered into the collection.
128:             * @return a collection of all items that have been marked for the main page and
129:             * whose friends of username have purchased.
130:             */
131:            public Collection findByMainPageAndFriendsOf(String username) {
132:                try {
133:                    return home.findByMainPageAndFriendsOf(username);
134:                } catch (Exception e) {
135:                    return null;
136:                }
137:            }
138:
139:            /**
140:             * Returns a collection of items that have been marked for the main page and
141:             * have been marked as a special offer.
142:             * @return a collectino of items that have been marked for the main page and
143:             * have been marked as a special offer.
144:             */
145:            public Collection findByMainPageAndSpecialOffer() {
146:                try {
147:                    return home.findByMainPageAndSpecialOffer();
148:                } catch (Exception e) {
149:                    return null;
150:                }
151:            }
152:
153:            /**
154:             * Returns a collection of all items that have been marked
155:             * for the main page.
156:             * @return a collection of all items that have been marked
157:             * for the main page.
158:             */
159:            public Collection findByMainPage() {
160:                try {
161:                    return home.findByMainPage();
162:                } catch (Exception e) {
163:                    return null;
164:                }
165:            }
166:
167:            /**
168:             * Saves the given item into the backend storage.
169:             * @param item the item to save.
170:             * @throws Exception
171:             */
172:            public void saveItem(ItemValue item) throws Exception {
173:                helper.saveItem(item);
174:            }
175:
176:            /**
177:             * A collection of all properties for the given type.
178:             * @param type the type for which properties will be returned.
179:             * @return a collection of all properties for the given type.
180:             * @throws Exception
181:             */
182:            public Collection getPropertiesForType(String type)
183:                    throws Exception {
184:                return helper.getPropertiesForType(type);
185:            }
186:
187:            /**
188:             * Record this item as interesting to the user.
189:             * 
190:             * @param itemId the ID of the item the user wants to mark as interesting
191:             * @param user the username of the currently logged in user
192:             * @throws Exception if there is an error making the change
193:             */
194:            public void markItemAsInteresting(Integer itemId, String user)
195:                    throws Exception {
196:                helper.markItemAsInteresting(itemId.toString(), user);
197:            }
198:
199:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.