KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ofbiz > workflow > WfUtil


1 /*
2  * $Id: WfUtil.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  */

25 package org.ofbiz.workflow;
26
27 import java.util.Map JavaDoc;
28
29 import org.ofbiz.base.util.UtilMisc;
30
31 /**
32  * WorkflowUtil - Workflow Engine Utilities
33  *
34  * @author <a HREF="mailto:jaz@ofbiz.org">Andy Zeneski</a>
35  * @version $Rev: 5462 $
36  * @since 2.0
37  */

38 public final class WfUtil {
39     
40     private static final Map JavaDoc typeMap = UtilMisc.toMap("WDT_BOOLEAN", "java.lang.Boolean",
41         "WDT_STRING", "java.lang.String", "WDT_INTEGER", "java.lang.Long",
42         "WDT_FLOAT", "java.lang.Double", "WDT_DATETIME", "java.sql.Timestamp");
43                       
44     /**
45      * Gets the Java type from a XPDL datatype
46      * @param xpdlType XPDL data type to be translated
47      * @return Java Class name equivalence to the XPDL data type
48      */

49     public static final String JavaDoc getJavaType(String JavaDoc xpdlType) {
50         if (typeMap.containsKey(xpdlType))
51             return (String JavaDoc) typeMap.get(xpdlType);
52         else
53             return "java.lang.Object";
54     }
55     
56     /**
57      * Returns the OFB status code which refers to the passed OMG status code
58      * @param state
59      * @return String
60      */

61     public static String JavaDoc getOFBStatus(String JavaDoc state) {
62         String JavaDoc statesArr[] = {"open.running", "open.not_running.not_started", "open.not_running.suspended",
63                 "closed.completed", "closed.terminated", "closed.aborted"};
64         String JavaDoc entityArr[] = {"WF_RUNNING", "WF_NOT_STARTED", "WF_SUSPENDED", "WF_COMPLETED",
65                 "WF_TERMINATED", "WF_ABORTED"};
66
67         for (int i = 0; i < statesArr.length; i++) {
68             if (statesArr[i].equals(state))
69                 return entityArr[i];
70         }
71         return null;
72     }
73
74     /**
75      * Returns the OMG status code which refers to the passed OFB status code
76      * @param state
77      * @return String
78      */

79     public static String JavaDoc getOMGStatus(String JavaDoc state) {
80         String JavaDoc statesArr[] = {"open.running", "open.not_running.not_started", "open.not_running.suspended",
81                 "closed.completed", "closed.terminated", "closed.aborted"};
82         String JavaDoc entityArr[] = {"WF_RUNNING", "WF_NOT_STARTED", "WF_SUSPENDED", "WF_COMPLETED",
83                 "WF_TERMINATED", "WF_ABORTED"};
84
85         for (int i = 0; i < entityArr.length; i++) {
86             if (entityArr[i].equals(state))
87                 return statesArr[i];
88         }
89         return null;
90     }
91     
92     
93 }
94
Popular Tags