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