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