|  1 |     | 
     | 
  |  2 |     | 
     | 
  |  3 |     | 
     | 
  |  4 |     | 
     | 
  |  5 |     | 
     | 
  |  6 |     | 
     | 
  |  7 |     | 
     | 
  |  8 |     | 
     | 
  |  9 |     | 
     | 
  |  10 |     | 
     | 
  |  11 |     | 
     | 
  |  12 |     | 
     | 
  |  13 |     | 
     | 
  |  14 |     | 
     | 
  |  15 |     | 
     | 
  |  16 |     | 
   package org.kuali.rice.kns.datadictionary;  | 
  |  17 |     | 
     | 
  |  18 |     | 
     | 
  |  19 |     | 
     | 
  |  20 |     | 
     | 
  |  21 |     | 
     | 
  |  22 |     | 
     | 
  |  23 |     | 
     | 
  |  24 |     | 
   import org.apache.commons.lang.StringUtils;  | 
  |  25 |     | 
   import org.apache.commons.logging.Log;  | 
  |  26 |     | 
   import org.apache.commons.logging.LogFactory;  | 
  |  27 |     | 
   import org.kuali.rice.kns.datadictionary.control.ControlDefinition;  | 
  |  28 |     | 
   import org.kuali.rice.kns.datadictionary.exception.CompletionException;  | 
  |  29 |     | 
   import org.kuali.rice.kns.datadictionary.validation.ValidationPattern;  | 
  |  30 |     | 
   import org.kuali.rice.kns.service.KNSServiceLocatorWeb;  | 
  |  31 |     | 
     | 
  |  32 |     | 
     | 
  |  33 |     | 
     | 
  |  34 |     | 
     | 
  |  35 |     | 
     | 
  |  36 |     | 
     | 
  |  37 |     | 
     | 
  |  38 |     | 
     | 
  |  39 |     | 
   public class ExternalizableAttributeDefinitionProxy extends AttributeDefinition { | 
  |  40 |     | 
           private static final long serialVersionUID = -3204870440281417429L;  | 
  |  41 |     | 
     | 
  |  42 |     | 
             | 
  |  43 |    0 |            private static Log LOG = LogFactory  | 
  |  44 |     | 
                           .getLog(ExternalizableAttributeDefinitionProxy.class);  | 
  |  45 |     | 
     | 
  |  46 |     | 
           private String sourceExternalizableBusinessObjectInterface;  | 
  |  47 |     | 
           private String sourceAttributeName;  | 
  |  48 |     | 
           private AttributeDefinition delegate;  | 
  |  49 |     | 
     | 
  |  50 |     | 
             | 
  |  51 |     | 
     | 
  |  52 |     | 
     | 
  |  53 |    0 |            public ExternalizableAttributeDefinitionProxy() { | 
  |  54 |    0 |                    LOG.debug("creating new ExternalizableAttributeDefinitionProxy"); | 
  |  55 |    0 |            }  | 
  |  56 |     | 
     | 
  |  57 |     | 
           public void setSourceExternalizableBusinessObjectInterface(  | 
  |  58 |     | 
                           String sourceClassName) { | 
  |  59 |    0 |                    if (StringUtils.isBlank(sourceClassName)) { | 
  |  60 |    0 |                            throw new IllegalArgumentException(  | 
  |  61 |     | 
                                           "invalid (blank) sourceClassName");  | 
  |  62 |     | 
                   }  | 
  |  63 |     | 
     | 
  |  64 |    0 |                    this.sourceExternalizableBusinessObjectInterface = sourceClassName;  | 
  |  65 |    0 |            }  | 
  |  66 |     | 
     | 
  |  67 |     | 
           public String getSourceExternalizableBusinessObjectInterface() { | 
  |  68 |    0 |                    return this.sourceExternalizableBusinessObjectInterface;  | 
  |  69 |     | 
           }  | 
  |  70 |     | 
     | 
  |  71 |     | 
           public void setSourceAttributeName(String sourceAttributeName) { | 
  |  72 |    0 |                    if (StringUtils.isBlank(sourceAttributeName)) { | 
  |  73 |    0 |                            throw new IllegalArgumentException(  | 
  |  74 |     | 
                                           "invalid (blank) sourceAttributeName");  | 
  |  75 |     | 
                   }  | 
  |  76 |     | 
     | 
  |  77 |    0 |                    this.sourceAttributeName = sourceAttributeName;  | 
  |  78 |    0 |            }  | 
  |  79 |     | 
     | 
  |  80 |     | 
           public String getSourceAttributeName() { | 
  |  81 |    0 |                    return this.sourceAttributeName;  | 
  |  82 |     | 
           }  | 
  |  83 |     | 
     | 
  |  84 |     | 
             | 
  |  85 |     | 
     | 
  |  86 |     | 
     | 
  |  87 |     | 
     | 
  |  88 |     | 
           AttributeDefinition getDelegate() { | 
  |  89 |    0 |                    BusinessObjectEntry delegateEntry = null;  | 
  |  90 |    0 |                    if ( delegate == null ) { | 
  |  91 |     | 
                           try { | 
  |  92 |    0 |                                    delegateEntry = KNSServiceLocatorWeb  | 
  |  93 |     | 
                                                   .getKualiModuleService()  | 
  |  94 |     | 
                                                   .getResponsibleModuleService(  | 
  |  95 |     | 
                                                                   Class  | 
  |  96 |     | 
                                                                                   .forName(getSourceExternalizableBusinessObjectInterface()))  | 
  |  97 |     | 
                                                   .getExternalizableBusinessObjectDictionaryEntry(  | 
  |  98 |     | 
                                                                   Class  | 
  |  99 |     | 
                                                                                   .forName(getSourceExternalizableBusinessObjectInterface()));  | 
  |  100 |    0 |                            } catch (ClassNotFoundException e) { | 
  |  101 |    0 |                                    LOG.error("Unable to get delegate entry for sourceExternalizableBusinessObjectInterface",e); | 
  |  102 |    0 |                            }  | 
  |  103 |     | 
             | 
  |  104 |    0 |                            if (delegateEntry == null) { | 
  |  105 |    0 |                                    throw new CompletionException(  | 
  |  106 |     | 
                                                   "no BusinessObjectEntry exists for sourceClassName '"  | 
  |  107 |     | 
                                                                   + getSourceExternalizableBusinessObjectInterface()  | 
  |  108 |     | 
                                                                   + "'");  | 
  |  109 |     | 
                           }  | 
  |  110 |    0 |                            delegate = delegateEntry  | 
  |  111 |     | 
                                           .getAttributeDefinition(getSourceAttributeName());  | 
  |  112 |    0 |                            if (delegate == null) { | 
  |  113 |    0 |                                    throw new CompletionException(  | 
  |  114 |     | 
                                                   "no AttributeDefnintion exists for sourceAttributeName '"  | 
  |  115 |     | 
                                                                   + getSourceExternalizableBusinessObjectInterface()  | 
  |  116 |     | 
                                                                   + "." + getSourceAttributeName() + "'");  | 
  |  117 |     | 
                           }  | 
  |  118 |     | 
                   }  | 
  |  119 |     | 
     | 
  |  120 |    0 |                    return delegate;  | 
  |  121 |     | 
           }  | 
  |  122 |     | 
     | 
  |  123 |     | 
             | 
  |  124 |     | 
     | 
  |  125 |     | 
     | 
  |  126 |     | 
     | 
  |  127 |     | 
     | 
  |  128 |     | 
           void setDelegate(AttributeDefinition delegate) { | 
  |  129 |    0 |                    if (delegate == null) { | 
  |  130 |    0 |                            throw new IllegalArgumentException("invalid (null) delegate"); | 
  |  131 |     | 
                   }  | 
  |  132 |     | 
     | 
  |  133 |    0 |                    this.delegate = delegate;  | 
  |  134 |    0 |            }  | 
  |  135 |     | 
     | 
  |  136 |     | 
             | 
  |  137 |     | 
     | 
  |  138 |     | 
     | 
  |  139 |     | 
     | 
  |  140 |     | 
     | 
  |  141 |     | 
     | 
  |  142 |     | 
           public Boolean getForceUppercase() { | 
  |  143 |    0 |                    Boolean value = super.getForceUppercase();  | 
  |  144 |    0 |                    if (value == null) { | 
  |  145 |    0 |                            value = getDelegate().getForceUppercase();  | 
  |  146 |     | 
                   }  | 
  |  147 |     | 
     | 
  |  148 |    0 |                    return value;  | 
  |  149 |     | 
           }  | 
  |  150 |     | 
     | 
  |  151 |     | 
             | 
  |  152 |     | 
     | 
  |  153 |     | 
     | 
  |  154 |     | 
     | 
  |  155 |     | 
     | 
  |  156 |     | 
           public String getName() { | 
  |  157 |    0 |                    String name = super.getName();  | 
  |  158 |    0 |                    if (name == null) { | 
  |  159 |    0 |                            name = getDelegate().getName();  | 
  |  160 |     | 
                   }  | 
  |  161 |     | 
     | 
  |  162 |    0 |                    return name;  | 
  |  163 |     | 
           }  | 
  |  164 |     | 
     | 
  |  165 |     | 
             | 
  |  166 |     | 
     | 
  |  167 |     | 
     | 
  |  168 |     | 
     | 
  |  169 |     | 
     | 
  |  170 |     | 
           public String getLabel() { | 
  |  171 |    0 |                    String label = super.getLabel();  | 
  |  172 |     | 
     | 
  |  173 |    0 |                    if (label == null) { | 
  |  174 |    0 |                            label = getDelegate().getLabel();  | 
  |  175 |     | 
                   }  | 
  |  176 |     | 
     | 
  |  177 |    0 |                    return label;  | 
  |  178 |     | 
           }  | 
  |  179 |     | 
     | 
  |  180 |     | 
             | 
  |  181 |     | 
     | 
  |  182 |     | 
     | 
  |  183 |     | 
     | 
  |  184 |     | 
     | 
  |  185 |     | 
     | 
  |  186 |     | 
           public String getShortLabel() { | 
  |  187 |    0 |                    String shortLabel = super.getDirectShortLabel();  | 
  |  188 |    0 |                    if (shortLabel == null) { | 
  |  189 |    0 |                            shortLabel = getDelegate().getShortLabel();  | 
  |  190 |     | 
                   }  | 
  |  191 |     | 
     | 
  |  192 |    0 |                    return shortLabel;  | 
  |  193 |     | 
           }  | 
  |  194 |     | 
     | 
  |  195 |     | 
             | 
  |  196 |     | 
     | 
  |  197 |     | 
     | 
  |  198 |     | 
     | 
  |  199 |     | 
     | 
  |  200 |     | 
     | 
  |  201 |     | 
           public Integer getMaxLength() { | 
  |  202 |    0 |                    Integer maxLength = super.getMaxLength();  | 
  |  203 |    0 |                    if (maxLength == null) { | 
  |  204 |    0 |                            maxLength = getDelegate().getMaxLength();  | 
  |  205 |     | 
                   }  | 
  |  206 |     | 
     | 
  |  207 |    0 |                    return maxLength;  | 
  |  208 |     | 
           }  | 
  |  209 |     | 
     | 
  |  210 |     | 
             | 
  |  211 |     | 
     | 
  |  212 |     | 
     | 
  |  213 |     | 
     | 
  |  214 |     | 
     | 
  |  215 |     | 
           public boolean hasValidationPattern() { | 
  |  216 |    0 |                    return (getValidationPattern() != null);  | 
  |  217 |     | 
           }  | 
  |  218 |     | 
     | 
  |  219 |     | 
             | 
  |  220 |     | 
     | 
  |  221 |     | 
     | 
  |  222 |     | 
     | 
  |  223 |     | 
     | 
  |  224 |     | 
     | 
  |  225 |     | 
           public ValidationPattern getValidationPattern() { | 
  |  226 |    0 |                    ValidationPattern validationPattern = super.getValidationPattern();  | 
  |  227 |    0 |                    if (validationPattern == null) { | 
  |  228 |    0 |                            validationPattern = getDelegate().getValidationPattern();  | 
  |  229 |     | 
                   }  | 
  |  230 |     | 
     | 
  |  231 |    0 |                    return validationPattern;  | 
  |  232 |     | 
           }  | 
  |  233 |     | 
     | 
  |  234 |     | 
             | 
  |  235 |     | 
     | 
  |  236 |     | 
     | 
  |  237 |     | 
     | 
  |  238 |     | 
     | 
  |  239 |     | 
           public Boolean isRequired() { | 
  |  240 |    0 |                    Boolean required = super.isRequired();  | 
  |  241 |    0 |                    if (required == null) { | 
  |  242 |    0 |                            required = getDelegate().isRequired();  | 
  |  243 |     | 
                   }  | 
  |  244 |     | 
     | 
  |  245 |    0 |                    return required;  | 
  |  246 |     | 
           }  | 
  |  247 |     | 
     | 
  |  248 |     | 
             | 
  |  249 |     | 
     | 
  |  250 |     | 
     | 
  |  251 |     | 
     | 
  |  252 |     | 
     | 
  |  253 |     | 
           public ControlDefinition getControl() { | 
  |  254 |    0 |                    ControlDefinition control = super.getControl();  | 
  |  255 |    0 |                    if (control == null) { | 
  |  256 |    0 |                            control = getDelegate().getControl();  | 
  |  257 |     | 
                   }  | 
  |  258 |     | 
     | 
  |  259 |    0 |                    return control;  | 
  |  260 |     | 
           }  | 
  |  261 |     | 
     | 
  |  262 |     | 
             | 
  |  263 |     | 
     | 
  |  264 |     | 
     | 
  |  265 |     | 
     | 
  |  266 |     | 
     | 
  |  267 |     | 
           public String getSummary() { | 
  |  268 |    0 |                    String summary = super.getSummary();  | 
  |  269 |    0 |                    if (summary == null) { | 
  |  270 |    0 |                            summary = getDelegate().getSummary();  | 
  |  271 |     | 
                   }  | 
  |  272 |     | 
     | 
  |  273 |    0 |                    return summary;  | 
  |  274 |     | 
           }  | 
  |  275 |     | 
     | 
  |  276 |     | 
             | 
  |  277 |     | 
     | 
  |  278 |     | 
     | 
  |  279 |     | 
     | 
  |  280 |     | 
     | 
  |  281 |     | 
     | 
  |  282 |     | 
           public String getDescription() { | 
  |  283 |    0 |                    String description = super.getDescription();  | 
  |  284 |    0 |                    if (description == null) { | 
  |  285 |    0 |                            description = getDelegate().getDescription();  | 
  |  286 |     | 
                   }  | 
  |  287 |     | 
     | 
  |  288 |    0 |                    return description;  | 
  |  289 |     | 
           }  | 
  |  290 |     | 
     | 
  |  291 |     | 
             | 
  |  292 |     | 
     | 
  |  293 |     | 
     | 
  |  294 |     | 
     | 
  |  295 |     | 
     | 
  |  296 |     | 
           public boolean hasFormatterClass() { | 
  |  297 |    0 |                    return (getFormatterClass() != null);  | 
  |  298 |     | 
           }  | 
  |  299 |     | 
     | 
  |  300 |     | 
             | 
  |  301 |     | 
     | 
  |  302 |     | 
     | 
  |  303 |     | 
     | 
  |  304 |     | 
     | 
  |  305 |     | 
     | 
  |  306 |     | 
           public String getFormatterClass() { | 
  |  307 |    0 |                    String formatterClass = super.getFormatterClass();  | 
  |  308 |    0 |                    if (formatterClass == null) { | 
  |  309 |    0 |                            formatterClass = getDelegate().getFormatterClass();  | 
  |  310 |     | 
                   }  | 
  |  311 |     | 
     | 
  |  312 |    0 |                    return formatterClass;  | 
  |  313 |     | 
           }  | 
  |  314 |     | 
     | 
  |  315 |     | 
             | 
  |  316 |     | 
     | 
  |  317 |     | 
     | 
  |  318 |     | 
           @Override  | 
  |  319 |     | 
           public String getDisplayLabelAttribute() { | 
  |  320 |    0 |                    String displayLabelAttribute = super.getDisplayLabelAttribute();  | 
  |  321 |    0 |                    if (StringUtils.isBlank(displayLabelAttribute)) { | 
  |  322 |    0 |                            displayLabelAttribute = getDelegate().getDisplayLabelAttribute();  | 
  |  323 |     | 
                   }  | 
  |  324 |    0 |                    return displayLabelAttribute;  | 
  |  325 |     | 
           }  | 
  |  326 |     | 
     | 
  |  327 |     | 
             | 
  |  328 |     | 
     | 
  |  329 |     | 
     | 
  |  330 |     | 
     | 
  |  331 |     | 
     | 
  |  332 |     | 
     | 
  |  333 |     | 
           @Override  | 
  |  334 |     | 
           public void completeValidation(Class rootObjectClass, Class otherObjectClass) { | 
  |  335 |    0 |                    if (StringUtils.isBlank(sourceExternalizableBusinessObjectInterface)) { | 
  |  336 |    0 |                            throw new IllegalArgumentException(  | 
  |  337 |     | 
                                           "invalid (blank) sourceClassName for attribute '"  | 
  |  338 |     | 
                                                           + rootObjectClass.getName() + "." + getName() + "'");  | 
  |  339 |     | 
                   }  | 
  |  340 |    0 |                    if (StringUtils.isBlank(sourceAttributeName)) { | 
  |  341 |    0 |                            throw new IllegalArgumentException(  | 
  |  342 |     | 
                                           "invalid (blank) sourceAttributeName for attribute '"  | 
  |  343 |     | 
                                                           + rootObjectClass.getName() + "." + getName() + "'");  | 
  |  344 |     | 
                   }  | 
  |  345 |    0 |                    if ( DataDictionary.validateEBOs ) { | 
  |  346 |    0 |                            getDelegate();   | 
  |  347 |    0 |                            super.completeValidation(rootObjectClass, otherObjectClass);  | 
  |  348 |     | 
                   }  | 
  |  349 |    0 |            }  | 
  |  350 |     | 
     | 
  |  351 |     | 
             | 
  |  352 |     | 
     | 
  |  353 |     | 
     | 
  |  354 |     | 
           public String toString() { | 
  |  355 |    0 |                    String name = super.getName();  | 
  |  356 |     | 
     | 
  |  357 |     | 
                     | 
  |  358 |     | 
                     | 
  |  359 |     | 
                     | 
  |  360 |    0 |                    if ((name == null) && (getDelegate() != null)) { | 
  |  361 |    0 |                            name = getDelegate().getName();  | 
  |  362 |     | 
                   }  | 
  |  363 |    0 |                    return "AttributeReferenceDefinition for attribute " + name;  | 
  |  364 |     | 
           }  | 
  |  365 |     | 
   }  |