Source Code Cross Referenced for PromoServices.java in  » ERP-CRM-Financial » SourceTap-CRM » org » ofbiz » product » promo » 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 » SourceTap CRM » org.ofbiz.product.promo 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: PromoServices.java,v 1.2 2004/01/15 17:45:38 jonesde Exp $
003:         * 
004:         * Copyright (c) 2001, 2002 The Open For Business Project - www.ofbiz.org
005:         * 
006:         * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal
007:         * in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008:         * copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
009:         * 
010:         * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
011:         * 
012:         * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
013:         * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
014:         * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
015:         */
016:        package org.ofbiz.product.promo;
017:
018:        import java.sql.Timestamp;
019:        import java.util.LinkedList;
020:        import java.util.List;
021:        import java.util.Map;
022:
023:        import org.ofbiz.base.util.Debug;
024:        import org.ofbiz.base.util.UtilDateTime;
025:        import org.ofbiz.base.util.UtilValidate;
026:        import org.ofbiz.entity.GenericDelegator;
027:        import org.ofbiz.entity.GenericEntityException;
028:        import org.ofbiz.entity.GenericValue;
029:        import org.ofbiz.entity.condition.EntityCondition;
030:        import org.ofbiz.entity.condition.EntityConditionList;
031:        import org.ofbiz.entity.condition.EntityExpr;
032:        import org.ofbiz.entity.condition.EntityOperator;
033:        import org.ofbiz.entity.util.EntityListIterator;
034:        import org.ofbiz.service.DispatchContext;
035:        import org.ofbiz.service.GenericServiceException;
036:        import org.ofbiz.service.LocalDispatcher;
037:        import org.ofbiz.service.ServiceUtil;
038:
039:        /**
040:         * Inventory Services
041:         * 
042:         * @author Nathan De Graw
043:         * @version $Revision: 1.2 $
044:         * @since 3.0
045:         */
046:        public class PromoServices {
047:
048:            public final static String module = PromoServices.class.getName();
049:
050:            public static Map createProductPromoCodeSet(DispatchContext dctx,
051:                    Map context) {
052:                //GenericDelegator delegator = dctx.getDelegator();
053:                LocalDispatcher dispatcher = dctx.getDispatcher();
054:                Long quantity = (Long) context.get("quantity");
055:                //Long useLimitPerCode = (Long) context.get("useLimitPerCode");
056:                //Long useLimitPerCustomer = (Long) context.get("useLimitPerCustomer");
057:                //GenericValue promoItem = null;
058:                //GenericValue newItem = null;
059:
060:                StringBuffer bankOfNumbers = new StringBuffer();
061:                for (long i = 0; i < quantity.longValue(); i++) {
062:                    Map createProductPromoCodeMap = null;
063:                    try {
064:                        createProductPromoCodeMap = dispatcher.runSync(
065:                                "createProductPromoCode", dctx
066:                                        .makeValidContext(
067:                                                "createProductPromoCode", "IN",
068:                                                context));
069:                    } catch (GenericServiceException err) {
070:                        return ServiceUtil.returnError(
071:                                "Could not create a bank of promo codes", null,
072:                                null, createProductPromoCodeMap);
073:                    }
074:                    if (ServiceUtil.isError(createProductPromoCodeMap)) {
075:                        // what to do here? try again?
076:                        return ServiceUtil.returnError(
077:                                "Could not create a bank of promo codes", null,
078:                                null, createProductPromoCodeMap);
079:                    }
080:                    bankOfNumbers.append((String) createProductPromoCodeMap
081:                            .get("productPromoCodeId"));
082:                    bankOfNumbers.append("<br>");
083:                }
084:
085:                return ServiceUtil.returnSuccess(bankOfNumbers.toString());
086:            }
087:
088:            public static Map purgeOldStoreAutoPromos(DispatchContext dctx,
089:                    Map context) {
090:                GenericDelegator delegator = dctx.getDelegator();
091:                String productStoreId = (String) context.get("productStoreId");
092:                Timestamp nowTimestamp = UtilDateTime.nowTimestamp();
093:
094:                List condList = new LinkedList();
095:                if (UtilValidate.isEmpty(productStoreId)) {
096:                    condList.add(new EntityExpr("productStoreId",
097:                            EntityOperator.EQUALS, productStoreId));
098:                }
099:                condList.add(new EntityExpr("userEntered",
100:                        EntityOperator.EQUALS, "Y"));
101:                condList.add(new EntityExpr("thruDate",
102:                        EntityOperator.NOT_EQUAL, null));
103:                condList.add(new EntityExpr("thruDate",
104:                        EntityOperator.LESS_THAN, nowTimestamp));
105:                EntityCondition cond = new EntityConditionList(condList,
106:                        EntityOperator.AND);
107:
108:                try {
109:                    EntityListIterator eli = delegator
110:                            .findListIteratorByCondition(
111:                                    "ProductStorePromoAndAppl", cond, null,
112:                                    null);
113:                    GenericValue productStorePromoAndAppl = null;
114:                    while ((productStorePromoAndAppl = (GenericValue) eli
115:                            .next()) != null) {
116:                        GenericValue productStorePromo = delegator.makeValue(
117:                                "ProductStorePromo", null);
118:                        productStorePromo.setAllFields(
119:                                productStorePromoAndAppl, true, null, null);
120:                        productStorePromo.remove();
121:                    }
122:                    eli.close();
123:                } catch (GenericEntityException e) {
124:                    String errMsg = "Error removing expired ProductStorePromo records: "
125:                            + e.toString();
126:                    Debug.logError(e, errMsg, module);
127:                    return ServiceUtil.returnError(errMsg);
128:                }
129:
130:                return ServiceUtil.returnSuccess();
131:            }
132:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.