| 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 | 0 | private ExtensionRepositoryServiceImpl() { |
| 54 | 0 | this.ruleAttributeService = null; |
| 55 | 0 | } |
| 56 | |
|
| 57 | |
@XmlElement(name = Elements.RULE_ATTRIBUTE_SERVICE, required = true) |
| 58 | |
private RuleAttributeService ruleAttributeService; |
| 59 | |
|
| 60 | |
|
| 61 | |
|
| 62 | |
|
| 63 | |
|
| 64 | |
|
| 65 | |
@Override |
| 66 | |
public ExtensionDefinition getExtensionById(String id) throws RiceIllegalArgumentException { |
| 67 | 0 | if (StringUtils.isBlank(id)) { |
| 68 | 0 | throw new RiceIllegalArgumentException("id was null or blank"); |
| 69 | |
} |
| 70 | 0 | RuleAttribute ruleAttribute = ruleAttributeService.findByRuleAttributeId(id); |
| 71 | 0 | return translateFromRuleAttribute(ruleAttribute); |
| 72 | |
} |
| 73 | |
|
| 74 | |
|
| 75 | |
|
| 76 | |
|
| 77 | |
|
| 78 | |
|
| 79 | |
@Override |
| 80 | |
public ExtensionDefinition getExtensionByName(String name) throws RiceIllegalArgumentException { |
| 81 | 0 | if (StringUtils.isBlank(name)) { |
| 82 | 0 | throw new RiceIllegalArgumentException("name was null or blank"); |
| 83 | |
} |
| 84 | 0 | RuleAttribute ruleAttribute = ruleAttributeService.findByName(name); |
| 85 | 0 | return translateFromRuleAttribute(ruleAttribute); |
| 86 | |
} |
| 87 | |
|
| 88 | |
private ExtensionDefinition translateFromRuleAttribute(RuleAttribute ruleAttribute) { |
| 89 | 0 | return RuleAttribute.to(ruleAttribute); |
| 90 | |
} |
| 91 | |
|
| 92 | |
|
| 93 | |
|
| 94 | |
|
| 95 | |
|
| 96 | |
public void setRuleAttributeService(RuleAttributeService ruleAttributeService) { |
| 97 | 0 | this.ruleAttributeService = ruleAttributeService; |
| 98 | 0 | } |
| 99 | |
|
| 100 | 0 | @SuppressWarnings("unused") |
| 101 | |
@XmlAnyElement |
| 102 | |
private final Collection<Element> _futureElements = null; |
| 103 | |
|
| 104 | |
|
| 105 | |
|
| 106 | |
|
| 107 | |
|
| 108 | 0 | static class Constants { |
| 109 | |
static final String ROOT_ELEMENT_NAME = "extensionRepositoryService"; |
| 110 | |
static final String TYPE_NAME = "ExtensionRepositoryService"; |
| 111 | |
} |
| 112 | |
|
| 113 | |
|
| 114 | |
|
| 115 | |
|
| 116 | |
|
| 117 | 0 | static class Elements { |
| 118 | |
static final String RULE_ATTRIBUTE_SERVICE = "ruleAttributeService"; |
| 119 | |
} |
| 120 | |
} |