1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.impl.extension;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.core.api.CoreConstants;
20 import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
21 import org.kuali.rice.kew.api.extension.ExtensionDefinition;
22 import org.kuali.rice.kew.api.extension.ExtensionRepositoryService;
23 import org.kuali.rice.kew.rule.bo.RuleAttribute;
24 import org.kuali.rice.kew.rule.service.RuleAttributeService;
25 import org.w3c.dom.Element;
26
27 import javax.xml.bind.annotation.XmlAccessType;
28 import javax.xml.bind.annotation.XmlAccessorType;
29 import javax.xml.bind.annotation.XmlAnyElement;
30 import javax.xml.bind.annotation.XmlElement;
31 import javax.xml.bind.annotation.XmlRootElement;
32 import javax.xml.bind.annotation.XmlType;
33 import java.util.Collection;
34
35
36
37
38
39
40
41 @XmlRootElement(name = ExtensionRepositoryServiceImpl.Constants.ROOT_ELEMENT_NAME)
42 @XmlAccessorType(XmlAccessType.NONE)
43 @XmlType(name = ExtensionRepositoryServiceImpl.Constants.TYPE_NAME, propOrder = {
44 ExtensionRepositoryServiceImpl.Elements.RULE_ATTRIBUTE_SERVICE,
45 CoreConstants.CommonElements.FUTURE_ELEMENTS
46 })
47 public class ExtensionRepositoryServiceImpl implements ExtensionRepositoryService {
48
49
50
51
52
53 private ExtensionRepositoryServiceImpl() {
54 this.ruleAttributeService = null;
55 }
56
57 @XmlElement(name = Elements.RULE_ATTRIBUTE_SERVICE, required = true)
58 private RuleAttributeService ruleAttributeService;
59
60
61 @Override
62 public ExtensionDefinition getExtensionById(String id) throws RiceIllegalArgumentException {
63 if (StringUtils.isBlank(id)) {
64 throw new RiceIllegalArgumentException("id was null or blank");
65 }
66 RuleAttribute ruleAttribute = ruleAttributeService.findByRuleAttributeId(id);
67 return translateFromRuleAttribute(ruleAttribute);
68 }
69
70
71 @Override
72 public ExtensionDefinition getExtensionByName(String name) throws RiceIllegalArgumentException {
73 if (StringUtils.isBlank(name)) {
74 throw new RiceIllegalArgumentException("name was null or blank");
75 }
76 RuleAttribute ruleAttribute = ruleAttributeService.findByName(name);
77 return translateFromRuleAttribute(ruleAttribute);
78 }
79
80 private ExtensionDefinition translateFromRuleAttribute(RuleAttribute ruleAttribute) {
81 return RuleAttribute.to(ruleAttribute);
82 }
83
84
85
86
87
88 public void setRuleAttributeService(RuleAttributeService ruleAttributeService) {
89 this.ruleAttributeService = ruleAttributeService;
90 }
91
92 @SuppressWarnings("unused")
93 @XmlAnyElement
94 private final Collection<Element> _futureElements = null;
95
96
97
98
99
100 static class Constants {
101 static final String ROOT_ELEMENT_NAME = "extensionRepositoryService";
102 static final String TYPE_NAME = "ExtensionRepositoryService";
103 }
104
105
106
107
108
109 static class Elements {
110 static final String RULE_ATTRIBUTE_SERVICE = "ruleAttributeService";
111 }
112 }