Coverage Report - org.kuali.rice.kns.datadictionary.MaintainableSectionDefinition
 
Classes in this File Line Coverage Branch Coverage Complexity
MaintainableSectionDefinition
0%
0/35
0%
0/16
1.929
 
 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.kns.datadictionary;
 18  
 
 19  
 import java.util.ArrayList;
 20  
 import java.util.List;
 21  
 
 22  
 import org.apache.commons.lang.StringUtils;
 23  
 
 24  
 /**
 25  
     The maintainableSection element defines one section of the
 26  
     maintenance document.
 27  
 
 28  
     JSTL: maintainableSection is a Map which is accessed by an
 29  
     integer representing the sequential occurrence of the section.
 30  
     e.g. "0", "1", etc.  This map contains entries with the following
 31  
     keys:
 32  
         * index (String) - e.g. "0" for first section, etc.
 33  
         * title (String)
 34  
         * maintainableItems (Map)
 35  
  */
 36  
 public class MaintainableSectionDefinition extends DataDictionaryDefinitionBase {
 37  
     private static final long serialVersionUID = -8615694293159113523L;
 38  
 
 39  
         protected String title;
 40  
 
 41  0
     protected List<MaintainableItemDefinition> maintainableItems = new ArrayList<MaintainableItemDefinition>();
 42  
     
 43  0
     protected boolean hidden = false;
 44  
     
 45  0
     protected boolean defaultOpen = true;
 46  
     
 47  
     protected String helpUrl;
 48  
     
 49  0
     public MaintainableSectionDefinition() {}
 50  
 
 51  
     /**
 52  
      * @return title
 53  
      */
 54  
     public String getTitle() {
 55  0
         return title;
 56  
     }
 57  
 
 58  
     /**
 59  
      * Default the ID to the title for now.
 60  
      * 
 61  
      * @see org.kuali.rice.kns.datadictionary.DataDictionaryDefinitionBase#getId()
 62  
      */
 63  
     @Override
 64  
     public String getId() {
 65  0
         if (StringUtils.isBlank(id)) {
 66  0
                 return title;
 67  
         }
 68  0
         return id;
 69  
     }
 70  
 
 71  
 
 72  
     /**
 73  
      * Sets title of the Section.
 74  
      * 
 75  
      * @throws IllegalArgumentException if the given title is blank
 76  
      */
 77  
     public void setTitle(String title) {
 78  0
         if (StringUtils.isBlank(title)) {
 79  0
             throw new IllegalArgumentException("invalid (blank) title");
 80  
         }
 81  
 
 82  0
         this.title = title;
 83  0
     }
 84  
 
 85  
     /**
 86  
      * @return Collection of all MaintainableFieldDefinitions associated with this MaintainableSection, in the order in which they
 87  
      *         were added
 88  
      */
 89  
     public List<MaintainableItemDefinition> getMaintainableItems() {
 90  0
         return maintainableItems;
 91  
     }
 92  
 
 93  
 
 94  
     /**
 95  
      * Directly validate simple fields, call completeValidation on Definition fields.
 96  
      * 
 97  
      * @see org.kuali.rice.kns.datadictionary.DataDictionaryDefinition#completeValidation(java.lang.Class, java.lang.Object)
 98  
      */
 99  
     public void completeValidation(Class rootBusinessObjectClass, Class otherBusinessObjectClass) {
 100  0
             if (StringUtils.contains(title, ",") && StringUtils.isBlank(id)) {
 101  0
                     throw new DataDictionaryException("The title for maintainable section \"" + title + "\" for class " + rootBusinessObjectClass.getName() +
 102  
                                     " contains a comma.  In this case, the id property must be defined and it may not contain a comma");
 103  
             }
 104  0
             if (StringUtils.contains(id, ",")) {
 105  0
                     throw new DataDictionaryException("The id for maintainable section \"" + id + "\" for class " + rootBusinessObjectClass.getName() +
 106  
                                     " contains a comma, which is not allowed.");
 107  
             }
 108  0
         for ( MaintainableItemDefinition maintainableItem : maintainableItems ) {
 109  0
             maintainableItem.completeValidation(rootBusinessObjectClass, null);
 110  
         }
 111  0
     }
 112  
 
 113  
     public String toString() {
 114  0
         return "MaintainableSectionDefinition '" + getTitle() + "'";
 115  
     }
 116  
 
 117  
 
 118  
     public boolean isHidden() {
 119  0
         return this.hidden;
 120  
     }
 121  
 
 122  
 
 123  
     /** Whether to hide the entire section, tab and all. */
 124  
     public void setHidden(boolean hidden) {
 125  0
         this.hidden = hidden;
 126  0
     }
 127  
 
 128  
 
 129  
     /**
 130  
         The maintainableItems element defines the components of a
 131  
         section.  These may include fields, sub-section headers,
 132  
         and fields.
 133  
 
 134  
         JSTL: maintainableItems is a Map which is accessed by a
 135  
         key of "maintainableItems".  This map contains entries with
 136  
         the following keys:
 137  
             * name of first item in the section
 138  
             * name of second item in the section
 139  
             * etc.
 140  
         The corresponding value is an ExportMap which is dependent
 141  
         upon the type of the item as follows:
 142  
 
 143  
         subSectionHeader ExportMap
 144  
             In this case, the ExportMap contains the following
 145  
             keys and values:
 146  
                 **Key**     **Value**
 147  
                 name        name of subSectionHeader
 148  
 
 149  
         maintainableField ExportMap
 150  
             In this case, the ExportMap contains the following
 151  
             keys and values:
 152  
                 **Key**     **Value**
 153  
                 field       true
 154  
                 name        name of maintainableField
 155  
                 required    true or false
 156  
 
 157  
         maintainableCollection ExportMap
 158  
             In this case, the ExportMap contains the following
 159  
             keys and values:
 160  
                 **Key**                **Value**
 161  
                 collection             true
 162  
                 name                   name of collection
 163  
                 businessObjectClass    name of collection class
 164  
      */
 165  
     public void setMaintainableItems(List<MaintainableItemDefinition> maintainableItems) {
 166  0
         for ( MaintainableItemDefinition maintainableItem : maintainableItems ) {
 167  0
             if (maintainableItem == null) {
 168  0
                 throw new IllegalArgumentException("invalid (null) maintainableItem");
 169  
             }
 170  
         }
 171  
         
 172  0
         this.maintainableItems = maintainableItems;
 173  0
     }
 174  
 
 175  
         /**
 176  
          * @return the defaultOpen
 177  
          */
 178  
         public boolean isDefaultOpen() {
 179  0
                 return this.defaultOpen;
 180  
         }
 181  
 
 182  
         /**
 183  
          * @param defaultOpen the defaultOpen to set
 184  
          */
 185  
         public void setDefaultOpen(boolean defaultOpen) {
 186  0
                 this.defaultOpen = defaultOpen;
 187  0
         }
 188  
 
 189  
         public String getHelpUrl() {
 190  0
                 return helpUrl;
 191  
         }
 192  
 
 193  
         public void setHelpUrl(String helpUrl) {
 194  0
                 this.helpUrl = helpUrl;
 195  0
         }
 196  
         
 197  
 }