Coverage Report - org.kuali.rice.krad.datadictionary.CollectionDefinition
 
Classes in this File Line Coverage Branch Coverage Complexity
CollectionDefinition
4%
2/41
0%
0/10
1.391
 
 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.krad.datadictionary;
 17  
 
 18  
 import org.apache.commons.lang.StringUtils;
 19  
 import org.kuali.rice.krad.datadictionary.exception.AttributeValidationException;
 20  
 import org.kuali.rice.krad.datadictionary.validation.capability.CollectionSizeConstrainable;
 21  
 
 22  
 /**
 23  
  * A single Collection attribute definition in the DataDictionary, which contains information relating to the display, validation,
 24  
  * and general maintenance of a specific Collection attribute of an entry.
 25  
  * 
 26  
  * 
 27  
  */
 28  
 public class CollectionDefinition extends DataDictionaryDefinitionBase implements CollectionSizeConstrainable{
 29  
     private static final long serialVersionUID = -2644072136271281041L;
 30  
     
 31  
     protected String dataObjectClass;
 32  
     protected String name;
 33  
     protected String label;
 34  
     protected String shortLabel;
 35  
     protected String elementLabel;
 36  
     
 37  
     protected String summary;
 38  
 
 39  
         protected String description;
 40  
     
 41  
         protected Integer minOccurs;
 42  
         protected Integer maxOccurs;
 43  
 
 44  36
     public CollectionDefinition() {
 45  
             //empty
 46  36
     }
 47  
 
 48  
     public String getName() {
 49  0
         return name;
 50  
     }
 51  
 
 52  
     public void setName(String name) {
 53  0
         if (StringUtils.isBlank(name)) {
 54  0
             throw new IllegalArgumentException("invalid (blank) name");
 55  
         }
 56  0
         this.name = name;
 57  0
     }
 58  
 
 59  
     public String getLabel() {
 60  0
         return label;
 61  
     }
 62  
 
 63  
     public void setLabel(String label) {
 64  0
         if (StringUtils.isBlank(label)) {
 65  0
             throw new IllegalArgumentException("invalid (blank) label");
 66  
         }
 67  0
         this.label = label;
 68  0
     }
 69  
 
 70  
     /**
 71  
      * @return the shortLabel, or the label if no shortLabel has been set
 72  
      */
 73  
     public String getShortLabel() {
 74  0
         return (shortLabel != null) ? shortLabel : label;
 75  
     }
 76  
 
 77  
     public void setShortLabel(String shortLabel) {
 78  0
         if (StringUtils.isBlank(shortLabel)) {
 79  0
             throw new IllegalArgumentException("invalid (blank) shortLabel");
 80  
         }
 81  0
         this.shortLabel = shortLabel;
 82  0
     }
 83  
 
 84  
     /**
 85  
      * Gets the elementLabel attribute. 
 86  
      * @return Returns the elementLabel.
 87  
      */
 88  
     public String getElementLabel() {
 89  0
         return elementLabel;
 90  
     }
 91  
 
 92  
     /**
 93  
           * The elementLabel defines the name to be used for a single object
 94  
      * within the collection.  For example: "Address" may be the name
 95  
      * of one object within the "Addresses" collection.
 96  
      */
 97  
     public void setElementLabel(String elementLabel) {
 98  0
         this.elementLabel = elementLabel;
 99  0
     }
 100  
 
 101  
     public String getSummary() {
 102  0
         return summary;
 103  
     }
 104  
 
 105  
     /**
 106  
          * The summary element is used to provide a short description of the
 107  
      * attribute or collection.  This is designed to be used for help purposes.
 108  
      */
 109  
     public void setSummary(String summary) {
 110  0
         this.summary = summary;
 111  0
     }
 112  
 
 113  
     public String getDescription() {
 114  0
         return description;
 115  
     }
 116  
 
 117  
     /**
 118  
          * The description element is used to provide a long description of the
 119  
          * attribute or collection.  This is designed to be used for help purposes.
 120  
      */
 121  
     public void setDescription(String description) {
 122  0
         this.description = description;
 123  0
     }
 124  
     
 125  
            
 126  
     /**
 127  
          * @return the dataObjectClass
 128  
          */
 129  
         public String getDataObjectClass() {
 130  0
                 return this.dataObjectClass;
 131  
         }
 132  
 
 133  
         /**
 134  
          * @param objectClass the dataObjectClass to set
 135  
          */
 136  
         public void setDataObjectClass(String dataObjectClass) {
 137  0
                 this.dataObjectClass = dataObjectClass;
 138  0
         }
 139  
 
 140  
         /**
 141  
      * Directly validate simple fields, call completeValidation on Definition fields.
 142  
      * 
 143  
      * @see org.kuali.rice.krad.datadictionary.DataDictionaryEntry#completeValidation()
 144  
      */
 145  
     public void completeValidation(Class rootBusinessObjectClass, Class otherBusinessObjectClass) {
 146  0
         if (!DataDictionary.isCollectionPropertyOf(rootBusinessObjectClass, name)) {
 147  0
             throw new AttributeValidationException("property '" + name + "' is not a collection property of class '" + rootBusinessObjectClass + "' (" + "" + ")");
 148  
         }
 149  0
     }
 150  
 
 151  
 
 152  
     /**
 153  
      * @see java.lang.Object#toString()
 154  
      */
 155  
     @Override
 156  
     public String toString() {
 157  0
         return "CollectionDefinition for collection " + getName();
 158  
     }
 159  
 
 160  
         /**
 161  
          * @see org.kuali.rice.krad.datadictionary.validation.constraint.CollectionSizeConstraint#getMaximumNumberOfElements()
 162  
          */
 163  
         @Override
 164  
         public Integer getMaximumNumberOfElements() {
 165  0
                 return this.maxOccurs;
 166  
         }
 167  
 
 168  
         /**
 169  
          * @see org.kuali.rice.krad.datadictionary.validation.constraint.CollectionSizeConstraint#getMinimumNumberOfElements()
 170  
          */
 171  
         @Override
 172  
         public Integer getMinimumNumberOfElements() {
 173  0
                 return this.minOccurs;
 174  
         }
 175  
 
 176  
     /**
 177  
          * @return the minOccurs
 178  
          */
 179  
         public Integer getMinOccurs() {
 180  0
                 return this.minOccurs;
 181  
         }
 182  
 
 183  
         /**
 184  
          * @param minOccurs the minOccurs to set
 185  
          */
 186  
         public void setMinOccurs(Integer minOccurs) {
 187  0
                 this.minOccurs = minOccurs;
 188  0
         }
 189  
 
 190  
         /**
 191  
          * @return the maxOccurs
 192  
          */
 193  
         public Integer getMaxOccurs() {
 194  0
                 return this.maxOccurs;
 195  
         }
 196  
 
 197  
         /**
 198  
          * @param maxOccurs the maxOccurs to set
 199  
          */
 200  
         public void setMaxOccurs(Integer maxOccurs) {
 201  0
                 this.maxOccurs = maxOccurs;
 202  0
         }
 203  
 
 204  
 }