KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ofbiz > order > task > TaskWorker


1 /*
2  * $Id: TaskWorker.java 5462 2005-08-05 18:35:48Z jonesde $
3  *
4  * Copyright (c) 2001, 2002 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 package org.ofbiz.order.task;
25
26 import java.util.Map JavaDoc;
27
28 import org.ofbiz.base.util.Debug;
29 import org.ofbiz.base.util.UtilMisc;
30 import org.ofbiz.entity.GenericEntityException;
31 import org.ofbiz.entity.GenericValue;
32
33 /**
34  * Order Processing Task Worker
35  *
36  * @author <a HREF="mailto:jaz@ofbiz.org">Andy Zeneski</a>
37  * @version $Rev: 5462 $
38  * @since 2.0
39  */

40 public class TaskWorker {
41     
42     public static final String JavaDoc module = TaskWorker.class.getName();
43     
44     public static String JavaDoc getCustomerName(GenericValue orderTaskList) {
45         String JavaDoc lastName = orderTaskList.getString("customerLastName");
46         String JavaDoc firstName = orderTaskList.getString("customerFirstName");
47         //String groupName = orderTaskList.getString("customerGroupName");
48
String JavaDoc groupName = null; // this is only until the entity gets fixed
49
if (groupName != null) {
50             return groupName;
51         } else if (lastName != null) {
52             String JavaDoc name = lastName;
53             if (firstName != null)
54                 name = name + ", " + firstName;
55             return name;
56         } else {
57             return "";
58         }
59     }
60     
61     static Map JavaDoc statusMapping = UtilMisc.toMap("WF_NOT_STARTED", "Waiting", "WF_RUNNING", "Active", "WF_COMPLETE", "Complete", "WF_SUSPENDED", "Hold");
62     
63     public static String JavaDoc getPrettyStatus(GenericValue orderTaskList) {
64         String JavaDoc statusId = orderTaskList.getString("currentStatusId");
65         String JavaDoc prettyStatus = (String JavaDoc) statusMapping.get(statusId);
66         if (prettyStatus == null)
67             prettyStatus = "?";
68         return prettyStatus;
69     }
70         
71      
72     public static String JavaDoc getRoleDescription(GenericValue orderTaskList) {
73         GenericValue role = null;
74         try {
75             Map JavaDoc pkFields = UtilMisc.toMap("roleTypeId", orderTaskList.getString("roleTypeId"));
76             role = orderTaskList.getDelegator().findByPrimaryKey("RoleType", pkFields);
77         } catch (GenericEntityException e) {
78             Debug.logError(e, "Cannot get RoleType entity value", module);
79             return orderTaskList.getString("roleTypeId");
80         }
81         return role.getString("description");
82     }
83     
84 }
85
Popular Tags