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


001:        /*
002:         * $Id: BOMServices.java,v 1.2 2004/02/17 11:27:39 jacopo 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
007:         * copy of this software and associated documentation files (the "Software"),
008:         * to deal in the Software without restriction, including without limitation
009:         * the rights to use, copy, modify, merge, publish, distribute, sublicense,
010:         * and/or sell copies of the Software, and to permit persons to whom the
011:         * Software is furnished to do so, subject to the following conditions:
012:         *
013:         * The above copyright notice and this permission notice shall be included
014:         * in all copies or substantial portions of the Software.
015:         *
016:         * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
017:         * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
018:         * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
019:         * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
020:         * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
021:         * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
022:         * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
023:         *
024:         */
025:        package org.ofbiz.manufacturing.bom;
026:
027:        import java.sql.Timestamp;
028:        import java.util.ArrayList;
029:        import java.util.HashMap;
030:        import java.util.Iterator;
031:        import java.util.List;
032:        import java.util.Locale;
033:        import java.util.Map;
034:        import java.util.Date;
035:
036:        import org.ofbiz.base.util.Debug;
037:        import org.ofbiz.base.util.UtilDateTime;
038:        import org.ofbiz.base.util.UtilMisc;
039:        import org.ofbiz.base.util.UtilValidate;
040:        import org.ofbiz.entity.GenericDelegator;
041:        import org.ofbiz.entity.GenericEntityException;
042:        import org.ofbiz.entity.GenericValue;
043:        import org.ofbiz.security.Security;
044:        import org.ofbiz.service.DispatchContext;
045:        import org.ofbiz.service.GenericServiceException;
046:        import org.ofbiz.service.LocalDispatcher;
047:        import org.ofbiz.service.ServiceUtil;
048:
049:        /** Bills of Materials' services implementation.
050:         * These services are useful when dealing with product's
051:         * bills of materials.
052:         * @author <a href="mailto:tiz@sastau.it">Jacopo Cappellato</a>
053:         */
054:        public class BOMServices {
055:
056:            public static final String module = BOMServices.class.getName();
057:
058:            /** Returns the product's low level code (llc) i.e. the maximum depth
059:             * in which the productId can be found in any of the
060:             * bills of materials of bomType type.
061:             * @param dctx
062:             * @param context
063:             * @return
064:             */
065:            public static Map getMaxDepth(DispatchContext dctx, Map context) {
066:
067:                Map result = new HashMap();
068:                Security security = dctx.getSecurity();
069:                GenericDelegator delegator = dctx.getDelegator();
070:                LocalDispatcher dispatcher = dctx.getDispatcher();
071:                String productId = (String) context.get("productId");
072:                String fromDateStr = (String) context.get("fromDate");
073:                String bomType = (String) context.get("bomType");
074:
075:                Date fromDate = null;
076:                if (UtilValidate.isNotEmpty(fromDateStr)) {
077:                    try {
078:                        fromDate = Timestamp.valueOf(fromDateStr);
079:                    } catch (Exception e) {
080:                    }
081:                }
082:                if (fromDate == null) {
083:                    fromDate = new Date();
084:                }
085:
086:                Integer depth = null;
087:                try {
088:                    depth = new Integer(BOMHelper.getMaxDepth(productId,
089:                            bomType, fromDate, delegator));
090:                } catch (GenericEntityException gee) {
091:                    return ServiceUtil
092:                            .returnError("Error running max depth algorithm: "
093:                                    + gee.getMessage());
094:                }
095:
096:                result.put("depth", depth);
097:
098:                return result;
099:            }
100:
101:            /** Returns the ProductAssoc generic value for a duplicate productIdKey
102:             * ancestor if present, null otherwise.
103:             * Useful to avoid loops when adding new assocs (components)
104:             * to a bill of materials.
105:             * @param dctx
106:             * @param context
107:             * @return
108:             */
109:            public static Map searchDuplicatedAncestor(DispatchContext dctx,
110:                    Map context) {
111:
112:                Map result = new HashMap();
113:                Security security = dctx.getSecurity();
114:                GenericDelegator delegator = dctx.getDelegator();
115:                LocalDispatcher dispatcher = dctx.getDispatcher();
116:                String productId = (String) context.get("productId");
117:                String productIdKey = (String) context.get("productIdKey");
118:                String fromDateStr = (String) context.get("fromDate");
119:                String bomType = (String) context.get("bomType");
120:
121:                Date fromDate = null;
122:                if (UtilValidate.isNotEmpty(fromDateStr)) {
123:                    try {
124:                        fromDate = Timestamp.valueOf(fromDateStr);
125:                    } catch (Exception e) {
126:                    }
127:                }
128:                if (fromDate == null) {
129:                    fromDate = new Date();
130:                }
131:
132:                GenericValue duplicatedProductAssoc = null;
133:                try {
134:                    duplicatedProductAssoc = BOMHelper
135:                            .searchDuplicatedAncestor(productId, productIdKey,
136:                                    bomType, fromDate, delegator);
137:                } catch (GenericEntityException gee) {
138:                    return ServiceUtil
139:                            .returnError("Error running duplicated ancestor search: "
140:                                    + gee.getMessage());
141:                }
142:
143:                result.put("duplicatedProductAssoc", duplicatedProductAssoc);
144:
145:                return result;
146:            }
147:
148:            /** It reads the product's bill of materials,
149:             * if necessary configure it, and it returns
150:             * an object (see {@link ItemConfigurationTree}
151:             * and {@link ItemConfigurationNode}) that represents a
152:             * configured bill of material tree.
153:             * Useful for tree traversal (breakdown, explosion, implosion).
154:             * @param dctx
155:             * @param context
156:             * @return
157:             */
158:            public static Map getItemConfigurationTree(DispatchContext dctx,
159:                    Map context) {
160:
161:                Map result = new HashMap();
162:                Security security = dctx.getSecurity();
163:                GenericDelegator delegator = dctx.getDelegator();
164:                LocalDispatcher dispatcher = dctx.getDispatcher();
165:                String productId = (String) context.get("productId");
166:                String fromDateStr = (String) context.get("fromDate");
167:                String bomType = (String) context.get("bomType");
168:                Boolean explosion = (Boolean) context.get("explosion");
169:                if (explosion == null) {
170:                    explosion = new Boolean(true);
171:                }
172:
173:                Date fromDate = null;
174:                if (UtilValidate.isNotEmpty(fromDateStr)) {
175:                    try {
176:                        fromDate = Timestamp.valueOf(fromDateStr);
177:                    } catch (Exception e) {
178:                    }
179:                }
180:                if (fromDate == null) {
181:                    fromDate = new Date();
182:                }
183:
184:                ItemConfigurationTree tree = null;
185:                try {
186:                    tree = new ItemConfigurationTree(productId, bomType,
187:                            fromDate, explosion.booleanValue(), delegator);
188:                } catch (GenericEntityException gee) {
189:                    return ServiceUtil
190:                            .returnError("Error creating bill of materials tree: "
191:                                    + gee.getMessage());
192:                }
193:
194:                result.put("tree", tree);
195:
196:                return result;
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.