View Javadoc

1   /**
2    * Copyright 2005-2013 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.datadictionary.exporter;
17  
18  import org.kuali.rice.kew.api.KewApiServiceLocator;
19  import org.kuali.rice.kew.api.doctype.DocumentType;
20  import org.kuali.rice.kns.datadictionary.KNSDocumentEntry;
21  import org.kuali.rice.kns.service.DocumentHelperService;
22  import org.kuali.rice.kns.service.KNSServiceLocator;
23  import org.kuali.rice.krad.datadictionary.DataDictionaryEntryBase;
24  import org.kuali.rice.krad.datadictionary.exporter.ExportMap;
25  
26  /**
27   * DocumentEntryMapper
28   * 
29   * 
30   */
31  @Deprecated
32  public abstract class DocumentEntryMapper {
33      
34      protected DocumentType getDocumentType(String documentTypeName) {
35          return KewApiServiceLocator.getDocumentTypeService().getDocumentTypeByName(documentTypeName);
36      }
37  
38      /**
39       * @param entry
40       * @return Map containing entries for properties common to all DocumentEntry subclasses
41       */
42      @SuppressWarnings("unchecked")
43  	protected ExportMap mapEntry(KNSDocumentEntry entry) {
44          if (entry == null) {
45              throw new IllegalArgumentException("invalid (null) entry");
46          }
47  
48          // simple properties
49          ExportMap entryMap = new ExportMap(entry.getJstlKey());
50  
51          Class businessRulesClass = entry.getBusinessRulesClass();
52          if (businessRulesClass != null) {
53              entryMap.set("businessRulesClass", businessRulesClass.getName());
54          }
55  
56          entryMap.set("documentTypeName", entry.getDocumentTypeName());
57  
58          DocumentType docType = getDocumentType(entry.getDocumentTypeName());
59          entryMap.set("label", docType.getLabel());
60  
61          if (docType.getDescription() != null) {
62              entryMap.set("description", docType.getDescription());
63          }
64  
65          DocumentHelperService documentHelperService = KNSServiceLocator.getDocumentHelperService();
66          entryMap.set("documentAuthorizerClass", documentHelperService.getDocumentAuthorizer(entry.getDocumentTypeName()).getClass().getName());
67          entryMap.set("documentPresentationControllerClass", documentHelperService.getDocumentPresentationController(entry.getDocumentTypeName()).getClass().getName());
68  
69          entryMap.set("allowsNoteAttachments", Boolean.toString(entry.getAllowsNoteAttachments()));
70  
71          entryMap.set("allowsNoteFYI", Boolean.toString(entry.getAllowsNoteFYI()));
72          
73          if (entry.getAttachmentTypesValuesFinderClass() != null) {
74              entryMap.set("attachmentTypesValuesFinderClass", entry.getAttachmentTypesValuesFinderClass().getName());
75          }
76  
77          entryMap.set("displayTopicFieldInNotes", Boolean.toString(entry.getDisplayTopicFieldInNotes()));
78          
79          entryMap.set("usePessimisticLocking", Boolean.toString(entry.getUsePessimisticLocking()));
80          entryMap.set("useWorkflowPessimisticLocking", Boolean.toString(entry.getUseWorkflowPessimisticLocking()));
81          entryMap.set("sessionDocument", Boolean.toString(entry.isSessionDocument()));
82          
83          entryMap.set(new AttributesMapBuilder().buildAttributesMap((DataDictionaryEntryBase) entry));
84          entryMap.set(new CollectionsMapBuilder().buildCollectionsMap((DataDictionaryEntryBase) entry));
85  
86          return entryMap;
87      }
88  
89  }