Coverage Report - org.kuali.rice.krms.impl.repository.KrmsAttributeDefinitionService
 
Classes in this File Line Coverage Branch Coverage Complexity
KrmsAttributeDefinitionService
N/A
N/A
1
 
 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.krms.impl.repository;
 17  
 
 18  
 import java.util.List;
 19  
 import java.util.Map;
 20  
 
 21  
 import org.kuali.rice.krms.api.repository.type.KrmsAttributeDefinition;
 22  
 
 23  
 
 24  
 public interface KrmsAttributeDefinitionService {
 25  
 
 26  
     /**
 27  
      * This will create a {@link KrmsAttributeDefinition} exactly like the parameter passed in.
 28  
      *
 29  
      * @param attributeDefinition - KrmsAttributeDefinition
 30  
      * @throws IllegalArgumentException if the attribute definition is null
 31  
      * @throws IllegalStateException if the attribute definition already exists in the system
 32  
      */
 33  
         public KrmsAttributeDefinition createAttributeDefinition(KrmsAttributeDefinition attributeDefinition);
 34  
 
 35  
     /**
 36  
      * This will update a {@link KrmsAttributeDefinition}.
 37  
      *
 38  
      *
 39  
      * @param attributeDefinition - KrmsAttributeDefinition
 40  
      * @throws IllegalArgumentException if the attribute definition is null
 41  
      * @throws IllegalStateException if the attribute definition does not exist in the system
 42  
      */
 43  
         public void updateAttributeDefinition(KrmsAttributeDefinition attributeDefinition);
 44  
 
 45  
     /**
 46  
      * Lookup a KrmsAttributeDefinition based on the given id.
 47  
      *
 48  
      * @param id the given KrmsAttributeDefinition id
 49  
      * @return a KrmsAttributeDefinition object with the given id.  A null reference is returned if an invalid or
 50  
      *         non-existant id is supplied.
 51  
      */
 52  
         public KrmsAttributeDefinition getAttributeDefinitionById(String id);
 53  
 
 54  
     /**
 55  
      * Get a KrmsAttributeDefinition object based on name and namespace
 56  
      *
 57  
      * @param name the given name
 58  
      * @param namespace the given type namespace
 59  
      * @return A KrmsAttributeDefinition object with the given namespace and name if one with that name and namespace
 60  
      *         exists.  Otherwise, null is returned.
 61  
      * @throws IllegalStateException if multiple KrmsAttributeDefinitions exist with the same name and namespace
 62  
      */
 63  
         public KrmsAttributeDefinition getAttributeDefinitionByNameAndNamespace(String name, String namespace);
 64  
 
 65  
    /**
 66  
      * Returns all KrmsAttributeDefinition that for a given namespace.
 67  
      *
 68  
      * @return all KrmsAttributeDefinition for a namespace
 69  
      */
 70  
         public List<KrmsAttributeDefinition> findAttributeDefinitionsByNamespace(String namespace);
 71  
 
 72  
 
 73  
     /**
 74  
       * Returns all KrmsAttributeDefinition that for a given type.
 75  
       *
 76  
       * @return all KrmsAttributeDefinition for a type.  May be empty, will not be null;
 77  
       */
 78  
      public List<KrmsAttributeDefinition> findAttributeDefinitionsByType(String typeId);
 79  
 
 80  
 
 81  
     /**
 82  
      * Returns all KrmsAttributeDefinitions
 83  
      *
 84  
      * @return all KrmsAttributeDefinitions
 85  
      */
 86  
         public List<KrmsAttributeDefinition> findAllAttributeDefinitions();
 87  
 
 88  
         /**
 89  
          * This method converts a collection of name/value attribute pairs to
 90  
          * id/value attribute pairs.
 91  
          * <p>
 92  
          * At the api layer, attributes are represented as name/value pairs.
 93  
          * However, in the database, the names of the attribute and the values are
 94  
          * stored separately. The attribute definitions contain the attribute names.
 95  
          * All defined attributes(for the various krms entity types) are stored 
 96  
          * together in a single table. The attribute values themselves are stored 
 97  
          * in separate tables for each entity type, and then reference the attribute
 98  
          * definitions by the attribute definition id.
 99  
          * <p>
 100  
          * This method converts the name/value pairs to id/value pairs so they
 101  
          * can be searched from a single table. This simplifies the queries for 
 102  
          * attributes.
 103  
          * <p>
 104  
          * 
 105  
          * @param attributesByName - a Map<String/String> containing the name/value
 106  
          *         pairs for the set of attributes.
 107  
          * @param namespace - the namespace code of the set of attributes
 108  
          * @return a Map<String,String> containing the id/value pairs for the set
 109  
          * of attributes.
 110  
          */
 111  
         public Map<String,String> convertAttributeKeys(Map<String,String> attributesByName, String namespace);
 112  
 
 113  
         /**
 114  
          * This method gets the attribute definition ID for a given attribute
 115  
          * 
 116  
          * @param attributeName - the name of the attribute
 117  
          * @param namespace - the namespace code of the attribute
 118  
          * @return - the attribute definition id 
 119  
          */
 120  
         public String getKrmsAttributeId( String attributeName, String namespace);
 121  
         
 122  
         /**
 123  
          * This method gets a KrmsAttributeDefinitionBo object for a given attribute.
 124  
          * 
 125  
          * @param attributeName - the name of the attribute
 126  
          * @param namespace - the namespace code of the attribute
 127  
          * @return - the attribute definition id 
 128  
          */
 129  
         public KrmsAttributeDefinitionBo getKrmsAttributeBo( String attributeName, String namespace);
 130  
 
 131  
         /**
 132  
          * This method clears the cache of AttributeDefinitionBo objects.
 133  
          * <p>
 134  
          * Since searching for attribute definitions is a common operation,
 135  
          * the attribute definitions fetched from the database are cached to
 136  
          * improve performance.
 137  
          * <p>
 138  
          */
 139  
         public void clearCache();
 140  
         
 141  
 }