Coverage Report - org.kuali.rice.kew.impl.extension.ExtensionRepositoryServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
ExtensionRepositoryServiceImpl
0%
0/15
0%
0/4
1.8
ExtensionRepositoryServiceImpl$Constants
0%
0/1
N/A
1.8
ExtensionRepositoryServiceImpl$Elements
0%
0/1
N/A
1.8
 
 1  
 /**
 2  
  * Copyright 2005-2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 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  
  * Reference implementation of the {@code ExtensionRepositoryService}.  This implementation
 37  
  * essentially sits on top of the legacy "RuleAttribute" service.
 38  
  *
 39  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 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  
      * Private constructor used only by JAXB.
 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  
          * Returns the {@link ExtensionDefinition} of the {@Link RuleAttribute} for the given id.
 62  
          * @param id the id to search by.
 63  
      * @return the extension definition found for the matching rule attribute service
 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  
          * Returns the {@link ExtensionDefinition} of the {@Link RuleAttribute} for the given name.
 76  
          * @param name the name to search by.
 77  
      * @return the extension definition found for the matching rule attribute service
 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  
          * Sets the rule attribute service.
 94  
          * @param ruleAttributeService the rule attribute service to set.
 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  
      * Defines some internal constants used on this class.
 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  
      * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
 115  
      *
 116  
      */
 117  0
     static class Elements {
 118  
         static final String RULE_ATTRIBUTE_SERVICE = "ruleAttributeService";
 119  
     }
 120  
 }