Coverage Report - org.kuali.rice.krad.service.impl.DataDictionaryServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
DataDictionaryServiceImpl
0%
0/297
0%
0/138
2.013
 
 1  
 /**
 2  
  * Copyright 2005-2011 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  
 package org.kuali.rice.krad.service.impl;
 17  
 
 18  
 import org.apache.commons.lang.StringUtils;
 19  
 import org.apache.log4j.Logger;
 20  
 import org.kuali.rice.core.api.config.property.ConfigurationService;
 21  
 import org.kuali.rice.core.api.util.ClassLoaderUtils;
 22  
 import org.kuali.rice.core.web.format.Formatter;
 23  
 import org.kuali.rice.kew.api.KewApiServiceLocator;
 24  
 import org.kuali.rice.kew.api.doctype.DocumentType;
 25  
 import org.kuali.rice.kew.api.doctype.DocumentTypeService;
 26  
 import org.kuali.rice.krad.bo.BusinessObject;
 27  
 import org.kuali.rice.krad.datadictionary.AttributeDefinition;
 28  
 import org.kuali.rice.krad.datadictionary.AttributeSecurity;
 29  
 import org.kuali.rice.krad.datadictionary.BusinessObjectEntry;
 30  
 import org.kuali.rice.krad.datadictionary.CollectionDefinition;
 31  
 import org.kuali.rice.krad.datadictionary.DataDictionary;
 32  
 import org.kuali.rice.krad.datadictionary.DataDictionaryEntryBase;
 33  
 import org.kuali.rice.krad.datadictionary.DataObjectEntry;
 34  
 import org.kuali.rice.krad.datadictionary.DocumentEntry;
 35  
 import org.kuali.rice.krad.datadictionary.InactivationBlockingMetadata;
 36  
 import org.kuali.rice.krad.datadictionary.PrimitiveAttributeDefinition;
 37  
 import org.kuali.rice.krad.datadictionary.RelationshipDefinition;
 38  
 import org.kuali.rice.krad.datadictionary.control.ControlDefinition;
 39  
 import org.kuali.rice.krad.datadictionary.exception.UnknownBusinessClassAttributeException;
 40  
 import org.kuali.rice.krad.datadictionary.exception.UnknownDocumentTypeException;
 41  
 import org.kuali.rice.krad.datadictionary.validation.ValidationPattern;
 42  
 import org.kuali.rice.krad.document.Document;
 43  
 import org.kuali.rice.krad.keyvalues.KeyValuesFinder;
 44  
 import org.kuali.rice.krad.service.DataDictionaryService;
 45  
 import org.kuali.rice.krad.service.KualiModuleService;
 46  
 import org.kuali.rice.krad.uif.UifConstants;
 47  
 import org.kuali.rice.krad.uif.view.View;
 48  
 import org.kuali.rice.krad.uif.UifConstants.ViewType;
 49  
 
 50  
 import java.io.IOException;
 51  
 import java.util.ArrayList;
 52  
 import java.util.Collections;
 53  
 import java.util.HashMap;
 54  
 import java.util.Iterator;
 55  
 import java.util.List;
 56  
 import java.util.Map;
 57  
 import java.util.Set;
 58  
 import java.util.regex.Pattern;
 59  
 
 60  
 /**
 61  
  * Service implementation for a DataDictionary. It is a thin wrapper around creating, initializing, and
 62  
  * returning a DataDictionary. This is the default, Kuali delivered implementation
 63  
  *
 64  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 65  
  */
 66  
 public class DataDictionaryServiceImpl implements DataDictionaryService {
 67  0
     private static final Logger LOG = Logger.getLogger(DataDictionaryServiceImpl.class);
 68  
 
 69  
     private DataDictionary dataDictionary;
 70  
 
 71  
     private ConfigurationService kualiConfigurationService;
 72  
     private KualiModuleService kualiModuleService;
 73  
     private volatile DocumentTypeService documentTypeService;
 74  
 
 75  
     /**
 76  
      * @see org.kuali.rice.krad.service.DataDictionaryService#setBaselinePackages(java.lang.String)
 77  
      */
 78  
     public void setBaselinePackages(List baselinePackages) throws IOException {
 79  0
         this.addDataDictionaryLocations(baselinePackages);
 80  0
     }
 81  
 
 82  
     /**
 83  
      * Default constructor.
 84  
      */
 85  0
     public DataDictionaryServiceImpl() {
 86  0
         this.dataDictionary = new DataDictionary();
 87  0
     }
 88  
 
 89  0
     public DataDictionaryServiceImpl(DataDictionary dataDictionary) {
 90  0
         this.dataDictionary = dataDictionary;
 91  0
     }
 92  
 
 93  
     /**
 94  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getDataDictionary()
 95  
      */
 96  
     public DataDictionary getDataDictionary() {
 97  0
         return dataDictionary;
 98  
     }
 99  
 
 100  
     /**
 101  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getAttributeControlDefinition(java.lang.String)
 102  
      */
 103  
     public ControlDefinition getAttributeControlDefinition(String entryName, String attributeName) {
 104  0
         ControlDefinition controlDefinition = null;
 105  
 
 106  0
         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
 107  0
         if (attributeDefinition != null) {
 108  0
             controlDefinition = attributeDefinition.getControl();
 109  
         }
 110  
 
 111  0
         return controlDefinition;
 112  
     }
 113  
 
 114  
     /**
 115  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getAttributeSize(java.lang.String)
 116  
      */
 117  
     public Integer getAttributeSize(String entryName, String attributeName) {
 118  0
         Integer size = null;
 119  
 
 120  0
         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
 121  0
         if (attributeDefinition != null) {
 122  0
             ControlDefinition controlDefinition = attributeDefinition.getControl();
 123  0
             if (controlDefinition.isText() || controlDefinition.isCurrency()) {
 124  0
                 size = controlDefinition.getSize();
 125  
             }
 126  
         }
 127  
 
 128  0
         return size;
 129  
     }
 130  
 
 131  
     /**
 132  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getAttributeMinLength(java.lang.String)
 133  
      */
 134  
     public Integer getAttributeMinLength(String entryName, String attributeName) {
 135  0
         Integer minLength = null;
 136  
 
 137  0
         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
 138  0
         if (attributeDefinition != null) {
 139  0
             minLength = attributeDefinition.getMinLength();
 140  
         }
 141  
 
 142  0
         return minLength;
 143  
     }
 144  
 
 145  
     /**
 146  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getAttributeMaxLength(java.lang.String)
 147  
      */
 148  
     public Integer getAttributeMaxLength(String entryName, String attributeName) {
 149  0
         Integer maxLength = null;
 150  
 
 151  0
         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
 152  0
         if (attributeDefinition != null) {
 153  0
             maxLength = attributeDefinition.getMaxLength();
 154  
         }
 155  
 
 156  0
         return maxLength;
 157  
     }
 158  
 
 159  
     /**
 160  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getAttributeExclusiveMin
 161  
      */
 162  
     public String getAttributeExclusiveMin(String entryName, String attributeName) {
 163  0
         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
 164  0
         return attributeDefinition == null ? null : attributeDefinition.getExclusiveMin();
 165  
     }
 166  
 
 167  
     /**
 168  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getAttributeInclusiveMax
 169  
      */
 170  
     public String getAttributeInclusiveMax(String entryName, String attributeName) {
 171  0
         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
 172  0
         return attributeDefinition == null ? null : attributeDefinition.getInclusiveMax();
 173  
     }
 174  
 
 175  
     /**
 176  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getAttributeValidatingExpression(java.lang.String)
 177  
      */
 178  
     public Pattern getAttributeValidatingExpression(String entryName, String attributeName) {
 179  0
         Pattern regex = null;
 180  
 
 181  0
         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
 182  0
         if (attributeDefinition != null) {
 183  0
             if (attributeDefinition.hasValidationPattern()) {
 184  0
                 regex = attributeDefinition.getValidationPattern().getRegexPattern();
 185  
             } else {
 186  
                 // workaround for existing calls which don't bother checking for null return values
 187  0
                 regex = Pattern.compile(".*");
 188  
             }
 189  
         }
 190  
 
 191  0
         return regex;
 192  
     }
 193  
 
 194  
     /**
 195  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getAttributeLabel(java.lang.String)
 196  
      */
 197  
     public String getAttributeLabel(String entryName, String attributeName) {
 198  0
         String label = "";
 199  
 
 200  0
         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
 201  0
         if (attributeDefinition != null) {
 202  
             // KULRICE-4445 prevent NullPointerException by ensuring a label is set
 203  0
             label = attributeDefinition.getLabel();
 204  0
             if (!StringUtils.isEmpty(attributeDefinition.getDisplayLabelAttribute())) {
 205  0
                 attributeDefinition = getAttributeDefinition(entryName, attributeDefinition.getDisplayLabelAttribute());
 206  0
                 if (attributeDefinition != null) {
 207  0
                     label = attributeDefinition.getLabel();
 208  
                 }
 209  
             }
 210  
         }
 211  
 
 212  0
         return label;
 213  
     }
 214  
 
 215  
     /**
 216  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getAttributeShortLabel(java.lang.String)
 217  
      */
 218  
     public String getAttributeShortLabel(String entryName, String attributeName) {
 219  0
         String shortLabel = "";
 220  
 
 221  0
         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
 222  0
         if (attributeDefinition != null) {
 223  0
             if (!StringUtils.isEmpty(attributeDefinition.getDisplayLabelAttribute())) {
 224  0
                 attributeDefinition = getAttributeDefinition(entryName, attributeDefinition.getDisplayLabelAttribute());
 225  0
                 if (attributeDefinition != null) {
 226  0
                     shortLabel = attributeDefinition.getShortLabel();
 227  
                 }
 228  
             } else {
 229  0
                 shortLabel = attributeDefinition.getShortLabel();
 230  
             }
 231  
         }
 232  
 
 233  0
         return shortLabel;
 234  
     }
 235  
 
 236  
     /**
 237  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getAttributeErrorLabel(java.lang.String)
 238  
      */
 239  
     public String getAttributeErrorLabel(String entryName, String attributeName) {
 240  0
         String longAttributeLabel = this.getAttributeLabel(entryName, attributeName);
 241  0
         String shortAttributeLabel = this.getAttributeShortLabel(entryName, attributeName);
 242  0
         return longAttributeLabel + " (" + shortAttributeLabel + ")";
 243  
     }
 244  
 
 245  
     /**
 246  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getAttributeFormatter(java.lang.String)
 247  
      */
 248  
     public Class<? extends Formatter> getAttributeFormatter(String entryName, String attributeName) {
 249  0
         Class formatterClass = null;
 250  
 
 251  0
         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
 252  0
         if (attributeDefinition != null) {
 253  0
             if (attributeDefinition.hasFormatterClass()) {
 254  0
                 formatterClass = ClassLoaderUtils.getClass(attributeDefinition.getFormatterClass());
 255  
             }
 256  
         }
 257  
 
 258  0
         return formatterClass;
 259  
     }
 260  
 
 261  
     /**
 262  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getAttributeForceUppercase(java.lang.String)
 263  
      */
 264  
     public Boolean getAttributeForceUppercase(String entryName,
 265  
             String attributeName) throws UnknownBusinessClassAttributeException {
 266  0
         Boolean forceUppercase = null;
 267  
 
 268  0
         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
 269  0
         if (attributeDefinition == null) {
 270  0
             throw new UnknownBusinessClassAttributeException(
 271  
                     "Could not find a matching data dictionary business class attribute entry for " + entryName + "." +
 272  
                             attributeName);
 273  
         }
 274  0
         forceUppercase = attributeDefinition.getForceUppercase();
 275  
 
 276  0
         return forceUppercase;
 277  
     }
 278  
 
 279  
     /**
 280  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getAttributeDisplayMask(java.lang.String, java.lang.String)
 281  
      */
 282  
     public AttributeSecurity getAttributeSecurity(String entryName, String attributeName) {
 283  0
         AttributeSecurity attributeSecurity = null;
 284  
 
 285  0
         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
 286  0
         if (attributeDefinition != null) {
 287  0
             attributeSecurity = attributeDefinition.getAttributeSecurity();
 288  
         }
 289  
 
 290  0
         return attributeSecurity;
 291  
     }
 292  
 
 293  
     /**
 294  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getAttributeSummary(java.lang.String)
 295  
      */
 296  
     public String getAttributeSummary(String entryName, String attributeName) {
 297  0
         String summary = null;
 298  
 
 299  0
         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
 300  0
         if (attributeDefinition != null) {
 301  0
             summary = attributeDefinition.getSummary();
 302  
         }
 303  
 
 304  0
         return summary;
 305  
     }
 306  
 
 307  
     /**
 308  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getAttributeDescription(java.lang.String)
 309  
      */
 310  
     public String getAttributeDescription(String entryName, String attributeName) {
 311  0
         String description = null;
 312  
 
 313  0
         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
 314  0
         if (attributeDefinition != null) {
 315  0
             description = attributeDefinition.getDescription();
 316  
         }
 317  
 
 318  0
         return description;
 319  
     }
 320  
 
 321  
     /**
 322  
      * @see org.kuali.rice.krad.service.DataDictionaryService#isAttributeRequired(java.lang.Class, java.lang.String)
 323  
      */
 324  
     public Boolean isAttributeRequired(String entryName, String attributeName) {
 325  0
         Boolean required = null;
 326  
 
 327  0
         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
 328  0
         if (attributeDefinition != null) {
 329  0
             required = attributeDefinition.isRequired();
 330  
         }
 331  
 
 332  0
         return required;
 333  
     }
 334  
 
 335  
     /**
 336  
      * @see org.kuali.rice.krad.service.DataDictionaryService#isAttributeDefined(java.lang.Class, java.lang.String)
 337  
      */
 338  
     public Boolean isAttributeDefined(String entryName, String attributeName) {
 339  0
         boolean isDefined = false;
 340  
 
 341  0
         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
 342  0
         if (attributeDefinition != null) {
 343  0
             isDefined = true;
 344  
         }
 345  
 
 346  0
         return isDefined;
 347  
     }
 348  
 
 349  
     /**
 350  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getAttributeValuesScopeId(java.lang.Class,
 351  
      *      java.lang.String)
 352  
      */
 353  
     public Class<? extends KeyValuesFinder> getAttributeValuesFinderClass(String entryName, String attributeName) {
 354  0
         Class valuesFinderClass = null;
 355  
 
 356  0
         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
 357  0
         if (attributeDefinition != null) {
 358  0
             String valuesFinderClassName = attributeDefinition.getControl().getValuesFinderClass();
 359  0
             valuesFinderClass = ClassLoaderUtils.getClass(valuesFinderClassName);
 360  
         }
 361  
 
 362  0
         return valuesFinderClass;
 363  
     }
 364  
 
 365  
     /**
 366  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getCollectionLabel(java.lang.Class, java.lang.String)
 367  
      */
 368  
     public String getCollectionLabel(String entryName, String collectionName) {
 369  0
         String label = "";
 370  
 
 371  0
         CollectionDefinition collectionDefinition = getCollectionDefinition(entryName, collectionName);
 372  0
         if (collectionDefinition != null) {
 373  0
             label = collectionDefinition.getLabel();
 374  
         }
 375  
 
 376  0
         return label;
 377  
     }
 378  
 
 379  
     /**
 380  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getCollectionShortLabel(java.lang.Class, java.lang.String)
 381  
      */
 382  
     public String getCollectionShortLabel(String entryName, String collectionName) {
 383  0
         String shortLabel = "";
 384  
 
 385  0
         CollectionDefinition collectionDefinition = getCollectionDefinition(entryName, collectionName);
 386  0
         if (collectionDefinition != null) {
 387  0
             shortLabel = collectionDefinition.getShortLabel();
 388  
         }
 389  
 
 390  0
         return shortLabel;
 391  
     }
 392  
 
 393  
     /**
 394  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getCollectionElementLabel(java.lang.Class,
 395  
      *      java.lang.String)
 396  
      */
 397  
     public String getCollectionElementLabel(String entryName, String collectionName, Class dataObjectClass) {
 398  0
         String elementLabel = "";
 399  
 
 400  0
         CollectionDefinition collectionDefinition = getCollectionDefinition(entryName, collectionName);
 401  0
         if (collectionDefinition != null) {
 402  0
             elementLabel = collectionDefinition.getElementLabel();
 403  0
             if (StringUtils.isEmpty(elementLabel)) {
 404  0
                 BusinessObjectEntry boe = getDataDictionary().getBusinessObjectEntry(dataObjectClass.getName());
 405  0
                 if (boe != null) {
 406  0
                     elementLabel = boe.getObjectLabel();
 407  
                 }
 408  
             }
 409  
         }
 410  
 
 411  0
         return elementLabel;
 412  
     }
 413  
 
 414  
     /**
 415  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getCollectionSummary(java.lang.Class, java.lang.String)
 416  
      */
 417  
     public String getCollectionSummary(String entryName, String collectionName) {
 418  0
         String summary = null;
 419  
 
 420  0
         CollectionDefinition collectionDefinition = getCollectionDefinition(entryName, collectionName);
 421  0
         if (collectionDefinition != null) {
 422  0
             summary = collectionDefinition.getSummary();
 423  
         }
 424  
 
 425  0
         return summary;
 426  
     }
 427  
 
 428  
     /**
 429  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getCollectionDescription(java.lang.Class,
 430  
      *      java.lang.String)
 431  
      */
 432  
     public String getCollectionDescription(String entryName, String collectionName) {
 433  0
         String description = null;
 434  
 
 435  0
         CollectionDefinition collectionDefinition = getCollectionDefinition(entryName, collectionName);
 436  0
         if (collectionDefinition != null) {
 437  0
             description = collectionDefinition.getDescription();
 438  
         }
 439  
 
 440  0
         return description;
 441  
     }
 442  
 
 443  
     public Class<? extends BusinessObject> getRelationshipSourceClass(String entryName, String relationshipName) {
 444  0
         Class sourceClass = null;
 445  
 
 446  0
         RelationshipDefinition rd = getRelationshipDefinition(entryName, relationshipName);
 447  0
         if (rd != null) {
 448  0
             sourceClass = rd.getSourceClass();
 449  
         }
 450  
 
 451  0
         return sourceClass;
 452  
     }
 453  
 
 454  
     public Class<? extends BusinessObject> getRelationshipTargetClass(String entryName, String relationshipName) {
 455  0
         Class targetClass = null;
 456  
 
 457  0
         RelationshipDefinition rd = getRelationshipDefinition(entryName, relationshipName);
 458  0
         if (rd != null) {
 459  0
             targetClass = rd.getTargetClass();
 460  
         }
 461  
 
 462  0
         return targetClass;
 463  
     }
 464  
 
 465  
     public List<String> getRelationshipSourceAttributes(String entryName, String relationshipName) {
 466  0
         List<String> sourceAttributes = null;
 467  
 
 468  0
         RelationshipDefinition rd = getRelationshipDefinition(entryName, relationshipName);
 469  0
         if (rd != null) {
 470  0
             sourceAttributes = new ArrayList<String>();
 471  
 
 472  0
             for (PrimitiveAttributeDefinition pad : rd.getPrimitiveAttributes()) {
 473  0
                 sourceAttributes.add(pad.getSourceName());
 474  
             }
 475  
         }
 476  
 
 477  0
         return sourceAttributes;
 478  
     }
 479  
 
 480  
     public List<String> getRelationshipTargetAttributes(String entryName, String relationshipName) {
 481  0
         List<String> targetAttributes = null;
 482  
 
 483  0
         RelationshipDefinition rd = getRelationshipDefinition(entryName, relationshipName);
 484  0
         if (rd != null) {
 485  0
             targetAttributes = new ArrayList<String>();
 486  
 
 487  0
             for (PrimitiveAttributeDefinition pad : rd.getPrimitiveAttributes()) {
 488  0
                 targetAttributes.add(pad.getTargetName());
 489  
             }
 490  
         }
 491  
 
 492  0
         return targetAttributes;
 493  
     }
 494  
 
 495  
     public List<String> getRelationshipEntriesForSourceAttribute(String entryName, String sourceAttributeName) {
 496  0
         List<String> relationships = new ArrayList<String>();
 497  
 
 498  0
         DataDictionaryEntryBase entry =
 499  
                 (DataDictionaryEntryBase) getDataDictionary().getDictionaryObjectEntry(entryName);
 500  
 
 501  0
         for (RelationshipDefinition def : entry.getRelationships()) {
 502  0
             for (PrimitiveAttributeDefinition pddef : def.getPrimitiveAttributes()) {
 503  0
                 if (StringUtils.equals(sourceAttributeName, pddef.getSourceName())) {
 504  0
                     relationships.add(def.getObjectAttributeName());
 505  0
                     break;
 506  
                 }
 507  
             }
 508  
         }
 509  0
         return relationships;
 510  
     }
 511  
 
 512  
     public List<String> getRelationshipEntriesForTargetAttribute(String entryName, String targetAttributeName) {
 513  0
         List<String> relationships = new ArrayList<String>();
 514  
 
 515  0
         DataDictionaryEntryBase entry =
 516  
                 (DataDictionaryEntryBase) getDataDictionary().getDictionaryObjectEntry(entryName);
 517  
 
 518  0
         for (RelationshipDefinition def : entry.getRelationships()) {
 519  0
             for (PrimitiveAttributeDefinition pddef : def.getPrimitiveAttributes()) {
 520  0
                 if (StringUtils.equals(targetAttributeName, pddef.getTargetName())) {
 521  0
                     relationships.add(def.getObjectAttributeName());
 522  0
                     break;
 523  
                 }
 524  
             }
 525  
         }
 526  0
         return relationships;
 527  
     }
 528  
 
 529  
     /**
 530  
      * @param objectClass
 531  
      * @param attributeName
 532  
      * @return AttributeDefinition for the given dataObjectClass and attribute name, or null if there is none
 533  
      * @throws IllegalArgumentException if the given Class is null or is not a BusinessObject class
 534  
      */
 535  
     public AttributeDefinition getAttributeDefinition(String entryName, String attributeName) {
 536  0
         if (StringUtils.isBlank(attributeName)) {
 537  0
             throw new IllegalArgumentException("invalid (blank) attributeName");
 538  
         }
 539  0
         AttributeDefinition attributeDefinition = null;
 540  
 
 541  0
         DataDictionaryEntryBase entry =
 542  
                 (DataDictionaryEntryBase) getDataDictionary().getDictionaryObjectEntry(entryName);
 543  0
         if (entry != null) {
 544  0
             attributeDefinition = entry.getAttributeDefinition(attributeName);
 545  
         }
 546  
 
 547  0
         return attributeDefinition;
 548  
     }
 549  
 
 550  
     /**
 551  
      * @param entryName
 552  
      * @param collectionName
 553  
      * @return CollectionDefinition for the given entryName and collectionName, or null if there is none
 554  
      */
 555  
     private CollectionDefinition getCollectionDefinition(String entryName, String collectionName) {
 556  0
         if (StringUtils.isBlank(collectionName)) {
 557  0
             throw new IllegalArgumentException("invalid (blank) collectionName");
 558  
         }
 559  0
         CollectionDefinition collectionDefinition = null;
 560  
 
 561  0
         DataDictionaryEntryBase entry =
 562  
                 (DataDictionaryEntryBase) getDataDictionary().getDictionaryObjectEntry(entryName);
 563  0
         if (entry != null) {
 564  0
             collectionDefinition = entry.getCollectionDefinition(collectionName);
 565  
         }
 566  
 
 567  0
         return collectionDefinition;
 568  
     }
 569  
 
 570  
     /**
 571  
      * @param entryName
 572  
      * @param relationshipName
 573  
      * @return RelationshipDefinition for the given entryName and relationshipName, or null if there is none
 574  
      */
 575  
     private RelationshipDefinition getRelationshipDefinition(String entryName, String relationshipName) {
 576  0
         if (StringUtils.isBlank(relationshipName)) {
 577  0
             throw new IllegalArgumentException("invalid (blank) relationshipName");
 578  
         }
 579  
 
 580  0
         RelationshipDefinition relationshipDefinition = null;
 581  
 
 582  0
         DataDictionaryEntryBase entry =
 583  
                 (DataDictionaryEntryBase) getDataDictionary().getDictionaryObjectEntry(entryName);
 584  0
         if (entry != null) {
 585  0
             relationshipDefinition = entry.getRelationshipDefinition(relationshipName);
 586  
         }
 587  
 
 588  0
         return relationshipDefinition;
 589  
     }
 590  
 
 591  
     /**
 592  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getRelationshipAttributeMap(java.lang.String, java.lang.String)
 593  
      */
 594  
     public Map<String, String> getRelationshipAttributeMap(String entryName, String relationshipName) {
 595  0
         Map<String, String> attributeMap = new HashMap<String, String>();
 596  0
         RelationshipDefinition relationshipDefinition = getRelationshipDefinition(entryName, relationshipName);
 597  0
         for (Iterator iter = relationshipDefinition.getPrimitiveAttributes().iterator(); iter.hasNext(); ) {
 598  0
             PrimitiveAttributeDefinition attribute = (PrimitiveAttributeDefinition) iter.next();
 599  0
             attributeMap.put(attribute.getTargetName(), attribute.getSourceName());
 600  0
         }
 601  0
         return attributeMap;
 602  
     }
 603  
 
 604  
     public boolean hasRelationship(String entryName, String relationshipName) {
 605  0
         return getRelationshipDefinition(entryName, relationshipName) != null;
 606  
     }
 607  
 
 608  
     public List<String> getRelationshipNames(String entryName) {
 609  0
         DataDictionaryEntryBase entry =
 610  
                 (DataDictionaryEntryBase) getDataDictionary().getDictionaryObjectEntry(entryName);
 611  
 
 612  0
         List<String> relationshipNames = new ArrayList<String>();
 613  0
         for (RelationshipDefinition def : entry.getRelationships()) {
 614  0
             relationshipNames.add(def.getObjectAttributeName());
 615  
         }
 616  0
         return relationshipNames;
 617  
     }
 618  
 
 619  
     /**
 620  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getAttributeControlDefinition(java.lang.String, java.lang.String)
 621  
      */
 622  
     public ControlDefinition getAttributeControlDefinition(Class dataObjectClass, String attributeName) {
 623  0
         return getAttributeControlDefinition(dataObjectClass.getName(), attributeName);
 624  
     }
 625  
 
 626  
     /**
 627  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getAttributeDescription(java.lang.String, java.lang.String)
 628  
      */
 629  
     public String getAttributeDescription(Class dataObjectClass, String attributeName) {
 630  0
         return getAttributeDescription(dataObjectClass.getName(), attributeName);
 631  
     }
 632  
 
 633  
     /**
 634  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getAttributeForceUppercase(java.lang.String, java.lang.String)
 635  
      */
 636  
     public Boolean getAttributeForceUppercase(Class dataObjectClass, String attributeName) {
 637  0
         return getAttributeForceUppercase(dataObjectClass.getName(), attributeName);
 638  
     }
 639  
 
 640  
     /**
 641  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getAttributeFormatter(java.lang.String, java.lang.String)
 642  
      */
 643  
     public Class<? extends Formatter> getAttributeFormatter(Class dataObjectClass, String attributeName) {
 644  0
         return getAttributeFormatter(dataObjectClass.getName(), attributeName);
 645  
     }
 646  
 
 647  
     /**
 648  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getAttributeLabel(java.lang.String, java.lang.String)
 649  
      */
 650  
     public String getAttributeLabel(Class dataObjectClass, String attributeName) {
 651  0
         return getAttributeLabel(dataObjectClass.getName(), attributeName);
 652  
     }
 653  
 
 654  
     /**
 655  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getAttributeMaxLength(java.lang.String, java.lang.String)
 656  
      */
 657  
     public Integer getAttributeMaxLength(Class dataObjectClass, String attributeName) {
 658  0
         return getAttributeMaxLength(dataObjectClass.getName(), attributeName);
 659  
     }
 660  
 
 661  
     /**
 662  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getAttributeShortLabel(java.lang.String, java.lang.String)
 663  
      */
 664  
     public String getAttributeShortLabel(Class dataObjectClass, String attributeName) {
 665  0
         return getAttributeShortLabel(dataObjectClass.getName(), attributeName);
 666  
     }
 667  
 
 668  
     /**
 669  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getAttributeErrorLabel(java.lang.String, java.lang.String)
 670  
      */
 671  
     public String getAttributeErrorLabel(Class dataObjectClass, String attributeName) {
 672  0
         return getAttributeErrorLabel(dataObjectClass.getName(), attributeName);
 673  
     }
 674  
 
 675  
     /**
 676  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getAttributeSize(java.lang.String, java.lang.String)
 677  
      */
 678  
     public Integer getAttributeSize(Class dataObjectClass, String attributeName) {
 679  0
         return getAttributeSize(dataObjectClass.getName(), attributeName);
 680  
     }
 681  
 
 682  
     /**
 683  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getAttributeSummary(java.lang.String, java.lang.String)
 684  
      */
 685  
     public String getAttributeSummary(Class dataObjectClass, String attributeName) {
 686  0
         return getAttributeSummary(dataObjectClass.getName(), attributeName);
 687  
     }
 688  
 
 689  
     /**
 690  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getAttributeValidatingExpression(java.lang.String, java.lang.String)
 691  
      */
 692  
     public Pattern getAttributeValidatingExpression(Class dataObjectClass, String attributeName) {
 693  0
         return getAttributeValidatingExpression(dataObjectClass.getName(), attributeName);
 694  
     }
 695  
 
 696  
     /**
 697  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getAttributeValuesFinderClass(java.lang.String, java.lang.String)
 698  
      */
 699  
     public Class getAttributeValuesFinderClass(Class dataObjectClass, String attributeName) {
 700  0
         return getAttributeValuesFinderClass(dataObjectClass.getName(), attributeName);
 701  
     }
 702  
 
 703  
     /**
 704  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getAttributeValidatingErrorMessageKey(java.lang.String, java.lang.String)
 705  
      */
 706  
     public String getAttributeValidatingErrorMessageKey(String entryName, String attributeName) {
 707  0
         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
 708  0
         if (attributeDefinition != null) {
 709  0
             if (attributeDefinition.hasValidationPattern()) {
 710  0
                 ValidationPattern validationPattern = attributeDefinition.getValidationPattern();
 711  0
                 return validationPattern.getValidationErrorMessageKey();
 712  
             }
 713  
         }
 714  0
         return null;
 715  
     }
 716  
 
 717  
     /**
 718  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getAttributeValidatingErrorMessageParameters(java.lang.String, java.lang.String)
 719  
      */
 720  
     public String[] getAttributeValidatingErrorMessageParameters(String entryName, String attributeName) {
 721  0
         AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
 722  0
         if (attributeDefinition != null) {
 723  0
             if (attributeDefinition.hasValidationPattern()) {
 724  0
                 ValidationPattern validationPattern = attributeDefinition.getValidationPattern();
 725  0
                 String attributeLabel = getAttributeErrorLabel(entryName, attributeName);
 726  0
                 return validationPattern.getValidationErrorMessageParameters(attributeLabel);
 727  
             }
 728  
         }
 729  0
         return null;
 730  
     }
 731  
 
 732  
     /**
 733  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getCollectionDescription(java.lang.String, java.lang.String)
 734  
      */
 735  
     public String getCollectionDescription(Class dataObjectClass, String collectionName) {
 736  0
         return getCollectionDescription(dataObjectClass.getName(), collectionName);
 737  
     }
 738  
 
 739  
     /**
 740  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getCollectionLabel(java.lang.String, java.lang.String)
 741  
      */
 742  
     public String getCollectionLabel(Class dataObjectClass, String collectionName) {
 743  0
         return getCollectionLabel(dataObjectClass.getName(), collectionName);
 744  
     }
 745  
 
 746  
     /**
 747  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getCollectionShortLabel(java.lang.String, java.lang.String)
 748  
      */
 749  
     public String getCollectionShortLabel(Class dataObjectClass, String collectionName) {
 750  0
         return getCollectionShortLabel(dataObjectClass.getName(), collectionName);
 751  
     }
 752  
 
 753  
     /**
 754  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getCollectionSummary(java.lang.String, java.lang.String)
 755  
      */
 756  
     public String getCollectionSummary(Class dataObjectClass, String collectionName) {
 757  0
         return getCollectionSummary(dataObjectClass.getName(), collectionName);
 758  
     }
 759  
 
 760  
     /**
 761  
      * @see org.kuali.rice.krad.service.DataDictionaryService#isAttributeDefined(java.lang.String, java.lang.String)
 762  
      */
 763  
     public Boolean isAttributeDefined(Class dataObjectClass, String attributeName) {
 764  0
         return isAttributeDefined(dataObjectClass.getName(), attributeName);
 765  
     }
 766  
 
 767  
     /**
 768  
      * @see org.kuali.rice.krad.service.DataDictionaryService#isAttributeRequired(java.lang.String, java.lang.String)
 769  
      */
 770  
     public Boolean isAttributeRequired(Class dataObjectClass, String attributeName) {
 771  0
         return isAttributeRequired(dataObjectClass.getName(), attributeName);
 772  
     }
 773  
 
 774  
     /**
 775  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getDocumentLabelByClass(java.lang.Class)
 776  
      */
 777  
     public String getDocumentLabelByClass(Class documentOrBusinessObjectClass) {
 778  0
         return getDocumentLabelByTypeName(getDocumentTypeNameByClass(documentOrBusinessObjectClass));
 779  
     }
 780  
 
 781  
     /**
 782  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getDocumentLabelByTypeName(java.lang.String)
 783  
      */
 784  
     public String getDocumentLabelByTypeName(String documentTypeName) {
 785  0
         String label = null;
 786  0
         if (StringUtils.isNotBlank(documentTypeName)) {
 787  0
             DocumentType documentType = getDocumentTypeService().getDocumentTypeByName(documentTypeName);
 788  0
             if (documentType != null) {
 789  0
                 label = documentType.getLabel();
 790  
             }
 791  
         }
 792  0
         return label;
 793  
     }
 794  
 
 795  
     /**
 796  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getDocumentTypeNameByClass(java.lang.Class)
 797  
      */
 798  
     public String getDocumentTypeNameByClass(Class documentClass) {
 799  0
         if (documentClass == null) {
 800  0
             throw new IllegalArgumentException("invalid (null) documentClass");
 801  
         }
 802  0
         if (!Document.class.isAssignableFrom(documentClass)) {
 803  0
             throw new IllegalArgumentException("invalid (non-Document) documentClass");
 804  
         }
 805  
 
 806  0
         String documentTypeName = null;
 807  
 
 808  0
         DocumentEntry documentEntry = getDataDictionary().getDocumentEntry(documentClass.getName());
 809  0
         if (documentEntry != null) {
 810  0
             documentTypeName = documentEntry.getDocumentTypeName();
 811  
         }
 812  
 
 813  0
         return documentTypeName;
 814  
     }
 815  
 
 816  
     /**
 817  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getValidDocumentTypeNameByClass(java.lang.Class)
 818  
      */
 819  
     public String getValidDocumentTypeNameByClass(Class documentClass) {
 820  0
         String documentTypeName = getDocumentTypeNameByClass(documentClass);
 821  0
         if (StringUtils.isBlank(documentTypeName)) {
 822  0
             throw new UnknownDocumentTypeException(
 823  
                     "unable to get documentTypeName for unknown documentClass '" + documentClass.getName() + "'");
 824  
         }
 825  0
         return documentTypeName;
 826  
     }
 827  
 
 828  
     /**
 829  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getDocumentClassByTypeName(java.lang.String)
 830  
      */
 831  
     public Class<? extends Document> getDocumentClassByTypeName(String documentTypeName) {
 832  0
         Class clazz = null;
 833  
 
 834  0
         DocumentEntry documentEntry = getDataDictionary().getDocumentEntry(documentTypeName);
 835  0
         if (documentEntry != null) {
 836  0
             clazz = documentEntry.getDocumentClass();
 837  
         }
 838  
 
 839  0
         return clazz;
 840  
     }
 841  
 
 842  
     /**
 843  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getValidDocumentClassByTypeName(java.lang.String)
 844  
      */
 845  
     public Class<? extends Document> getValidDocumentClassByTypeName(String documentTypeName) {
 846  0
         Class clazz = getDocumentClassByTypeName(documentTypeName);
 847  0
         if (clazz == null) {
 848  0
             throw new UnknownDocumentTypeException(
 849  
                     "unable to get class for unknown documentTypeName '" + documentTypeName + "'");
 850  
         }
 851  0
         return clazz;
 852  
     }
 853  
 
 854  
     /**
 855  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getViewById(java.lang.String)
 856  
      */
 857  
     public View getViewById(String viewId) {
 858  0
         return dataDictionary.getViewById(viewId);
 859  
     }
 860  
 
 861  
     /**
 862  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getDictionaryObject(java.lang.String)
 863  
      */
 864  
     public Object getDictionaryObject(String id) {
 865  0
         return dataDictionary.getDictionaryObject(id);
 866  
     }
 867  
 
 868  
     /**
 869  
      * @see org.kuali.rice.krad.service.DataDictionaryService#containsDictionaryObject(java.lang.String)
 870  
      */
 871  
     public boolean containsDictionaryObject(String id) {
 872  0
         return dataDictionary.containsDictionaryObject(id);
 873  
     }
 874  
 
 875  
     /**
 876  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getViewByTypeIndex(java.lang.String,
 877  
      *      java.util.Map)
 878  
      */
 879  
     public View getViewByTypeIndex(ViewType viewTypeName, Map<String, String> indexKey) {
 880  0
         return dataDictionary.getViewByTypeIndex(viewTypeName, indexKey);
 881  
     }
 882  
 
 883  
     public void addDataDictionaryLocation(String location) throws IOException {
 884  0
         dataDictionary.addConfigFileLocation(location);
 885  0
     }
 886  
 
 887  
     public void addDataDictionaryLocations(List<String> locations) throws IOException {
 888  0
         for (String location : locations) {
 889  0
             addDataDictionaryLocation(location);
 890  
         }
 891  0
     }
 892  
 
 893  
     /**
 894  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getGroupByAttributesForEffectiveDating(java.lang.Class)
 895  
      */
 896  
     public List<String> getGroupByAttributesForEffectiveDating(Class dataObjectClass) {
 897  0
         List<String> groupByList = null;
 898  
 
 899  0
         DataObjectEntry objectEntry = getDataDictionary().getDataObjectEntry(dataObjectClass.getName());
 900  0
         if (objectEntry != null) {
 901  0
             groupByList = objectEntry.getGroupByAttributesForEffectiveDating();
 902  
         }
 903  
 
 904  0
         return groupByList;
 905  
     }
 906  
 
 907  
     /**
 908  
      * Returns all of the inactivation blocks registered for a particular business object
 909  
      *
 910  
      * @see org.kuali.rice.krad.service.DataDictionaryService#getAllInactivationBlockingDefinitions(java.lang.Class)
 911  
      */
 912  
     public Set<InactivationBlockingMetadata> getAllInactivationBlockingDefinitions(
 913  
             Class inactivationBlockedBusinessObjectClass) {
 914  0
         Set<InactivationBlockingMetadata> blockingClasses =
 915  
                 dataDictionary.getAllInactivationBlockingMetadatas(inactivationBlockedBusinessObjectClass);
 916  0
         if (blockingClasses == null) {
 917  0
             return Collections.emptySet();
 918  
         }
 919  0
         return blockingClasses;
 920  
     }
 921  
     
 922  
     public DocumentTypeService getDocumentTypeService() {
 923  0
         if (documentTypeService == null) {
 924  0
             documentTypeService = KewApiServiceLocator.getDocumentTypeService();
 925  
         }
 926  0
         return documentTypeService;
 927  
     }
 928  
 
 929  
     public void setKualiConfigurationService(ConfigurationService kualiConfigurationService) {
 930  0
         this.kualiConfigurationService = kualiConfigurationService;
 931  0
     }
 932  
 
 933  
     public ConfigurationService getKualiConfigurationService() {
 934  0
         return kualiConfigurationService;
 935  
     }
 936  
 
 937  
     public KualiModuleService getKualiModuleService() {
 938  0
         return kualiModuleService;
 939  
     }
 940  
 
 941  
     public void setKualiModuleService(KualiModuleService kualiModuleService) {
 942  0
         this.kualiModuleService = kualiModuleService;
 943  0
     }
 944  
 }