01: /*******************************************************************************
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: *******************************************************************************/package org.ofbiz.workflow;
19:
20: import java.util.Map;
21:
22: import org.ofbiz.base.util.UtilMisc;
23:
24: /**
25: * WorkflowUtil - Workflow Engine Utilities
26: */
27: public final class WfUtil {
28:
29: private static final Map typeMap = UtilMisc.toMap("WDT_BOOLEAN",
30: "java.lang.Boolean", "WDT_STRING", "java.lang.String",
31: "WDT_INTEGER", "java.lang.Long", "WDT_FLOAT",
32: "java.lang.Double", "WDT_DATETIME", "java.sql.Timestamp");
33:
34: /**
35: * Gets the Java type from a XPDL datatype
36: * @param xpdlType XPDL data type to be translated
37: * @return Java Class name equivalence to the XPDL data type
38: */
39: public static final String getJavaType(String xpdlType) {
40: if (typeMap.containsKey(xpdlType))
41: return (String) typeMap.get(xpdlType);
42: else
43: return "java.lang.Object";
44: }
45:
46: /**
47: * Returns the OFB status code which refers to the passed OMG status code
48: * @param state
49: * @return String
50: */
51: public static String getOFBStatus(String state) {
52: String statesArr[] = { "open.running",
53: "open.not_running.not_started",
54: "open.not_running.suspended", "closed.completed",
55: "closed.terminated", "closed.aborted" };
56: String entityArr[] = { "WF_RUNNING", "WF_NOT_STARTED",
57: "WF_SUSPENDED", "WF_COMPLETED", "WF_TERMINATED",
58: "WF_ABORTED" };
59:
60: for (int i = 0; i < statesArr.length; i++) {
61: if (statesArr[i].equals(state))
62: return entityArr[i];
63: }
64: return null;
65: }
66:
67: /**
68: * Returns the OMG status code which refers to the passed OFB status code
69: * @param state
70: * @return String
71: */
72: public static String getOMGStatus(String state) {
73: String statesArr[] = { "open.running",
74: "open.not_running.not_started",
75: "open.not_running.suspended", "closed.completed",
76: "closed.terminated", "closed.aborted" };
77: String entityArr[] = { "WF_RUNNING", "WF_NOT_STARTED",
78: "WF_SUSPENDED", "WF_COMPLETED", "WF_TERMINATED",
79: "WF_ABORTED" };
80:
81: for (int i = 0; i < entityArr.length; i++) {
82: if (entityArr[i].equals(state))
83: return statesArr[i];
84: }
85: return null;
86: }
87:
88: }
|