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


001:        /*******************************************************************************
002:         * Licensed to the Apache Software Foundation (ASF) under one
003:         * or more contributor license agreements.  See the NOTICE file
004:         * distributed with this work for additional information
005:         * regarding copyright ownership.  The ASF licenses this file
006:         * to you under the Apache License, Version 2.0 (the
007:         * "License"); you may not use this file except in compliance
008:         * with the License.  You may obtain a copy of the License at
009:         * 
010:         * http://www.apache.org/licenses/LICENSE-2.0
011:         * 
012:         * Unless required by applicable law or agreed to in writing,
013:         * software distributed under the License is distributed on an
014:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015:         * KIND, either express or implied.  See the License for the
016:         * specific language governing permissions and limitations
017:         * under the License.
018:         *******************************************************************************/package org.ofbiz.workeffort.project;
019:
020:        import java.util.ArrayList;
021:        import java.util.Collection;
022:        import java.util.Iterator;
023:
024:        import javax.servlet.jsp.PageContext;
025:
026:        import org.ofbiz.base.util.Debug;
027:        import org.ofbiz.base.util.UtilMisc;
028:        import org.ofbiz.entity.GenericDelegator;
029:        import org.ofbiz.entity.GenericEntityException;
030:        import org.ofbiz.entity.GenericValue;
031:        import org.ofbiz.entity.condition.EntityExpr;
032:        import org.ofbiz.entity.condition.EntityOperator;
033:
034:        /**
035:         * WorkEffortWorker - Worker class to reduce code in JSPs & make it more reusable
036:         */
037:        public class ProjectWorker {
038:
039:            public static final String module = ProjectWorker.class.getName();
040:
041:            public static void getAssignedProjects(PageContext pageContext,
042:                    String projectsAttrName) {
043:                GenericDelegator delegator = (GenericDelegator) pageContext
044:                        .getRequest().getAttribute("delegator");
045:                GenericValue userLogin = (GenericValue) pageContext
046:                        .getSession().getAttribute("userLogin");
047:
048:                Collection validWorkEfforts = null;
049:
050:                if (userLogin != null && userLogin.get("partyId") != null) {
051:                    try {
052:                        validWorkEfforts = delegator.findByAnd(
053:                                "WorkEffortAndPartyAssign", UtilMisc.toList(
054:                                        new EntityExpr("partyId",
055:                                                EntityOperator.EQUALS,
056:                                                userLogin.get("partyId")),
057:                                        new EntityExpr("currentStatusId",
058:                                                EntityOperator.NOT_EQUAL,
059:                                                "WF_COMPLETED"),
060:                                        new EntityExpr("currentStatusId",
061:                                                EntityOperator.NOT_EQUAL,
062:                                                "WF_TERMINATED"),
063:                                        new EntityExpr("currentStatusId",
064:                                                EntityOperator.NOT_EQUAL,
065:                                                "WF_ABORTED"), new EntityExpr(
066:                                                "workEffortTypeId",
067:                                                EntityOperator.EQUALS, "TASK"),
068:                                        new EntityExpr(
069:                                                "workEffortPurposeTypeId",
070:                                                EntityOperator.EQUALS,
071:                                                "WEPT_PROJECT")), UtilMisc
072:                                        .toList("priority"));
073:                    } catch (GenericEntityException e) {
074:                        Debug.logWarning(e, module);
075:                    }
076:                }
077:                if (validWorkEfforts == null || validWorkEfforts.size() <= 0)
078:                    return;
079:
080:                pageContext.setAttribute(projectsAttrName, validWorkEfforts);
081:            }
082:
083:            public static void getAllAssignedProjects(PageContext pageContext,
084:                    String projectsAttrName) {
085:                GenericDelegator delegator = (GenericDelegator) pageContext
086:                        .getRequest().getAttribute("delegator");
087:                GenericValue userLogin = (GenericValue) pageContext
088:                        .getSession().getAttribute("userLogin");
089:
090:                Collection validWorkEfforts = null;
091:
092:                if (userLogin != null && userLogin.get("partyId") != null) {
093:                    try {
094:                        validWorkEfforts = delegator.findByAnd(
095:                                "WorkEffortAndPartyAssign", UtilMisc.toList(
096:                                        new EntityExpr("partyId",
097:                                                EntityOperator.EQUALS,
098:                                                userLogin.get("partyId")),
099:                                        new EntityExpr("workEffortTypeId",
100:                                                EntityOperator.EQUALS, "TASK"),
101:                                        new EntityExpr(
102:                                                "workEffortPurposeTypeId",
103:                                                EntityOperator.EQUALS,
104:                                                "WEPT_PROJECT")), UtilMisc
105:                                        .toList("priority"));
106:                    } catch (GenericEntityException e) {
107:                        Debug.logWarning(e, module);
108:                    }
109:                }
110:                if (validWorkEfforts == null || validWorkEfforts.size() <= 0)
111:                    return;
112:
113:                pageContext.setAttribute(projectsAttrName, validWorkEfforts);
114:            }
115:
116:            public static void getAllProjectPhases(PageContext pageContext,
117:                    String phasesAttrName) {
118:                GenericDelegator delegator = (GenericDelegator) pageContext
119:                        .getRequest().getAttribute("delegator");
120:                GenericValue userLogin = (GenericValue) pageContext
121:                        .getSession().getAttribute("userLogin");
122:
123:                String projectWorkEffortId = pageContext.getRequest()
124:                        .getParameter("projectWorkEffortId");
125:
126:                // if there was no parameter, check the request attribute, this may be a newly created entity
127:                if (projectWorkEffortId == null)
128:                    projectWorkEffortId = (String) pageContext.getRequest()
129:                            .getAttribute("projectWorkEffortId");
130:
131:                Collection relatedWorkEfforts = null;
132:
133:                if (userLogin != null && userLogin.get("partyId") != null) {
134:                    try {
135:                        relatedWorkEfforts = delegator.findByAnd(
136:                                "WorkEffortAssoc", UtilMisc.toList(
137:                                        new EntityExpr("workEffortIdFrom",
138:                                                EntityOperator.EQUALS,
139:                                                projectWorkEffortId),
140:                                        new EntityExpr("workEffortAssocTypeId",
141:                                                EntityOperator.EQUALS,
142:                                                "WORK_EFF_BREAKDOWN")));
143:                    } catch (GenericEntityException e) {
144:                        Debug.logWarning(e, module);
145:                    }
146:                }
147:
148:                Collection validWorkEfforts = new ArrayList();
149:
150:                if (relatedWorkEfforts != null) {
151:                    Iterator relatedWorkEffortsIter = relatedWorkEfforts
152:                            .iterator();
153:
154:                    try {
155:                        while (relatedWorkEffortsIter.hasNext()) {
156:                            GenericValue workEffortAssoc = (GenericValue) relatedWorkEffortsIter
157:                                    .next();
158:                            GenericValue workEffort = workEffortAssoc
159:                                    .getRelatedOne("ToWorkEffort");
160:
161:                            // only get phases
162:                            if ("TASK".equals(workEffort
163:                                    .getString("workEffortTypeId"))
164:                                    && ("WEPT_PHASE"
165:                                            .equals(workEffort
166:                                                    .getString("workEffortPurposeTypeId")))) {
167:                                validWorkEfforts.add(workEffort);
168:                            }
169:                        }
170:                    } catch (GenericEntityException e) {
171:                        Debug.logWarning(e, module);
172:                    }
173:                }
174:                if (validWorkEfforts == null || validWorkEfforts.size() <= 0)
175:                    return;
176:
177:                pageContext.setAttribute(phasesAttrName, validWorkEfforts);
178:            }
179:
180:            public static void getAllPhaseTasks(PageContext pageContext,
181:                    String tasksAttrName) {
182:                GenericDelegator delegator = (GenericDelegator) pageContext
183:                        .getRequest().getAttribute("delegator");
184:                GenericValue userLogin = (GenericValue) pageContext
185:                        .getSession().getAttribute("userLogin");
186:
187:                String phaseWorkEffortId = pageContext.getRequest()
188:                        .getParameter("phaseWorkEffortId");
189:
190:                // if there was no parameter, check the request attribute, this may be a newly created entity
191:                if (phaseWorkEffortId == null)
192:                    phaseWorkEffortId = (String) pageContext.getRequest()
193:                            .getAttribute("phaseWorkEffortId");
194:
195:                Collection relatedWorkEfforts = null;
196:
197:                if (userLogin != null && userLogin.get("partyId") != null) {
198:                    try {
199:                        relatedWorkEfforts = delegator.findByAnd(
200:                                "WorkEffortAssoc", UtilMisc.toList(
201:                                        new EntityExpr("workEffortIdFrom",
202:                                                EntityOperator.EQUALS,
203:                                                phaseWorkEffortId),
204:                                        new EntityExpr("workEffortAssocTypeId",
205:                                                EntityOperator.EQUALS,
206:                                                "WORK_EFF_BREAKDOWN")));
207:                    } catch (GenericEntityException e) {
208:                        Debug.logWarning(e, module);
209:                    }
210:                }
211:
212:                Collection validWorkEfforts = new ArrayList();
213:
214:                if (relatedWorkEfforts != null) {
215:                    Iterator relatedWorkEffortsIter = relatedWorkEfforts
216:                            .iterator();
217:
218:                    try {
219:                        while (relatedWorkEffortsIter.hasNext()) {
220:                            GenericValue workEffortAssoc = (GenericValue) relatedWorkEffortsIter
221:                                    .next();
222:                            GenericValue workEffort = workEffortAssoc
223:                                    .getRelatedOne("ToWorkEffort");
224:
225:                            // only get phases
226:                            if ("TASK".equals(workEffort
227:                                    .getString("workEffortTypeId"))) {
228:                                validWorkEfforts.add(workEffort);
229:                            }
230:                        }
231:                    } catch (GenericEntityException e) {
232:                        Debug.logWarning(e, module);
233:                    }
234:                }
235:                if (validWorkEfforts == null || validWorkEfforts.size() <= 0)
236:                    return;
237:
238:                pageContext.setAttribute(tasksAttrName, validWorkEfforts);
239:            }
240:
241:            public static void getTaskNotes(PageContext pageContext,
242:                    String notesAttrName) {
243:                GenericDelegator delegator = (GenericDelegator) pageContext
244:                        .getRequest().getAttribute("delegator");
245:                GenericValue userLogin = (GenericValue) pageContext
246:                        .getSession().getAttribute("userLogin");
247:
248:                String workEffortId = pageContext.getRequest().getParameter(
249:                        "workEffortId");
250:
251:                // if there was no parameter, check the request attribute, this may be a newly created entity
252:                if (workEffortId == null)
253:                    workEffortId = (String) pageContext.getRequest()
254:                            .getAttribute("workEffortId");
255:
256:                Collection notes = null;
257:
258:                if (userLogin != null && userLogin.get("partyId") != null) {
259:                    try {
260:                        notes = delegator.findByAnd("WorkEffortNoteAndData",
261:                                UtilMisc.toList(new EntityExpr("workEffortId",
262:                                        EntityOperator.EQUALS, workEffortId)),
263:                                UtilMisc.toList("noteDateTime"));
264:                    } catch (GenericEntityException e) {
265:                        Debug.logWarning(e, module);
266:                    }
267:                }
268:                if (notes == null || notes.size() <= 0)
269:                    return;
270:
271:                pageContext.setAttribute(notesAttrName, notes);
272:            }
273:
274:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.