|  1 |     | 
     | 
  |  2 |     | 
     | 
  |  3 |     | 
     | 
  |  4 |     | 
     | 
  |  5 |     | 
     | 
  |  6 |     | 
     | 
  |  7 |     | 
     | 
  |  8 |     | 
     | 
  |  9 |     | 
     | 
  |  10 |     | 
     | 
  |  11 |     | 
     | 
  |  12 |     | 
     | 
  |  13 |     | 
     | 
  |  14 |     | 
     | 
  |  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 |     | 
     | 
  |  27 |     | 
     | 
  |  28 |     | 
     | 
  |  29 |     | 
     | 
  |  30 |     | 
     | 
  |  31 |     | 
     | 
  |  32 |     | 
     | 
  |  33 |     | 
     | 
  |  34 |     | 
     | 
  |  35 |     | 
     | 
  |  36 |     | 
     | 
  |  37 |     | 
     | 
  |  38 |     | 
     | 
  |  39 |     | 
     | 
  |  40 |     | 
     | 
  |  41 |     | 
     | 
  |  42 |     | 
     | 
  |  43 |     | 
     | 
  |  44 |     | 
     | 
  |  45 |     | 
     | 
  |  46 |     | 
     | 
  |  47 |     | 
     | 
  |  48 |     | 
     | 
  |  49 |     | 
     | 
  |  50 |     | 
     | 
  |  51 |     | 
     | 
  |  52 |    0 |    public class BusinessObjectEntry extends DataObjectEntry { | 
  |  53 |     | 
         | 
  |  54 |     | 
         | 
  |  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 |     | 
     | 
  |  90 |     | 
     | 
  |  91 |     | 
     | 
  |  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 |     | 
     | 
  |  108 |     | 
     | 
  |  109 |     | 
     | 
  |  110 |     | 
     | 
  |  111 |     | 
     | 
  |  112 |     | 
     | 
  |  113 |     | 
       public void setBoNotesEnabled(boolean boNotesEnabled) { | 
  |  114 |    0 |            this.boNotesEnabled = boNotesEnabled;  | 
  |  115 |    0 |        }  | 
  |  116 |     | 
     | 
  |  117 |     | 
     | 
  |  118 |     | 
     | 
  |  119 |     | 
         | 
  |  120 |     | 
     | 
  |  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 |     | 
                     | 
  |  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 |     | 
     | 
  |  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 |     | 
     | 
  |  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 |     | 
                             | 
  |  190 |    0 |                                ibd.setBlockedBusinessObjectClass( DataDictionary.getAttributeClass(businessObjectClass, ibd.getBlockedReferencePropertyName()) );  | 
  |  191 |     | 
                       }  | 
  |  192 |    0 |                                ibd.setBlockingReferenceBusinessObjectClass(getBusinessObjectClass());  | 
  |  193 |     | 
                       }  | 
  |  194 |     | 
               }  | 
  |  195 |    0 |        }  | 
  |  196 |     | 
         | 
  |  197 |     | 
         | 
  |  198 |     | 
     | 
  |  199 |     | 
     | 
  |  200 |     | 
       public boolean hasInquiryDefinition() { | 
  |  201 |    0 |            return (inquiryDefinition != null);  | 
  |  202 |     | 
       }  | 
  |  203 |     | 
     | 
  |  204 |     | 
         | 
  |  205 |     | 
     | 
  |  206 |     | 
     | 
  |  207 |     | 
       public InquiryDefinition getInquiryDefinition() { | 
  |  208 |    0 |            return inquiryDefinition;  | 
  |  209 |     | 
       }  | 
  |  210 |     | 
     | 
  |  211 |     | 
         | 
  |  212 |     | 
     | 
  |  213 |     | 
     | 
  |  214 |     | 
     | 
  |  215 |     | 
     | 
  |  216 |     | 
     | 
  |  217 |     | 
     | 
  |  218 |     | 
     | 
  |  219 |     | 
     | 
  |  220 |     | 
     | 
  |  221 |     | 
     | 
  |  222 |     | 
     | 
  |  223 |     | 
     | 
  |  224 |     | 
       public void setInquiryDefinition(InquiryDefinition inquiryDefinition) { | 
  |  225 |    0 |            this.inquiryDefinition = inquiryDefinition;  | 
  |  226 |    0 |        }  | 
  |  227 |     | 
         | 
  |  228 |     | 
         | 
  |  229 |     | 
     | 
  |  230 |     | 
     | 
  |  231 |     | 
       public boolean hasLookupDefinition() { | 
  |  232 |    0 |            return (lookupDefinition != null);  | 
  |  233 |     | 
       }  | 
  |  234 |     | 
     | 
  |  235 |     | 
         | 
  |  236 |     | 
     | 
  |  237 |     | 
     | 
  |  238 |     | 
       public LookupDefinition getLookupDefinition() { | 
  |  239 |    0 |            return lookupDefinition;  | 
  |  240 |     | 
       }  | 
  |  241 |     | 
     | 
  |  242 |     | 
         | 
  |  243 |     | 
     | 
  |  244 |     | 
     | 
  |  245 |     | 
     | 
  |  246 |     | 
     | 
  |  247 |     | 
     | 
  |  248 |     | 
     | 
  |  249 |     | 
     | 
  |  250 |     | 
     | 
  |  251 |     | 
     | 
  |  252 |     | 
     | 
  |  253 |     | 
     | 
  |  254 |     | 
     | 
  |  255 |     | 
     | 
  |  256 |     | 
     | 
  |  257 |     | 
     | 
  |  258 |     | 
     | 
  |  259 |     | 
     | 
  |  260 |     | 
     | 
  |  261 |     | 
     | 
  |  262 |     | 
       public void setLookupDefinition(LookupDefinition lookupDefinition) { | 
  |  263 |    0 |            this.lookupDefinition = lookupDefinition;  | 
  |  264 |    0 |        }  | 
  |  265 |     | 
     | 
  |  266 |     | 
   }  |