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 034public class TransactionalDocumentDictionaryServiceImpl implements TransactionalDocumentDictionaryService { 035 private DataDictionaryService dataDictionaryService; 036 037 /** 038 * @see org.kuali.rice.kns.service.TransactionalDocumentDictionaryService#getAllowsCopy(org.kuali.bo.TransactionalDocument) 039 */ 040 public Boolean getAllowsCopy(TransactionalDocument document) { 041 Boolean allowsCopy = null; 042 043 TransactionalDocumentEntry entry = getTransactionalDocumentEntry(document); 044 if (entry != null) { 045 allowsCopy = Boolean.valueOf(entry.getAllowsCopy()); 046 } 047 048 return allowsCopy; 049 } 050 051 /** 052 * @see org.kuali.rice.kns.service.TransactionalDocumentDictionaryService#getDocumentClassByName(java.lang.String) 053 */ 054 public Class getDocumentClassByName(String documentTypeName) { 055 Class documentClass = null; 056 057 TransactionalDocumentEntry entry = getTransactionalDocumentEntryBydocumentTypeName(documentTypeName); 058 if (entry != null) { 059 documentClass = entry.getDocumentClass(); 060 } 061 062 return documentClass; 063 } 064 065 /** 066 * @see org.kuali.rice.kns.service.TransactionalDocumentDictionaryService#getDescription(org.kuali.bo.TransactionalDocument) 067 */ 068 public String getDescription(String transactionalDocumentTypeName) { 069 String description = null; 070 071 DocumentType docType = getDocumentType(transactionalDocumentTypeName); 072 if (docType != null) { 073 description = docType.getDescription(); 074 } 075 076 return description; 077 } 078 079 /** 080 * @see org.kuali.rice.kns.service.TransactionalDocumentDictionaryService#getDescription(org.kuali.bo.TransactionalDocument) 081 */ 082 public String getLabel(String transactionalDocumentTypeName) { 083 String label = null; 084 085 DocumentType docType = getDocumentType(transactionalDocumentTypeName); 086 if (docType != null) { 087 label = docType.getLabel(); 088 } 089 090 return label; 091 } 092 093 094 /** 095 * Sets the data dictionary instance. 096 * 097 * @param dataDictionaryService 098 */ 099 public void setDataDictionaryService(DataDictionaryService dataDictionaryService) { 100 this.dataDictionaryService = dataDictionaryService; 101 } 102 103 /** 104 * Retrieves the data dictionary instance. 105 * 106 * @return 107 */ 108 public DataDictionary getDataDictionary() { 109 return this.dataDictionaryService.getDataDictionary(); 110 } 111 112 /** 113 * This method gets the workflow document type for the given documentTypeName 114 * 115 * @param documentTypeName 116 * @return 117 */ 118 protected DocumentType getDocumentType(String documentTypeName) { 119 return KewApiServiceLocator.getDocumentTypeService().getDocumentTypeByName(documentTypeName); 120 } 121 122 /** 123 * Retrieves the document entry by transactional document class instance. 124 * 125 * @param document 126 * @return TransactionalDocumentEntry 127 */ 128 private TransactionalDocumentEntry getTransactionalDocumentEntry(TransactionalDocument document) { 129 if (document == null) { 130 throw new IllegalArgumentException("invalid (null) document"); 131 } 132 133 TransactionalDocumentEntry entry = (TransactionalDocumentEntry)getDataDictionary().getDocumentEntry(document.getClass().getName()); 134 135 return entry; 136 } 137 138 /** 139 * Retrieves the document entry by transactional document type name. 140 * 141 * @param documentTypeName 142 * @return 143 */ 144 private TransactionalDocumentEntry getTransactionalDocumentEntryBydocumentTypeName(String documentTypeName) { 145 if (documentTypeName == null) { 146 throw new IllegalArgumentException("invalid (null) document type name"); 147 } 148 149 TransactionalDocumentEntry entry = (TransactionalDocumentEntry) getDataDictionary().getDocumentEntry(documentTypeName); 150 151 return entry; 152 } 153 154 /** 155 * This overridden method ... 156 * 157 * @see org.kuali.rice.kns.service.TransactionalDocumentDictionaryService#getDefaultExistenceChecks(java.lang.String) 158 */ 159 public Collection getDefaultExistenceChecks(String docTypeName) { 160 Collection defaultExistenceChecks = null; 161 162 TransactionalDocumentEntry entry = getTransactionalDocumentEntryBydocumentTypeName(docTypeName); 163 if (entry != null) { 164 defaultExistenceChecks = entry.getDefaultExistenceChecks(); 165 } 166 167 return defaultExistenceChecks; 168 } 169 170 /** 171 * This overridden method ... 172 * 173 * @see org.kuali.rice.kns.service.TransactionalDocumentDictionaryService#getDefaultExistenceChecks(org.kuali.rice.krad.document.TransactionalDocument) 174 */ 175 public Collection getDefaultExistenceChecks(TransactionalDocument document) { 176 return getDefaultExistenceChecks(getTransactionalDocumentEntry(document).getDocumentTypeName()); 177 } 178}