001/** 002 * Copyright 2005-2015 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.datadictionary.exporter; 017 018import org.kuali.rice.kew.api.KewApiServiceLocator; 019import org.kuali.rice.kew.api.doctype.DocumentType; 020import org.kuali.rice.kns.datadictionary.KNSDocumentEntry; 021import org.kuali.rice.kns.service.DocumentHelperService; 022import org.kuali.rice.kns.service.KNSServiceLocator; 023import org.kuali.rice.krad.datadictionary.DataDictionaryEntryBase; 024import org.kuali.rice.krad.datadictionary.exporter.ExportMap; 025 026/** 027 * DocumentEntryMapper 028 * 029 * 030 */ 031@Deprecated 032public abstract class DocumentEntryMapper { 033 034 protected DocumentType getDocumentType(String documentTypeName) { 035 return KewApiServiceLocator.getDocumentTypeService().getDocumentTypeByName(documentTypeName); 036 } 037 038 /** 039 * @param entry 040 * @return Map containing entries for properties common to all DocumentEntry subclasses 041 */ 042 @SuppressWarnings("unchecked") 043 protected ExportMap mapEntry(KNSDocumentEntry entry) { 044 if (entry == null) { 045 throw new IllegalArgumentException("invalid (null) entry"); 046 } 047 048 // simple properties 049 ExportMap entryMap = new ExportMap(entry.getJstlKey()); 050 051 Class businessRulesClass = entry.getBusinessRulesClass(); 052 if (businessRulesClass != null) { 053 entryMap.set("businessRulesClass", businessRulesClass.getName()); 054 } 055 056 entryMap.set("documentTypeName", entry.getDocumentTypeName()); 057 058 DocumentType docType = getDocumentType(entry.getDocumentTypeName()); 059 entryMap.set("label", docType.getLabel()); 060 061 if (docType.getDescription() != null) { 062 entryMap.set("description", docType.getDescription()); 063 } 064 065 DocumentHelperService documentHelperService = KNSServiceLocator.getDocumentHelperService(); 066 entryMap.set("documentAuthorizerClass", documentHelperService.getDocumentAuthorizer(entry.getDocumentTypeName()).getClass().getName()); 067 entryMap.set("documentPresentationControllerClass", documentHelperService.getDocumentPresentationController(entry.getDocumentTypeName()).getClass().getName()); 068 069 entryMap.set("allowsNoteAttachments", Boolean.toString(entry.getAllowsNoteAttachments())); 070 071 entryMap.set("allowsNoteFYI", Boolean.toString(entry.getAllowsNoteFYI())); 072 073 if (entry.getAttachmentTypesValuesFinderClass() != null) { 074 entryMap.set("attachmentTypesValuesFinderClass", entry.getAttachmentTypesValuesFinderClass().getName()); 075 } 076 077 entryMap.set("displayTopicFieldInNotes", Boolean.toString(entry.getDisplayTopicFieldInNotes())); 078 079 entryMap.set("usePessimisticLocking", Boolean.toString(entry.getUsePessimisticLocking())); 080 entryMap.set("useWorkflowPessimisticLocking", Boolean.toString(entry.getUseWorkflowPessimisticLocking())); 081 entryMap.set("sessionDocument", Boolean.toString(entry.isSessionDocument())); 082 083 entryMap.set(new AttributesMapBuilder().buildAttributesMap((DataDictionaryEntryBase) entry)); 084 entryMap.set(new CollectionsMapBuilder().buildCollectionsMap((DataDictionaryEntryBase) entry)); 085 086 return entryMap; 087 } 088 089}