01: /*
02: * $Id: TaskWorker.java,v 1.1 2003/08/19 06:42:54 ajzeneski Exp $
03: *
04: * Copyright (c) 2001, 2002 The Open For Business Project - www.ofbiz.org
05: *
06: * Permission is hereby granted, free of charge, to any person obtaining a
07: * copy of this software and associated documentation files (the "Software"),
08: * to deal in the Software without restriction, including without limitation
09: * 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;
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 $Revision: 1.1 $
38: * @since 2.0
39: */
40: public class TaskWorker {
41:
42: public static final String module = TaskWorker.class.getName();
43:
44: public static String getCustomerName(GenericValue orderTaskList) {
45: String lastName = orderTaskList.getString("customerLastName");
46: String firstName = orderTaskList.getString("customerFirstName");
47: //String groupName = orderTaskList.getString("customerGroupName");
48: String groupName = null; // this is only until the entity gets fixed
49: if (groupName != null) {
50: return groupName;
51: } else if (lastName != null) {
52: String name = lastName;
53: if (firstName != null)
54: name = name + ", " + firstName;
55: return name;
56: } else {
57: return "";
58: }
59: }
60:
61: static Map statusMapping = UtilMisc.toMap("WF_NOT_STARTED",
62: "Waiting", "WF_RUNNING", "Active", "WF_COMPLETE",
63: "Complete", "WF_SUSPENDED", "Hold");
64:
65: public static String getPrettyStatus(GenericValue orderTaskList) {
66: String statusId = orderTaskList.getString("currentStatusId");
67: String prettyStatus = (String) statusMapping.get(statusId);
68: if (prettyStatus == null)
69: prettyStatus = "?";
70: return prettyStatus;
71: }
72:
73: public static String getRoleDescription(GenericValue orderTaskList) {
74: GenericValue role = null;
75: try {
76: Map pkFields = UtilMisc.toMap("roleTypeId", orderTaskList
77: .getString("roleTypeId"));
78: role = orderTaskList.getDelegator().findByPrimaryKey(
79: "RoleType", pkFields);
80: } catch (GenericEntityException e) {
81: Debug.logError(e, "Cannot get RoleType entity value",
82: module);
83: return orderTaskList.getString("roleTypeId");
84: }
85: return role.getString("description");
86: }
87:
88: }
|