1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krms.impl.ui;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
20 import org.kuali.rice.krms.api.repository.operator.CustomOperator;
21 import org.kuali.rice.krms.impl.util.KrmsImplConstants;
22
23 import javax.xml.namespace.QName;
24
25
26
27
28
29
30 public class CustomOperatorUiTranslator {
31
32
33
34
35
36
37
38
39
40 public QName parseCustomOperatorServiceQName(String customOperatorFormValue) {
41 if (customOperatorFormValue == null ||
42 !isCustomOperatorFormValue(customOperatorFormValue)) {
43 throw new IllegalArgumentException("custom operator form value (" + customOperatorFormValue +
44 ") must be formatted as " +
45 KrmsImplConstants.CUSTOM_OPERATOR_PREFIX + "namespace:serviceName");
46 }
47
48 String [] customOperatorServiceInfo = customOperatorFormValue.split(":");
49
50 if (customOperatorServiceInfo == null || customOperatorServiceInfo.length != 3) {
51 throw new IllegalArgumentException("custom operator form value (" + customOperatorFormValue +
52 ") must be formatted as " +
53 KrmsImplConstants.CUSTOM_OPERATOR_PREFIX + "namespace:serviceName");
54 }
55
56 QName customOperatorServiceQName = new QName(customOperatorServiceInfo[1], customOperatorServiceInfo[2]);
57
58 return customOperatorServiceQName;
59 }
60
61
62
63
64
65
66
67 public String getCustomOperatorName(String customOperatorFormValue) {
68 return getCustomOperator(customOperatorFormValue).getOperatorFunctionDefinition().getName();
69 }
70
71
72
73
74
75
76
77
78
79
80 public CustomOperator getCustomOperator(String customOperatorFormValue) {
81 return GlobalResourceLoader.getService(parseCustomOperatorServiceQName(customOperatorFormValue));
82 }
83
84
85
86
87
88
89
90
91
92 public boolean isCustomOperatorFormValue(String formValue) {
93 if (StringUtils.isEmpty(formValue)) {
94 return false;
95 }
96
97 return formValue.startsWith(KrmsImplConstants.CUSTOM_OPERATOR_PREFIX);
98 }
99
100 }