Coverage Report - org.kuali.rice.krad.datadictionary.AttributeDefinitionBase
 
Classes in this File Line Coverage Branch Coverage Complexity
AttributeDefinitionBase
23%
7/30
12%
1/8
1.467
 
 1  
 /*
 2  
  * Copyright 2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 1.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/ecl1.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.validation.capability.ExistenceConstrainable;
 20  
 
 21  
 /**
 22  
  * Common class for attribute definitions in the DataDictionary, which contains
 23  
  * information relating to the display, validation, and general maintenance of a
 24  
  * specific attribute of an entry. An attribute can be a simple or complex attribute.
 25  
  *  
 26  
  */
 27  180
 public abstract class AttributeDefinitionBase extends DataDictionaryDefinitionBase implements ExistenceConstrainable{
 28  
 
 29  
         protected String name;
 30  
 
 31  
         protected String label;
 32  
         protected String shortLabel;
 33  
         protected String displayLabelAttribute;
 34  
 
 35  
         protected String messageKey;        
 36  
         protected String summary;
 37  
         
 38  
         //Note: This is the actual constraint text that appears below field
 39  
     // TODO: is this used on definition
 40  
         protected String constraint;
 41  
         
 42  
         protected String description;
 43  
         
 44  180
         protected Boolean required = Boolean.FALSE;
 45  
         
 46  
         public String getName() {
 47  126
                 return name;
 48  
         }
 49  
 
 50  
         /*
 51  
          * name = name of attribute
 52  
          */
 53  
         public void setName(String name) {
 54  126
                 if (StringUtils.isBlank(name)) {
 55  0
                         throw new IllegalArgumentException("invalid (blank) name");
 56  
                 }
 57  126
                 this.name = name;
 58  126
         }
 59  
 
 60  
         public String getLabel() {
 61  9
                 return label;
 62  
         }
 63  
 
 64  
         /**
 65  
          * The label element is the field or collection name that will be shown on
 66  
          * inquiry and maintenance screens. This will be overridden by presence of
 67  
          * displayLabelAttribute element.
 68  
          */
 69  
         public void setLabel(String label) {
 70  0
                 if (StringUtils.isBlank(label)) {
 71  0
                         throw new IllegalArgumentException("invalid (blank) label");
 72  
                 }
 73  0
                 this.label = label;
 74  0
         }
 75  
 
 76  
         /**
 77  
          * @return the shortLabel, or the label if no shortLabel has been set
 78  
          */
 79  
         public String getShortLabel() {
 80  0
                 return (shortLabel != null) ? shortLabel : getLabel();
 81  
         }
 82  
 
 83  
         /**
 84  
          * @return the shortLabel directly, without substituting in the label
 85  
          */
 86  
         protected String getDirectShortLabel() {
 87  0
                 return shortLabel;
 88  
         }
 89  
 
 90  
         /**
 91  
          * The shortLabel element is the field or collection name that will be used
 92  
          * in applications when a shorter name (than the label element) is required.
 93  
          * This will be overridden by presence of displayLabelAttribute element.
 94  
          */
 95  
         public void setShortLabel(String shortLabel) {
 96  0
                 if (StringUtils.isBlank(shortLabel)) {
 97  0
                         throw new IllegalArgumentException("invalid (blank) shortLabel");
 98  
                 }
 99  0
                 this.shortLabel = shortLabel;
 100  0
         }
 101  
         
 102  
         /**
 103  
          * The required element allows values of "true" or "false". A value of
 104  
          * "true" indicates that a value must be entered for this business object
 105  
          * when creating or editing a new business object.
 106  
          */
 107  
         public void setRequired(Boolean required) {
 108  0
                 this.required = required;
 109  0
         }
 110  
 
 111  
         @Override
 112  
         public Boolean isRequired() {
 113  0
                 return this.required;
 114  
         }
 115  
         
 116  
         public String getSummary() {
 117  0
                 return summary;
 118  
         }
 119  
 
 120  
         /**
 121  
          * The summary element is used to provide a short description of the
 122  
          * attribute or collection. This is designed to be used for help purposes.
 123  
          */
 124  
         public void setSummary(String summary) {
 125  0
                 this.summary = summary;
 126  0
         }
 127  
 
 128  
         public String getDescription() {
 129  0
                 return description;
 130  
         }
 131  
 
 132  
         /**
 133  
          * The description element is used to provide a long description of the
 134  
          * attribute or collection. This is designed to be used for help purposes.
 135  
          */
 136  
         public void setDescription(String description) {
 137  0
                 this.description = description;
 138  0
         }
 139  
         
 140  
         public String getDisplayLabelAttribute() {
 141  0
                 return displayLabelAttribute;
 142  
         }
 143  
 
 144  
         /**
 145  
          * The displayLabelAttribute element is used to indicate that the label and
 146  
          * short label should be obtained from another attribute.
 147  
          * 
 148  
          * The label element and short label element defined for this attribute will
 149  
          * be overridden. Instead, the label and short label values will be obtained
 150  
          * by referencing the corresponding values from the attribute indicated by
 151  
          * this element.
 152  
          */
 153  
         public void setDisplayLabelAttribute(String displayLabelAttribute) {
 154  0
                 this.displayLabelAttribute = displayLabelAttribute;
 155  0
         }
 156  
 
 157  
 }