View Javadoc

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