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


001:        /*
002:         * $Id: TechDataServices.java,v 1.4 2003/12/09 20:55:19 holivier Exp $
003:         *
004:         * Copyright (c) 2003 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.techdata;
026:
027:        import java.sql.Timestamp;
028:        import java.util.ArrayList;
029:        import java.util.Collection;
030:        import java.util.HashMap;
031:        import java.util.HashSet;
032:        import java.util.Iterator;
033:        import java.util.LinkedList;
034:        import java.util.List;
035:        import java.util.Map;
036:        import java.util.Set;
037:
038:        import org.ofbiz.base.util.Debug;
039:        import org.ofbiz.base.util.UtilDateTime;
040:        import org.ofbiz.base.util.UtilMisc;
041:        import org.ofbiz.base.util.UtilValidate;
042:        import org.ofbiz.entity.GenericDelegator;
043:        import org.ofbiz.entity.GenericEntityException;
044:        import org.ofbiz.entity.GenericValue;
045:        import org.ofbiz.entity.condition.EntityExpr;
046:        import org.ofbiz.entity.condition.EntityOperator;
047:        import org.ofbiz.entity.util.EntityUtil;
048:        import org.ofbiz.security.Security;
049:        import org.ofbiz.service.DispatchContext;
050:        import org.ofbiz.service.ServiceUtil;
051:
052:        /**
053:         * TechDataServices - TechData related Services
054:         *
055:         * @author     <a href="mailto:olivier.heintz@nereide.biz">Olivier Heintz</a>
056:         * @version    $Revision: 1.4 $
057:         * @since      3.0
058:         */
059:        public class TechDataServices {
060:
061:            public static final String module = TechDataServices.class
062:                    .getName();
063:
064:            /**
065:             * 
066:             * Used to retreive some RoutingTasks (WorkEffort) selected by Name or MachineGroup ordered by Name
067:             * 
068:             * @author holivier
069:             * @param ctx
070:             * @param context: a map containing workEffortName (routingTaskName) and fixedAssetId (MachineGroup or ANY) 
071:             * @return result: a map containing lookupResult (list of RoutingTask <=> workEffortId with currentStatusId = "ROU_ACTIVE" and workEffortTypeId = "ROU_TASK"
072:             */
073:            public static Map lookupRoutingTask(DispatchContext ctx, Map context) {
074:                GenericDelegator delegator = ctx.getDelegator();
075:                GenericValue userLogin = (GenericValue) context
076:                        .get("userLogin");
077:                /*		Security security = ctx.getSecurity();  a completer par la suite */
078:                Map result = new HashMap();
079:
080:                String workEffortName = (String) context.get("workEffortName");
081:                String fixedAssetId = (String) context.get("fixedAssetId");
082:
083:                List listRoutingTask = null;
084:                List constraints = new LinkedList();
085:
086:                if (workEffortName != null && workEffortName.length() > 0)
087:                    constraints.add(new EntityExpr("workEffortName",
088:                            EntityOperator.GREATER_THAN_EQUAL_TO,
089:                            workEffortName));
090:                if (fixedAssetId != null && fixedAssetId.length() > 0
091:                        && !"ANY".equals(fixedAssetId))
092:                    constraints.add(new EntityExpr("fixedAssetId",
093:                            EntityOperator.EQUALS, fixedAssetId));
094:
095:                constraints.add(new EntityExpr("currentStatusId",
096:                        EntityOperator.EQUALS, "ROU_ACTIVE"));
097:                constraints.add(new EntityExpr("workEffortTypeId",
098:                        EntityOperator.EQUALS, "ROU_TASK"));
099:
100:                try {
101:                    listRoutingTask = delegator.findByAnd("WorkEffort",
102:                            constraints, UtilMisc.toList("workEffortName"));
103:                } catch (GenericEntityException e) {
104:                    Debug.logWarning(e, module);
105:                    return ServiceUtil
106:                            .returnError("Error finding desired WorkEffort records: "
107:                                    + e.toString());
108:                }
109:                if (listRoutingTask == null)
110:                    listRoutingTask = new LinkedList();
111:                if (listRoutingTask.size() == 0)
112:                    listRoutingTask.add(UtilMisc.toMap("label", "no Match",
113:                            "value", "NO_MATCH"));
114:                result.put("lookupResult", listRoutingTask);
115:                return result;
116:            }
117:
118:            /**
119:             * 
120:             * Used to check if there is not two routing task with the same SeqId valid at the same period
121:             * 
122:             * @author holivier
123:             * @param ctx
124:             * @param context: a map containing workEffortIdFrom (routing) and SeqId, fromDate thruDate
125:             * @return result: a map containing sequenceNumNotOk which is equal to "Y" if it's not Ok
126:             */
127:            public static Map checkRoutingTaskAssoc(DispatchContext ctx,
128:                    Map context) {
129:                GenericDelegator delegator = ctx.getDelegator();
130:                Map result = new HashMap();
131:                String sequenceNumNotOk = "N";
132:
133:                String workEffortIdFrom = (String) context
134:                        .get("workEffortIdFrom");
135:                String workEffortIdTo = (String) context.get("workEffortIdTo");
136:                String workEffortAssocTypeId = (String) context
137:                        .get("workEffortAssocTypeId");
138:                Long sequenceNum = (Long) context.get("sequenceNum");
139:                java.sql.Timestamp fromDate = (java.sql.Timestamp) context
140:                        .get("fromDate");
141:                java.sql.Timestamp thruDate = (java.sql.Timestamp) context
142:                        .get("thruDate");
143:
144:                List listRoutingTaskAssoc = null;
145:
146:                try {
147:                    listRoutingTaskAssoc = delegator.findByAnd(
148:                            "WorkEffortAssoc", UtilMisc.toMap(
149:                                    "workEffortIdFrom", workEffortIdFrom,
150:                                    "sequenceNum", sequenceNum), UtilMisc
151:                                    .toList("fromDate"));
152:                } catch (GenericEntityException e) {
153:                    Debug.logWarning(e, module);
154:                    return ServiceUtil
155:                            .returnError("Error finding desired WorkEffortAssoc records: "
156:                                    + e.toString());
157:                }
158:
159:                if (listRoutingTaskAssoc != null) {
160:                    Iterator i = listRoutingTaskAssoc.iterator();
161:                    while (i.hasNext()) {
162:                        GenericValue routingTaskAssoc = (GenericValue) i.next();
163:                        if (!workEffortIdFrom.equals(routingTaskAssoc
164:                                .getString("workEffortIdFrom"))
165:                                || !workEffortIdTo.equals(routingTaskAssoc
166:                                        .getString("workEffortIdTo"))
167:                                || !workEffortAssocTypeId
168:                                        .equals(routingTaskAssoc
169:                                                .getString("workEffortAssocTypeId"))
170:                                || !sequenceNum.equals(routingTaskAssoc
171:                                        .getLong("sequenceNum"))) {
172:                            if (routingTaskAssoc.getTimestamp("thruDate") == null
173:                                    && routingTaskAssoc
174:                                            .getTimestamp("fromDate") == null)
175:                                sequenceNumNotOk = "Y";
176:                            else if (routingTaskAssoc.getTimestamp("thruDate") == null) {
177:                                if (thruDate == null)
178:                                    sequenceNumNotOk = "Y";
179:                                else if (thruDate.after(routingTaskAssoc
180:                                        .getTimestamp("fromDate")))
181:                                    sequenceNumNotOk = "Y";
182:                            } else if (routingTaskAssoc
183:                                    .getTimestamp("fromDate") == null) {
184:                                if (fromDate == null)
185:                                    sequenceNumNotOk = "Y";
186:                                else if (fromDate.before(routingTaskAssoc
187:                                        .getTimestamp("thruDate")))
188:                                    sequenceNumNotOk = "Y";
189:                            } else if (fromDate == null && thruDate == null)
190:                                sequenceNumNotOk = "Y";
191:                            else if (thruDate == null) {
192:                                if (fromDate.before(routingTaskAssoc
193:                                        .getTimestamp("thruDate")))
194:                                    sequenceNumNotOk = "Y";
195:                            } else if (fromDate == null) {
196:                                if (thruDate.after(routingTaskAssoc
197:                                        .getTimestamp("fromDate")))
198:                                    sequenceNumNotOk = "Y";
199:                            } else if (routingTaskAssoc
200:                                    .getTimestamp("fromDate").before(thruDate)
201:                                    && fromDate.before(routingTaskAssoc
202:                                            .getTimestamp("thruDate")))
203:                                sequenceNumNotOk = "Y";
204:                        }
205:                    }
206:                }
207:
208:                result.put("sequenceNumNotOk", sequenceNumNotOk);
209:                return result;
210:            }
211:
212:            /**
213:             * 
214:             * Used to check if the routingtaskAssoc is valid for the testDate
215:             * 
216:             * @author holivier
217:             * @param routingTaskAssoc: the routingTaskAssoc to test  
218:             * @param testDate: a date
219:             * @return true if the routingTAskAssoc is valid
220:             */
221:            public static boolean routingTaskAssocIsValid(
222:                    GenericValue routingTaskAssoc, java.sql.Timestamp testDate) {
223:                if (routingTaskAssoc.getTimestamp("fromDate") != null)
224:                    if (routingTaskAssoc.getTimestamp("thruDate") != null)
225:                        if (testDate.after(routingTaskAssoc
226:                                .getTimestamp("fromDate"))
227:                                && testDate.before(routingTaskAssoc
228:                                        .getTimestamp("thruDate")))
229:                            return true;
230:                        else
231:                            return false;
232:                    else if (testDate.after(routingTaskAssoc
233:                            .getTimestamp("fromDate")))
234:                        return true;
235:                    else
236:                        return false;
237:                else if (routingTaskAssoc.getTimestamp("thruDate") != null)
238:                    if (testDate.before(routingTaskAssoc
239:                            .getTimestamp("thruDate")))
240:                        return true;
241:                    else
242:                        return false;
243:                else
244:                    return true;
245:            }
246:
247:            /**
248:             * 
249:             * Used to check if the productBom is valid for the testDate, currently only tested on date but in futur, maybe there will be the option {valid until stock=0>}
250:             * 
251:             * @author holivier
252:             * @param productBom: the productBom to test  
253:             * @param testDate: a date
254:             * @return true if the productBom is valid
255:             */
256:            public static boolean productBomIsValid(GenericValue productBom,
257:                    java.sql.Timestamp testDate) {
258:                if (productBom.getTimestamp("fromDate") != null)
259:                    if (productBom.getTimestamp("thruDate") != null)
260:                        if (testDate.after(productBom.getTimestamp("fromDate"))
261:                                && testDate.before(productBom
262:                                        .getTimestamp("thruDate")))
263:                            return true;
264:                        else
265:                            return false;
266:                    else if (testDate
267:                            .after(productBom.getTimestamp("fromDate")))
268:                        return true;
269:                    else
270:                        return false;
271:                else if (productBom.getTimestamp("thruDate") != null)
272:                    if (testDate.before(productBom.getTimestamp("thruDate")))
273:                        return true;
274:                    else
275:                        return false;
276:                else
277:                    return true;
278:            }
279:
280:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.