Coverage Report - org.kuali.rice.kns.datadictionary.BusinessObjectEntry
 
Classes in this File Line Coverage Branch Coverage Complexity
BusinessObjectEntry
0%
0/56
0%
0/32
2.053
 
 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.List;
 20  
 
 21  
 import org.apache.commons.lang.StringUtils;
 22  
 import org.kuali.rice.kns.bo.BusinessObject;
 23  
 import org.kuali.rice.kns.datadictionary.exception.ClassValidationException;
 24  
 
 25  
 /**
 26  
  * A single BusinessObject entry in the DataDictionary, which contains information relating to the display, validation, and general
 27  
  * maintenance of a BusinessObject and its attributes.
 28  
  *
 29  
  *
 30  
     DD: See BusinessObjectEntry.java
 31  
 
 32  
     JSTL: each businessObject is exposed as a Map which is accessed
 33  
     using a key of the business object class name.
 34  
     This map contains enties with the following keys
 35  
 
 36  
         * businessObjectClass (String)
 37  
         * exporterClass (String)
 38  
         * inquiry (Map, optional)
 39  
         * lookup (Map, optional)
 40  
         * attributes (Map)
 41  
         * collections (Map, optional)
 42  
         * relationships (Map, optional)
 43  
         * objectLabel (String, optional)
 44  
         * objectDescription (String, optional)
 45  
 
 46  
     See BusinessObjectEntryMapper.java
 47  
 
 48  
     Note: the use of extraButton in the <businessObject> tag is deprecated, and may be removed in future versions of the data dictionary.
 49  
 
 50  
  * Note: the setters do copious amounts of validation, to facilitate generating errors during the parsing process.
 51  
  */
 52  0
 public class BusinessObjectEntry extends DataObjectEntry {
 53  
     // logger
 54  
     //private static Log LOG = LogFactory.getLog(BusinessObjectEntry.class);
 55  
 
 56  
     protected Class<? extends BusinessObject> businessObjectClass;
 57  
     protected Class<? extends BusinessObject> baseBusinessObjectClass;
 58  
     protected InquiryDefinition inquiryDefinition;
 59  
     protected LookupDefinition lookupDefinition;
 60  
     
 61  0
     protected boolean boNotesEnabled = false;
 62  
 
 63  
     protected List<InactivationBlockingDefinition> inactivationBlockingDefinitions;
 64  
     
 65  
     protected List<String> groupByAttributesForEffectiveDating;
 66  
 
 67  
 
 68  
     public void setBusinessObjectClass(Class<? extends BusinessObject> businessObjectClass) {
 69  0
         super.setObjectClass(businessObjectClass);
 70  
         
 71  0
         if (businessObjectClass == null) {
 72  0
             throw new IllegalArgumentException("invalid (null) businessObjectClass");
 73  
         }
 74  
 
 75  0
         if ( getRelationships() != null ) {
 76  0
                 for ( RelationshipDefinition rd : getRelationships() ) {
 77  0
                         rd.setSourceClass(businessObjectClass);
 78  
                 }
 79  
         }
 80  
 
 81  0
         this.businessObjectClass = businessObjectClass;
 82  0
     }
 83  
 
 84  
     public Class<? extends BusinessObject> getBusinessObjectClass() {
 85  0
         return businessObjectClass;
 86  
     }
 87  
 
 88  
     /**
 89  
      * The baseBusinessObjectClass is an optional parameter for specifying a superclass
 90  
      * for the businessObjectClass, allowing the data dictionary to index by superclass
 91  
      * in addition to the current class.
 92  
      */
 93  
 
 94  
     public void setBaseBusinessObjectClass(Class<? extends BusinessObject> baseBusinessObjectClass) {
 95  0
         this.baseBusinessObjectClass = baseBusinessObjectClass;
 96  0
     }
 97  
 
 98  
     public Class<? extends BusinessObject> getBaseBusinessObjectClass() {
 99  0
         return baseBusinessObjectClass;
 100  
     }
 101  
 
 102  
         public boolean isBoNotesEnabled() {
 103  0
         return boNotesEnabled;
 104  
     }
 105  
 
 106  
     /**
 107  
      *            boNotesEnabled = true or false
 108  
            * true indicates that notes and attachments will be permanently
 109  
              associated with the business object
 110  
            * false indicates that notes and attachments are associated
 111  
              with the document used to create or edit the business object.
 112  
      */
 113  
     public void setBoNotesEnabled(boolean boNotesEnabled) {
 114  0
         this.boNotesEnabled = boNotesEnabled;
 115  0
     }
 116  
 
 117  
 
 118  
 
 119  
     /**
 120  
      * Directly validate simple fields, call completeValidation on Definition fields.
 121  
      */
 122  
     @Override
 123  
     public void completeValidation() {
 124  
         try {
 125  
 
 126  0
                 if (baseBusinessObjectClass != null && !baseBusinessObjectClass.isAssignableFrom(businessObjectClass)) {
 127  0
                         throw new ClassValidationException("The baseBusinessObjectClass " + baseBusinessObjectClass.getName() +
 128  
                                     " is not a superclass of the businessObjectClass " + businessObjectClass.getName());
 129  
                 }
 130  
 
 131  0
                 super.completeValidation();
 132  
 
 133  0
                 if (hasInquiryDefinition()) {
 134  0
                     inquiryDefinition.completeValidation(businessObjectClass, null);
 135  
                 }
 136  
 
 137  0
                 if (hasLookupDefinition()) {
 138  0
                     lookupDefinition.completeValidation(businessObjectClass, null);
 139  
                 }
 140  
 
 141  0
                 if (inactivationBlockingDefinitions != null && !inactivationBlockingDefinitions.isEmpty()) {
 142  0
                     for (InactivationBlockingDefinition inactivationBlockingDefinition : inactivationBlockingDefinitions) {
 143  0
                         inactivationBlockingDefinition.completeValidation(businessObjectClass, null);
 144  
                     }
 145  
                 }
 146  0
         } catch ( DataDictionaryException ex ) {
 147  
                 // just rethrow
 148  0
                 throw ex;
 149  0
         } catch ( Exception ex ) {
 150  0
                 throw new DataDictionaryException( "Exception validating " + this, ex);
 151  0
         }
 152  0
     }
 153  
 
 154  
     /**
 155  
      * @see java.lang.Object#toString()
 156  
      */
 157  
     @Override
 158  
         public String toString() {
 159  0
         return "BusinessObjectEntry for " + getBusinessObjectClass();
 160  
     }
 161  
 
 162  
     public List<InactivationBlockingDefinition> getInactivationBlockingDefinitions() {
 163  0
         return this.inactivationBlockingDefinitions;
 164  
     }
 165  
 
 166  
     public void setInactivationBlockingDefinitions(List<InactivationBlockingDefinition> inactivationBlockingDefinitions) {
 167  0
         this.inactivationBlockingDefinitions = inactivationBlockingDefinitions;
 168  0
     }
 169  
         
 170  
         public List<String> getGroupByAttributesForEffectiveDating() {
 171  0
                 return this.groupByAttributesForEffectiveDating;
 172  
         }
 173  
 
 174  
         public void setGroupByAttributesForEffectiveDating(List<String> groupByAttributesForEffectiveDating) {
 175  0
                 this.groupByAttributesForEffectiveDating = groupByAttributesForEffectiveDating;
 176  0
         }
 177  
 
 178  
         /**
 179  
      * @see org.kuali.rice.kns.datadictionary.DataDictionaryEntryBase#afterPropertiesSet()
 180  
      */
 181  
     @SuppressWarnings("unchecked")
 182  
         @Override
 183  
     public void afterPropertiesSet() throws Exception {
 184  0
             super.afterPropertiesSet();
 185  0
             if ( inactivationBlockingDefinitions != null ) {
 186  0
                     for ( InactivationBlockingDefinition ibd : inactivationBlockingDefinitions ) {
 187  0
                             ibd.setBusinessObjectClass( getBusinessObjectClass() );
 188  0
                     if (StringUtils.isNotBlank(ibd.getBlockedReferencePropertyName()) && ibd.getBlockedBusinessObjectClass() == null) {
 189  
                         // if the user didn't specify a class name for the blocked reference, determine it here
 190  0
                             ibd.setBlockedBusinessObjectClass( DataDictionary.getAttributeClass(businessObjectClass, ibd.getBlockedReferencePropertyName()) );
 191  
                     }
 192  0
                             ibd.setBlockingReferenceBusinessObjectClass(getBusinessObjectClass());
 193  
                     }
 194  
             }
 195  0
     }
 196  
     
 197  
     /**
 198  
      * @return true if this instance has an inquiryDefinition
 199  
      */
 200  
     public boolean hasInquiryDefinition() {
 201  0
         return (inquiryDefinition != null);
 202  
     }
 203  
 
 204  
     /**
 205  
      * @return current inquiryDefinition for this BusinessObjectEntry, or null if there is none
 206  
      */
 207  
     public InquiryDefinition getInquiryDefinition() {
 208  0
         return inquiryDefinition;
 209  
     }
 210  
 
 211  
     /**
 212  
            The inquiry element is used to specify the fields that will be displayed on the
 213  
             inquiry screen for this business object and the order in which they will appear.
 214  
 
 215  
             DD: See InquiryDefinition.java
 216  
 
 217  
             JSTL: The inquiry element is a Map which is accessed using
 218  
             a key of "inquiry".  This map contains the following keys:
 219  
                 * title (String)
 220  
                 * inquiryFields (Map)
 221  
 
 222  
             See InquiryMapBuilder.java
 223  
      */
 224  
     public void setInquiryDefinition(InquiryDefinition inquiryDefinition) {
 225  0
         this.inquiryDefinition = inquiryDefinition;
 226  0
     }
 227  
     
 228  
     /**
 229  
      * @return true if this instance has a lookupDefinition
 230  
      */
 231  
     public boolean hasLookupDefinition() {
 232  0
         return (lookupDefinition != null);
 233  
     }
 234  
 
 235  
     /**
 236  
      * @return current lookupDefinition for this BusinessObjectEntry, or null if there is none
 237  
      */
 238  
     public LookupDefinition getLookupDefinition() {
 239  0
         return lookupDefinition;
 240  
     }
 241  
 
 242  
     /**
 243  
             The lookup element is used to specify the rules for "looking up"
 244  
             a business object.  These specifications define the following:
 245  
             * How to specify the search criteria used to locate a set of business objects
 246  
             * How to display the search results
 247  
 
 248  
             DD: See LookupDefinition.java
 249  
 
 250  
             JSTL: The lookup element is a Map which is accessed using
 251  
             a key of "lookup".  This map contains the following keys:
 252  
             * lookupableID (String, optional)
 253  
             * title (String)
 254  
             * menubar (String, optional)
 255  
             * defaultSort (Map, optional)
 256  
             * lookupFields (Map)
 257  
             * resultFields (Map)
 258  
             * resultSetLimit (String, optional)
 259  
 
 260  
             See LookupMapBuilder.java
 261  
      */
 262  
     public void setLookupDefinition(LookupDefinition lookupDefinition) {
 263  0
         this.lookupDefinition = lookupDefinition;
 264  0
     }
 265  
 
 266  
 }