Coverage Report - org.kuali.rice.kns.service.impl.TransactionalDocumentDictionaryServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
TransactionalDocumentDictionaryServiceImpl
0%
0/45
0%
0/16
1.833
 
 1  
 /*
 2  
  * Copyright 2005-2007 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.kns.service.impl;
 17  
 
 18  
 import java.util.Collection;
 19  
 
 20  
 import org.kuali.rice.kew.api.KewApiServiceLocator;
 21  
 import org.kuali.rice.kew.api.doctype.DocumentType;
 22  
 import org.kuali.rice.kns.service.TransactionalDocumentDictionaryService;
 23  
 import org.kuali.rice.krad.datadictionary.DataDictionary;
 24  
 import org.kuali.rice.krad.datadictionary.TransactionalDocumentEntry;
 25  
 import org.kuali.rice.krad.document.TransactionalDocument;
 26  
 import org.kuali.rice.krad.rule.BusinessRule;
 27  
 import org.kuali.rice.krad.service.DataDictionaryService;
 28  
 
 29  
 /**
 30  
  * This class is the service implementation for the TransactionalDocumentDictionary structure. Defines the API for the interacting
 31  
  * with Document-related entries in the data dictionary. This is the default implementation that gets delivered with Kuali.
 32  
  */
 33  
 @Deprecated
 34  0
 public class TransactionalDocumentDictionaryServiceImpl implements TransactionalDocumentDictionaryService {
 35  
     private DataDictionaryService dataDictionaryService;
 36  
 
 37  
     /**
 38  
      * @see org.kuali.rice.kns.service.TransactionalDocumentDictionaryService#getAllowsCopy(org.kuali.bo.TransactionalDocument)
 39  
      */
 40  
     public Boolean getAllowsCopy(TransactionalDocument document) {
 41  0
         Boolean allowsCopy = null;
 42  
 
 43  0
         TransactionalDocumentEntry entry = getTransactionalDocumentEntry(document);
 44  0
         if (entry != null) {
 45  0
             allowsCopy = Boolean.valueOf(entry.getAllowsCopy());
 46  
         }
 47  
 
 48  0
         return allowsCopy;
 49  
     }
 50  
 
 51  
     /**
 52  
      * @see org.kuali.rice.kns.service.TransactionalDocumentDictionaryService#getDocumentClassByName(java.lang.String)
 53  
      */
 54  
     public Class getDocumentClassByName(String documentTypeName) {
 55  0
         Class documentClass = null;
 56  
 
 57  0
         TransactionalDocumentEntry entry = getTransactionalDocumentEntryBydocumentTypeName(documentTypeName);
 58  0
         if (entry != null) {
 59  0
             documentClass = entry.getDocumentClass();
 60  
         }
 61  
 
 62  0
         return documentClass;
 63  
     }
 64  
 
 65  
     /**
 66  
      * @see org.kuali.rice.kns.service.TransactionalDocumentDictionaryService#getDescription(org.kuali.bo.TransactionalDocument)
 67  
      */
 68  
     public String getDescription(String transactionalDocumentTypeName) {
 69  0
         String description = null;
 70  
 
 71  0
         DocumentType docType = getDocumentType(transactionalDocumentTypeName);
 72  0
         if (docType != null) {
 73  0
             description = docType.getDescription();
 74  
         }
 75  
 
 76  0
         return description;
 77  
     }
 78  
 
 79  
     /**
 80  
      * @see org.kuali.rice.kns.service.TransactionalDocumentDictionaryService#getDescription(org.kuali.bo.TransactionalDocument)
 81  
      */
 82  
     public String getLabel(String transactionalDocumentTypeName) {
 83  0
         String label = null;
 84  
 
 85  0
         DocumentType docType = getDocumentType(transactionalDocumentTypeName);
 86  0
         if (docType != null) {
 87  0
             label = docType.getLabel();
 88  
         }
 89  
 
 90  0
         return label;
 91  
     }
 92  
 
 93  
     /**
 94  
      * @see org.kuali.rice.kns.service.TransactionalDocumentDictionaryService#getBusinessRulesClass(org.kuali.bo.TransactionalDocument)
 95  
      */
 96  
     public Class<? extends BusinessRule> getBusinessRulesClass(TransactionalDocument document) {
 97  0
         Class<? extends BusinessRule> businessRulesClass = null;
 98  
 
 99  
         //TransactionalDocumentEntry entry = getTransactionalDocumentEntry(document);
 100  0
         String docTypeName = document.getDocumentHeader().getWorkflowDocument().getDocumentTypeName();
 101  0
         TransactionalDocumentEntry entry = getTransactionalDocumentEntryBydocumentTypeName(docTypeName);
 102  0
         if (entry != null) {
 103  0
             businessRulesClass = entry.getBusinessRulesClass();
 104  
         }
 105  
 
 106  0
         return businessRulesClass;
 107  
     }
 108  
 
 109  
     /**
 110  
      * Sets the data dictionary instance.
 111  
      * 
 112  
      * @param dataDictionaryService
 113  
      */
 114  
     public void setDataDictionaryService(DataDictionaryService dataDictionaryService) {
 115  0
         this.dataDictionaryService = dataDictionaryService;
 116  0
     }
 117  
 
 118  
     /**
 119  
      * Retrieves the data dictionary instance.
 120  
      * 
 121  
      * @return
 122  
      */
 123  
     public DataDictionary getDataDictionary() {
 124  0
         return this.dataDictionaryService.getDataDictionary();
 125  
     }
 126  
 
 127  
     /**
 128  
      * This method gets the workflow document type for the given documentTypeName
 129  
      * 
 130  
      * @param documentTypeName
 131  
      * @return
 132  
      */
 133  
     protected DocumentType getDocumentType(String documentTypeName) {
 134  0
         return KewApiServiceLocator.getDocumentTypeService().getDocumentTypeByName(documentTypeName);
 135  
     }
 136  
 
 137  
     /**
 138  
      * Retrieves the document entry by transactional document class instance.
 139  
      * 
 140  
      * @param document
 141  
      * @return TransactionalDocumentEntry
 142  
      */
 143  
     private TransactionalDocumentEntry getTransactionalDocumentEntry(TransactionalDocument document) {
 144  0
         if (document == null) {
 145  0
             throw new IllegalArgumentException("invalid (null) document");
 146  
         }
 147  
 
 148  0
         TransactionalDocumentEntry entry = (TransactionalDocumentEntry)getDataDictionary().getDocumentEntry(document.getClass().getName());
 149  
 
 150  0
         return entry;
 151  
     }
 152  
 
 153  
     /**
 154  
      * Retrieves the document entry by transactional document type name.
 155  
      * 
 156  
      * @param documentTypeName
 157  
      * @return
 158  
      */
 159  
     private TransactionalDocumentEntry getTransactionalDocumentEntryBydocumentTypeName(String documentTypeName) {
 160  0
         if (documentTypeName == null) {
 161  0
             throw new IllegalArgumentException("invalid (null) document type name");
 162  
         }
 163  
 
 164  0
         TransactionalDocumentEntry entry = (TransactionalDocumentEntry) getDataDictionary().getDocumentEntry(documentTypeName);
 165  
 
 166  0
         return entry;
 167  
     }
 168  
 
 169  
         /**
 170  
          * This overridden method ...
 171  
          * 
 172  
          * @see org.kuali.rice.kns.service.TransactionalDocumentDictionaryService#getDefaultExistenceChecks(java.lang.String)
 173  
          */
 174  
         public Collection getDefaultExistenceChecks(String docTypeName) {
 175  0
         Collection defaultExistenceChecks = null;
 176  
 
 177  0
         TransactionalDocumentEntry entry = getTransactionalDocumentEntryBydocumentTypeName(docTypeName);
 178  0
         if (entry != null) {
 179  0
             defaultExistenceChecks = entry.getDefaultExistenceChecks();
 180  
         }
 181  
 
 182  0
         return defaultExistenceChecks;
 183  
         }
 184  
 
 185  
         /**
 186  
          * This overridden method ...
 187  
          * 
 188  
          * @see org.kuali.rice.kns.service.TransactionalDocumentDictionaryService#getDefaultExistenceChecks(org.kuali.rice.krad.document.TransactionalDocument)
 189  
          */
 190  
         public Collection getDefaultExistenceChecks(TransactionalDocument document) {
 191  0
                 return getDefaultExistenceChecks(getTransactionalDocumentEntry(document).getDocumentTypeName());
 192  
         }
 193  
 }