KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ofbiz > common > status > StatusWorker


1 /*
2  * $Id: StatusWorker.java 5462 2005-08-05 18:35:48Z jonesde $
3  *
4  * Copyright (c) 2001-2005 The Open For Business Project - www.ofbiz.org
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
21  * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
22  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  *
24  */

25 package org.ofbiz.common.status;
26
27 import java.util.Collection JavaDoc;
28 import java.util.LinkedList JavaDoc;
29 import java.util.List JavaDoc;
30
31 import javax.servlet.jsp.PageContext JavaDoc;
32
33 import org.ofbiz.base.util.Debug;
34 import org.ofbiz.base.util.UtilMisc;
35 import org.ofbiz.entity.GenericDelegator;
36 import org.ofbiz.entity.GenericEntityException;
37
38 /**
39  * StatusWorker
40  *
41  * @author <a HREF="mailto:jonesde@ofbiz.org">David E. Jones</a>
42  * @version $Rev: 5462 $
43  * @since 2.0
44  */

45 public class StatusWorker {
46     
47     public static final String JavaDoc module = StatusWorker.class.getName();
48     
49     public static void getStatusItems(PageContext JavaDoc pageContext, String JavaDoc attributeName, String JavaDoc statusTypeId) {
50         GenericDelegator delegator = (GenericDelegator) pageContext.getRequest().getAttribute("delegator");
51
52         try {
53             Collection JavaDoc statusItems = delegator.findByAndCache("StatusItem", UtilMisc.toMap("statusTypeId", statusTypeId), UtilMisc.toList("sequenceId"));
54
55             if (statusItems != null)
56                 pageContext.setAttribute(attributeName, statusItems);
57         } catch (GenericEntityException e) {
58             Debug.logError(e, module);
59         }
60     }
61
62     public static void getStatusItems(PageContext JavaDoc pageContext, String JavaDoc attributeName, String JavaDoc statusTypeIdOne, String JavaDoc statusTypeIdTwo) {
63         GenericDelegator delegator = (GenericDelegator) pageContext.getRequest().getAttribute("delegator");
64         List JavaDoc statusItems = new LinkedList JavaDoc();
65
66         try {
67             Collection JavaDoc calItems = delegator.findByAndCache("StatusItem", UtilMisc.toMap("statusTypeId", statusTypeIdOne), UtilMisc.toList("sequenceId"));
68
69             if (calItems != null)
70                 statusItems.addAll(calItems);
71         } catch (GenericEntityException e) {
72             Debug.logError(e, module);
73         }
74         try {
75             Collection JavaDoc taskItems = delegator.findByAndCache("StatusItem", UtilMisc.toMap("statusTypeId", statusTypeIdTwo), UtilMisc.toList("sequenceId"));
76
77             if (taskItems != null)
78                 statusItems.addAll(taskItems);
79         } catch (GenericEntityException e) {
80             Debug.logError(e, module);
81         }
82
83         if (statusItems.size() > 0)
84             pageContext.setAttribute(attributeName, statusItems);
85     }
86
87     public static void getStatusValidChangeToDetails(PageContext JavaDoc pageContext, String JavaDoc attributeName, String JavaDoc statusId) {
88         GenericDelegator delegator = (GenericDelegator) pageContext.getRequest().getAttribute("delegator");
89         Collection JavaDoc statusValidChangeToDetails = null;
90
91         try {
92             statusValidChangeToDetails = delegator.findByAndCache("StatusValidChangeToDetail", UtilMisc.toMap("statusId", statusId), UtilMisc.toList("sequenceId"));
93         } catch (GenericEntityException e) {
94             Debug.logError(e, module);
95         }
96
97         if (statusValidChangeToDetails != null)
98             pageContext.setAttribute(attributeName, statusValidChangeToDetails);
99     }
100 }
101
Popular Tags