Source Code Cross Referenced for BSMarketingQueriesImpl.java in  » UML » MetaBoss » com » hatmaker » crm » services » miscellaneousservices » defaultimpl » 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 » UML » MetaBoss » com.hatmaker.crm.services.miscellaneousservices.defaultimpl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
002:        // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
003:        // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
004:        // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
005:        // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
006:        // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
007:        // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
008:        // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
009:        // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
010:        // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
011:        // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
012:        // POSSIBILITY OF SUCH DAMAGE.
013:        //
014:        // Copyright 2000-2004 © Softaris Pty.Ltd. All Rights Reserved.
015:        package com.hatmaker.crm.services.miscellaneousservices.defaultimpl;
016:
017:        import org.apache.commons.logging.Log;
018:        import org.apache.commons.logging.LogFactory;
019:
020:        import com.hatmaker.crm.domains.main.BOClient;
021:        import com.hatmaker.crm.domains.main.BOClientCollection;
022:        import com.hatmaker.crm.domains.main.BOOrderCollection;
023:        import com.hatmaker.crm.domains.main.BOOrderItemCollection;
024:        import com.hatmaker.crm.domains.main.BOProduct;
025:        import com.hatmaker.crm.domains.main.BOProductCollection;
026:        import com.hatmaker.crm.domains.main.BOProductOrderItem;
027:        import com.hatmaker.crm.domains.main.BOProductOrderItemCollection;
028:        import com.hatmaker.crm.domains.main.BOService;
029:        import com.hatmaker.crm.domains.main.BOServiceCollection;
030:        import com.hatmaker.crm.domains.main.BOServiceOrderItemCollection;
031:        import com.hatmaker.crm.services.maindomainsupport.STClientKey;
032:        import com.hatmaker.crm.services.maindomainsupport.STProductKey;
033:        import com.hatmaker.crm.services.maindomainsupport.STServiceKey;
034:        import com.hatmaker.crm.services.maindomainsupport.generatedimpl.TRBOClient;
035:        import com.hatmaker.crm.services.maindomainsupport.generatedimpl.TRBOOrder;
036:        import com.hatmaker.crm.services.maindomainsupport.generatedimpl.TRBOOrderItem;
037:        import com.hatmaker.crm.services.maindomainsupport.generatedimpl.TRBOProduct;
038:        import com.hatmaker.crm.services.maindomainsupport.generatedimpl.TRBOProductOrderItem;
039:        import com.hatmaker.crm.services.maindomainsupport.generatedimpl.TRBOService;
040:        import com.hatmaker.crm.types.main.PriceCategory;
041:        import com.hatmaker.types.core.BooleanField;
042:        import com.hatmaker.types.core.CollectionOffset;
043:        import com.hatmaker.types.core.SubsetSize;
044:        import com.metaboss.enterprise.bo.BOException;
045:        import com.metaboss.enterprise.bo.BORecordNotFoundException;
046:        import com.metaboss.enterprise.bs.BSDomainObjectInvocationException;
047:        import com.metaboss.enterprise.bs.BSException;
048:        import com.metaboss.enterprise.bs.BSNamingAndDirectoryServiceInvocationException;
049:        import com.metaboss.enterprise.bs.BSUnexpectedProgramConditionException;
050:
051:        /** This class contains implementation of the service */
052:        public class BSMarketingQueriesImpl
053:                implements 
054:                com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries {
055:            private static final Log sLogger = LogFactory
056:                    .getLog(BSMarketingQueriesImpl.class);
057:
058:            /** Constructor. */
059:            BSMarketingQueriesImpl() throws Exception {
060:            }
061:
062:            /** Implementation for {@link com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries#getClientsWhoOrderedProductsAndServices(com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries.STGetClientsWhoOrderedProductsAndServicesInput) getClientsWhoOrderedProductsAndServices} method */
063:            public com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries.STGetClientsWhoOrderedProductsAndServicesResult getClientsWhoOrderedProductsAndServices(
064:                    com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries.STGetClientsWhoOrderedProductsAndServicesInput pInput)
065:                    throws BSException {
066:                com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries.STGetClientsWhoOrderedProductsAndServicesResult lOperationResult = new com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries.STGetClientsWhoOrderedProductsAndServicesResult();
067:                try {
068:                    javax.naming.Context lContext = new javax.naming.InitialContext();
069:                    com.hatmaker.crm.domains.main.BODomain lDomain = (com.hatmaker.crm.domains.main.BODomain) lContext
070:                            .lookup(com.hatmaker.crm.domains.main.BODomain.COMPONENT_URL);
071:                    // We have to find all clients, who has ever ordered each product and service mentioned in inputs and than intersect them
072:                    // Note that this example shows slightly different approach to the getClientsWhoOrderedProductsOrServices() example
073:                    // here we get clients interested in each product or service separately and than run
074:                    // intersection on these clients 
075:                    BOClientCollection lResultCollection = null;
076:                    STProductKey[] lDesiredProducts = pInput.getProducts();
077:                    if (lDesiredProducts != null) {
078:                        for (int i = 0; i < lDesiredProducts.length; i++) {
079:                            STProductKey lDesiredProduct = lDesiredProducts[i];
080:                            BOProduct lProduct = lDomain
081:                                    .getProduct(lDesiredProduct.getInstanceId());
082:                            BOClientCollection lClientsWhoHaveOrderedDesiredProduct = lProduct
083:                                    .getCommitments().getAllOrders()
084:                                    .getAllClients();
085:                            if (lResultCollection == null)
086:                                lResultCollection = lClientsWhoHaveOrderedDesiredProduct; // First time
087:                            else
088:                                lResultCollection = lResultCollection
089:                                        .intersection(lClientsWhoHaveOrderedDesiredProduct); // All other times
090:                        }
091:                    }
092:                    STServiceKey[] lDesiredServices = pInput.getServices();
093:                    if (lDesiredServices != null) {
094:                        for (int i = 0; i < lDesiredServices.length; i++) {
095:                            STServiceKey lDesiredService = lDesiredServices[i];
096:                            BOService lService = lDomain
097:                                    .getService(lDesiredService.getInstanceId());
098:                            BOClientCollection lClientsWhoHaveOrderedDesiredService = lService
099:                                    .getCommitments().getAllOrders()
100:                                    .getAllClients();
101:                            if (lResultCollection == null)
102:                                lResultCollection = lClientsWhoHaveOrderedDesiredService; // First time
103:                            else
104:                                lResultCollection = lResultCollection
105:                                        .intersection(lClientsWhoHaveOrderedDesiredService); // All other times
106:                        }
107:                    }
108:                    // Now process result
109:                    if (lResultCollection != null) {
110:                        com.hatmaker.crm.domains.main.BOClient[] lEntities = lResultCollection
111:                                .toClientsArray();
112:                        lOperationResult.setClients(TRBOClient
113:                                .convertToDetailsStructureArray(lEntities));
114:                    }
115:                    return lOperationResult;
116:                } catch (javax.naming.NamingException e) {
117:                    throw new BSNamingAndDirectoryServiceInvocationException(
118:                            "Unable to complete getClientsWhoOrderedProductsAndServices operation.",
119:                            e);
120:                } catch (BOException e) {
121:                    throw new BSDomainObjectInvocationException(
122:                            "Unable to complete getClientsWhoOrderedProductsAndServices operation.",
123:                            e);
124:                }
125:            }
126:
127:            /** Implementation for {@link com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries#getClientsWhoOrderedProductsOrServices(com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries.STGetClientsWhoOrderedProductsOrServicesInput) getClientsWhoOrderedProductsOrServices} method */
128:            public com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries.STGetClientsWhoOrderedProductsOrServicesResult getClientsWhoOrderedProductsOrServices(
129:                    com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries.STGetClientsWhoOrderedProductsOrServicesInput pInput)
130:                    throws BSException {
131:                com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries.STGetClientsWhoOrderedProductsOrServicesResult lOperationResult = new com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries.STGetClientsWhoOrderedProductsOrServicesResult();
132:                try {
133:                    javax.naming.Context lContext = new javax.naming.InitialContext();
134:                    com.hatmaker.crm.domains.main.BODomain lDomain = (com.hatmaker.crm.domains.main.BODomain) lContext
135:                            .lookup(com.hatmaker.crm.domains.main.BODomain.COMPONENT_URL);
136:                    // We have to find all order items for requested products and services and than find all clients who these order items belong to
137:                    // Note that this example shows slightly different approach to the getClientsWhoOrderedProductsAndServices() example
138:                    // here we get order items associated with each product or service and than get all clients who ordered them
139:                    // intersection on these clients 
140:                    BOOrderItemCollection lOrderItemCollection = null;
141:                    STProductKey[] lDesiredProducts = pInput.getProducts();
142:                    if (lDesiredProducts != null) {
143:                        for (int i = 0; i < lDesiredProducts.length; i++) {
144:                            STProductKey lDesiredProduct = lDesiredProducts[i];
145:                            BOProduct lProduct = lDomain
146:                                    .getProduct(lDesiredProduct.getInstanceId());
147:                            BOProductOrderItemCollection lProductCommitments = lProduct
148:                                    .getCommitments();
149:                            if (lOrderItemCollection == null)
150:                                lOrderItemCollection = lProductCommitments; // First time
151:                            else
152:                                lOrderItemCollection = lOrderItemCollection
153:                                        .union(lProductCommitments); // Join to other commitments
154:                        }
155:                    }
156:                    STServiceKey[] lDesiredServices = pInput.getServices();
157:                    if (lDesiredServices != null) {
158:                        for (int i = 0; i < lDesiredServices.length; i++) {
159:                            STServiceKey lDesiredService = lDesiredServices[i];
160:                            BOService lService = lDomain
161:                                    .getService(lDesiredService.getInstanceId());
162:                            BOServiceOrderItemCollection lServiceCommitments = lService
163:                                    .getCommitments();
164:                            if (lOrderItemCollection == null)
165:                                lOrderItemCollection = lServiceCommitments; // First time
166:                            else
167:                                lOrderItemCollection = lOrderItemCollection
168:                                        .union(lServiceCommitments); // Join to other commitments
169:                        }
170:                    }
171:                    // Now process result
172:                    if (lOrderItemCollection != null) {
173:                        com.hatmaker.crm.domains.main.BOClient[] lEntities = lOrderItemCollection
174:                                .getAllOrders().getAllClients()
175:                                .toClientsArray();
176:                        lOperationResult.setClients(TRBOClient
177:                                .convertToDetailsStructureArray(lEntities));
178:                    }
179:                    return lOperationResult;
180:                } catch (javax.naming.NamingException e) {
181:                    throw new BSNamingAndDirectoryServiceInvocationException(
182:                            "Unable to complete getClientsWhoOrderedProductsOrServices operation.",
183:                            e);
184:                } catch (BOException e) {
185:                    throw new BSDomainObjectInvocationException(
186:                            "Unable to complete getClientsWhoOrderedProductsOrServices operation.",
187:                            e);
188:                }
189:            }
190:
191:            /** Implementation for {@link com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries#getProductsAndServicesOrderedByClient(com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries.STGetProductsAndServicesOrderedByClientInput) getProductsAndServicesOrderedByClient} method */
192:            public com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries.STGetProductsAndServicesOrderedByClientResult getProductsAndServicesOrderedByClient(
193:                    com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries.STGetProductsAndServicesOrderedByClientInput pInput)
194:                    throws BSException {
195:                com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries.STGetProductsAndServicesOrderedByClientResult lOperationResult = new com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries.STGetProductsAndServicesOrderedByClientResult();
196:                try {
197:                    javax.naming.Context lContext = new javax.naming.InitialContext();
198:                    com.hatmaker.crm.domains.main.BODomain lDomain = (com.hatmaker.crm.domains.main.BODomain) lContext
199:                            .lookup(com.hatmaker.crm.domains.main.BODomain.COMPONENT_URL);
200:                    // We have to find all order items for requested client, select specifically product items and service items and
201:                    // find all products associated with product items and all services associated with service items
202:                    // First get collection of all items of all orders associated with client 
203:                    STClientKey lClientKey = pInput.getClient();
204:                    BOClient lClient = lDomain.getClient(lClientKey
205:                            .getInstanceId());
206:                    BOOrderItemCollection lAllClientOrderItems = lClient
207:                            .getOrders().getAllItems();
208:                    // Select all products associated with product order items 
209:                    BOProductCollection lProductsOrderedByClient = lAllClientOrderItems
210:                            .selectProductOrderItems().getAllProducts();
211:                    // Select all services associated with service order items 
212:                    BOServiceCollection lServicesOrderedByClient = lAllClientOrderItems
213:                            .selectServiceOrderItems().getAllServices();
214:                    // Now process result
215:                    if (lProductsOrderedByClient != null) {
216:                        BOProduct[] lProducts = lProductsOrderedByClient
217:                                .toProductsArray();
218:                        lOperationResult.setProducts(TRBOProduct
219:                                .convertToDetailsStructureArray(lProducts));
220:                    }
221:                    if (lProductsOrderedByClient != null) {
222:                        BOService[] lServices = lServicesOrderedByClient
223:                                .toServicesArray();
224:                        lOperationResult.setServices(TRBOService
225:                                .convertToDetailsStructureArray(lServices));
226:                    }
227:                    return lOperationResult;
228:                } catch (javax.naming.NamingException e) {
229:                    throw new BSNamingAndDirectoryServiceInvocationException(
230:                            "Unable to complete getClientsWhoOrderedProductsOrServices operation.",
231:                            e);
232:                } catch (BOException e) {
233:                    throw new BSDomainObjectInvocationException(
234:                            "Unable to complete getClientsWhoOrderedProductsOrServices operation.",
235:                            e);
236:                }
237:            }
238:
239:            /** Implementation for {@link com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries#getProductOrdersDetails(com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries.STGetetProductOrdersDetailsInput) getProductOrdersDetails} method */
240:            public com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries.STGetProductOrdersDetailsResult getProductOrdersDetails(
241:                    com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries.STGetProductOrdersDetailsInput pInput)
242:                    throws BSException {
243:                com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries.STGetProductOrdersDetailsResult lOperationResult = new com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries.STGetProductOrdersDetailsResult();
244:                try {
245:                    javax.naming.Context lContext = new javax.naming.InitialContext();
246:                    com.hatmaker.crm.domains.main.BODomain lDomain = (com.hatmaker.crm.domains.main.BODomain) lContext
247:                            .lookup(com.hatmaker.crm.domains.main.BODomain.COMPONENT_URL);
248:                    // We have to find all order items for requested product and return them
249:                    STProductKey lProductKey = pInput.getProduct();
250:                    BOProduct lProduct = lDomain.getProduct(lProductKey
251:                            .getInstanceId());
252:                    BOProductOrderItem[] lAllProductOrderItems = lProduct
253:                            .getCommitments().toProductOrderItemsArray();
254:                    lOperationResult
255:                            .setOrderItems(TRBOProductOrderItem
256:                                    .convertToDetailsStructureArray(lAllProductOrderItems));
257:                    return lOperationResult;
258:                } catch (javax.naming.NamingException e) {
259:                    throw new BSNamingAndDirectoryServiceInvocationException(
260:                            "Unable to complete getClientsWhoOrderedProductsOrServices operation.",
261:                            e);
262:                } catch (BORecordNotFoundException e) {
263:                    if (e
264:                            .getRecordType()
265:                            .equals(
266:                                    "Enterprise/systems[Crm]/domains[Main]/entities[Product]")) {
267:                        com.hatmaker.crm.services.maindomainsupport.MOProductInstanceNotFoundError lErrorMessage = new com.hatmaker.crm.services.maindomainsupport.MOProductInstanceNotFoundError();
268:                        lOperationResult.setProductNotFoundError(lErrorMessage);
269:                        return lOperationResult;
270:                    }
271:                    throw new BSUnexpectedProgramConditionException(
272:                            "Caught unexpected exception.", e);
273:                } catch (BOException e) {
274:                    throw new BSDomainObjectInvocationException(
275:                            "Unable to complete getClientsWhoOrderedProductsOrServices operation.",
276:                            e);
277:                }
278:            }
279:
280:            /** Implementation for {@link com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries#getOrderItemsInPriceCategory(com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries.STGetOrderItemsInPriceCategoryInput) getOrderItemsInPriceCategory} method */
281:            public com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries.STGetOrderItemsInPriceCategoryResult getOrderItemsInPriceCategory(
282:                    com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries.STGetOrderItemsInPriceCategoryInput pInput)
283:                    throws BSException {
284:                com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries.STGetOrderItemsInPriceCategoryResult lOperationResult = new com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries.STGetOrderItemsInPriceCategoryResult();
285:                try {
286:                    javax.naming.Context lContext = new javax.naming.InitialContext();
287:                    com.hatmaker.crm.domains.main.BODomain lDomain = (com.hatmaker.crm.domains.main.BODomain) lContext
288:                            .lookup(com.hatmaker.crm.domains.main.BODomain.COMPONENT_URL);
289:                    // We have to find all order items for requested products and/or services and return them
290:                    BOOrderItemCollection lResultingOrderItems = null;
291:                    PriceCategory lRequiredCategory = pInput
292:                            .getRequiredCategory();
293:                    if (lRequiredCategory != null) {
294:                        BooleanField lNeedProducts = pInput
295:                                .getIncludeProducts();
296:                        if (lNeedProducts != null && lNeedProducts.isTrue()) {
297:                            BOOrderItemCollection lProductOrderItems = lDomain
298:                                    .getAllProducts()
299:                                    .selectProductsWithPriceCategory(
300:                                            lRequiredCategory)
301:                                    .getAllCommitments();
302:                            // Check for null, so this code is position independent and other flags independent
303:                            if (lResultingOrderItems == null)
304:                                lResultingOrderItems = lProductOrderItems;
305:                            else
306:                                lResultingOrderItems = lResultingOrderItems
307:                                        .union(lProductOrderItems);
308:                        }
309:                        BooleanField lNeedServices = pInput
310:                                .getIncludeServices();
311:                        if (lNeedServices != null && lNeedServices.isTrue()) {
312:                            BOOrderItemCollection lServiceOrderItems = lDomain
313:                                    .getAllServices()
314:                                    .selectServicesWithPriceCategory(
315:                                            lRequiredCategory)
316:                                    .getAllCommitments();
317:                            // Check for null, so this code is position independent and other flags independent
318:                            if (lResultingOrderItems == null)
319:                                lResultingOrderItems = lServiceOrderItems;
320:                            else
321:                                lResultingOrderItems = lResultingOrderItems
322:                                        .union(lServiceOrderItems);
323:                        }
324:                        // Only continue if there was at least request for one of the products and / or services 
325:                        if (lResultingOrderItems != null) {
326:                            CollectionOffset lCollectionOffset = pInput
327:                                    .getReturnedCollectionOffset();
328:                            SubsetSize lSubsetSize = pInput
329:                                    .getReturnedSubsetSize();
330:                            if (lCollectionOffset != null
331:                                    && lSubsetSize != null)
332:                                lResultingOrderItems = lResultingOrderItems
333:                                        .selectOrderItems(lCollectionOffset,
334:                                                lSubsetSize);
335:                            BOOrderCollection lOwnerOrders = lResultingOrderItems
336:                                    .getAllOrders();
337:                            BOClientCollection lOwnerClients = lOwnerOrders
338:                                    .getAllClients();
339:                            lOperationResult
340:                                    .setOrderItems(TRBOOrderItem
341:                                            .convertToDetailsStructureArray(lResultingOrderItems
342:                                                    .toOrderItemsArray()));
343:                            lOperationResult
344:                                    .setOwnerOrders(TRBOOrder
345:                                            .convertToDetailsStructureArray(lOwnerOrders
346:                                                    .toOrdersArray()));
347:                            lOperationResult
348:                                    .setOwnerClients(TRBOClient
349:                                            .convertToDetailsStructureArray(lOwnerClients
350:                                                    .toClientsArray()));
351:                        }
352:                    }
353:                    return lOperationResult;
354:                } catch (javax.naming.NamingException e) {
355:                    throw new BSNamingAndDirectoryServiceInvocationException(
356:                            "Unable to complete getOrderItemsInPriceCategory operation.",
357:                            e);
358:                } catch (BOException e) {
359:                    throw new BSDomainObjectInvocationException(
360:                            "Unable to complete getOrderItemsInPriceCategory operation.",
361:                            e);
362:                }
363:            }
364:
365:            /** Implementation for {@link com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries#getOrderItemsInPriceCategoryInList(com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries.STGetOrderItemsInPriceCategoryInListInput) getOrderItemsInPriceCategoryInList} method */
366:            public com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries.STGetOrderItemsInPriceCategoryInListResult getOrderItemsInPriceCategoryInList(
367:                    com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries.STGetOrderItemsInPriceCategoryInListInput pInput)
368:                    throws BSException {
369:                com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries.STGetOrderItemsInPriceCategoryInListResult lOperationResult = new com.hatmaker.crm.services.miscellaneousservices.BSMarketingQueries.STGetOrderItemsInPriceCategoryInListResult();
370:                try {
371:                    javax.naming.Context lContext = new javax.naming.InitialContext();
372:                    com.hatmaker.crm.domains.main.BODomain lDomain = (com.hatmaker.crm.domains.main.BODomain) lContext
373:                            .lookup(com.hatmaker.crm.domains.main.BODomain.COMPONENT_URL);
374:                    // We have to find all order items for requested products and/or services and return them
375:                    BOOrderItemCollection lResultingOrderItems = null;
376:                    PriceCategory[] lRequiredCategories = pInput
377:                            .getRequiredCategories();
378:                    BooleanField lNeedProducts = pInput.getIncludeProducts();
379:                    if (lNeedProducts != null && lNeedProducts.isTrue()) {
380:                        BOOrderItemCollection lProductOrderItems = lDomain
381:                                .getAllProducts()
382:                                .selectProductsWithPriceCategoryInList(
383:                                        lRequiredCategories)
384:                                .getAllCommitments();
385:                        // Check for null, so this code is position independent and other flags independent
386:                        if (lResultingOrderItems == null)
387:                            lResultingOrderItems = lProductOrderItems;
388:                        else
389:                            lResultingOrderItems = lResultingOrderItems
390:                                    .union(lProductOrderItems);
391:                    }
392:                    BooleanField lNeedServices = pInput.getIncludeServices();
393:                    if (lNeedServices != null && lNeedServices.isTrue()) {
394:                        BOOrderItemCollection lServiceOrderItems = lDomain
395:                                .getAllServices()
396:                                .selectServicesWithPriceCategoryInList(
397:                                        lRequiredCategories)
398:                                .getAllCommitments();
399:                        // Check for null, so this code is position independent and other flags independent
400:                        if (lResultingOrderItems == null)
401:                            lResultingOrderItems = lServiceOrderItems;
402:                        else
403:                            lResultingOrderItems = lResultingOrderItems
404:                                    .union(lServiceOrderItems);
405:                    }
406:                    // Only continue if there was at least request for one of the products and / or services 
407:                    if (lResultingOrderItems != null) {
408:                        CollectionOffset lCollectionOffset = pInput
409:                                .getReturnedCollectionOffset();
410:                        SubsetSize lSubsetSize = pInput.getReturnedSubsetSize();
411:                        if (lCollectionOffset != null && lSubsetSize != null)
412:                            lResultingOrderItems = lResultingOrderItems
413:                                    .selectOrderItems(lCollectionOffset,
414:                                            lSubsetSize);
415:                        BOOrderCollection lOwnerOrders = lResultingOrderItems
416:                                .getAllOrders();
417:                        BOClientCollection lOwnerClients = lOwnerOrders
418:                                .getAllClients();
419:                        lOperationResult
420:                                .setOrderItems(TRBOOrderItem
421:                                        .convertToDetailsStructureArray(lResultingOrderItems
422:                                                .toOrderItemsArray()));
423:                        lOperationResult.setOwnerOrders(TRBOOrder
424:                                .convertToDetailsStructureArray(lOwnerOrders
425:                                        .toOrdersArray()));
426:                        lOperationResult.setOwnerClients(TRBOClient
427:                                .convertToDetailsStructureArray(lOwnerClients
428:                                        .toClientsArray()));
429:                    }
430:                    return lOperationResult;
431:                } catch (javax.naming.NamingException e) {
432:                    throw new BSNamingAndDirectoryServiceInvocationException(
433:                            "Unable to complete getOrderItemsInPriceCategory operation.",
434:                            e);
435:                } catch (BOException e) {
436:                    throw new BSDomainObjectInvocationException(
437:                            "Unable to complete getOrderItemsInPriceCategory operation.",
438:                            e);
439:                }
440:            }
441:
442:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.