001/** 002 * Copyright 2005-2016 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.kns.service.impl; 017 018import java.util.Collection; 019 020import org.kuali.rice.kew.api.KewApiServiceLocator; 021import org.kuali.rice.kew.api.doctype.DocumentType; 022import org.kuali.rice.kns.service.TransactionalDocumentDictionaryService; 023import org.kuali.rice.krad.datadictionary.DataDictionary; 024import org.kuali.rice.krad.datadictionary.TransactionalDocumentEntry; 025import org.kuali.rice.krad.document.TransactionalDocument; 026import org.kuali.rice.krad.rules.rule.BusinessRule; 027import org.kuali.rice.krad.service.DataDictionaryService; 028 029/** 030 * This class is the service implementation for the TransactionalDocumentDictionary structure. Defines the API for the interacting 031 * with Document-related entries in the data dictionary. This is the default implementation that gets delivered with Kuali. 032 * 033 * @deprecated Only used by KNS classes, use KRAD. 034 */ 035@Deprecated 036public class TransactionalDocumentDictionaryServiceImpl implements TransactionalDocumentDictionaryService { 037 private DataDictionaryService dataDictionaryService; 038 039 /** 040 * @see org.kuali.rice.kns.service.TransactionalDocumentDictionaryService#getAllowsCopy(org.kuali.bo.TransactionalDocument) 041 */ 042 public Boolean getAllowsCopy(TransactionalDocument document) { 043 Boolean allowsCopy = null; 044 045 TransactionalDocumentEntry entry = getTransactionalDocumentEntry(document); 046 if (entry != null) { 047 allowsCopy = Boolean.valueOf(entry.getAllowsCopy()); 048 } 049 050 return allowsCopy; 051 } 052 053 /** 054 * @see org.kuali.rice.kns.service.TransactionalDocumentDictionaryService#getDocumentClassByName(java.lang.String) 055 */ 056 public Class getDocumentClassByName(String documentTypeName) { 057 Class documentClass = null; 058 059 TransactionalDocumentEntry entry = getTransactionalDocumentEntryBydocumentTypeName(documentTypeName); 060 if (entry != null) { 061 documentClass = entry.getDocumentClass(); 062 } 063 064 return documentClass; 065 } 066 067 /** 068 * @see org.kuali.rice.kns.service.TransactionalDocumentDictionaryService#getDescription(org.kuali.bo.TransactionalDocument) 069 */ 070 public String getDescription(String transactionalDocumentTypeName) { 071 String description = null; 072 073 DocumentType docType = getDocumentType(transactionalDocumentTypeName); 074 if (docType != null) { 075 description = docType.getDescription(); 076 } 077 078 return description; 079 } 080 081 /** 082 * @see org.kuali.rice.kns.service.TransactionalDocumentDictionaryService#getDescription(org.kuali.bo.TransactionalDocument) 083 */ 084 public String getLabel(String transactionalDocumentTypeName) { 085 String label = null; 086 087 DocumentType docType = getDocumentType(transactionalDocumentTypeName); 088 if (docType != null) { 089 label = docType.getLabel(); 090 } 091 092 return label; 093 } 094 095 096 /** 097 * Sets the data dictionary instance. 098 * 099 * @param dataDictionaryService 100 */ 101 public void setDataDictionaryService(DataDictionaryService dataDictionaryService) { 102 this.dataDictionaryService = dataDictionaryService; 103 } 104 105 /** 106 * Retrieves the data dictionary instance. 107 * 108 * @return 109 */ 110 public DataDictionary getDataDictionary() { 111 return this.dataDictionaryService.getDataDictionary(); 112 } 113 114 /** 115 * This method gets the workflow document type for the given documentTypeName 116 * 117 * @param documentTypeName 118 * @return 119 */ 120 protected DocumentType getDocumentType(String documentTypeName) { 121 return KewApiServiceLocator.getDocumentTypeService().getDocumentTypeByName(documentTypeName); 122 } 123 124 /** 125 * Retrieves the document entry by transactional document class instance. 126 * 127 * @param document 128 * @return TransactionalDocumentEntry 129 */ 130 private TransactionalDocumentEntry getTransactionalDocumentEntry(TransactionalDocument document) { 131 if (document == null) { 132 throw new IllegalArgumentException("invalid (null) document"); 133 } 134 135 TransactionalDocumentEntry entry = (TransactionalDocumentEntry)getDataDictionary().getDocumentEntry(document.getClass().getName()); 136 137 return entry; 138 } 139 140 /** 141 * Retrieves the document entry by transactional document type name. 142 * 143 * @param documentTypeName 144 * @return 145 */ 146 private TransactionalDocumentEntry getTransactionalDocumentEntryBydocumentTypeName(String documentTypeName) { 147 if (documentTypeName == null) { 148 throw new IllegalArgumentException("invalid (null) document type name"); 149 } 150 151 TransactionalDocumentEntry entry = (TransactionalDocumentEntry) getDataDictionary().getDocumentEntry(documentTypeName); 152 153 return entry; 154 } 155 156 /** 157 * This overridden method ... 158 * 159 * @see org.kuali.rice.kns.service.TransactionalDocumentDictionaryService#getDefaultExistenceChecks(java.lang.String) 160 */ 161 public Collection getDefaultExistenceChecks(String docTypeName) { 162 Collection defaultExistenceChecks = null; 163 164 TransactionalDocumentEntry entry = getTransactionalDocumentEntryBydocumentTypeName(docTypeName); 165 if (entry != null) { 166 defaultExistenceChecks = entry.getDefaultExistenceChecks(); 167 } 168 169 return defaultExistenceChecks; 170 } 171 172 /** 173 * This overridden method ... 174 * 175 * @see org.kuali.rice.kns.service.TransactionalDocumentDictionaryService#getDefaultExistenceChecks(org.kuali.rice.krad.document.TransactionalDocument) 176 */ 177 public Collection getDefaultExistenceChecks(TransactionalDocument document) { 178 return getDefaultExistenceChecks(getTransactionalDocumentEntry(document).getDocumentTypeName()); 179 } 180}