Coverage Report - org.kuali.rice.krad.datadictionary.exporter.DocumentEntryMapper
 
Classes in this File Line Coverage Branch Coverage Complexity
DocumentEntryMapper
0%
0/29
0%
0/8
5
 
 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.krad.datadictionary.exporter;
 17  
 
 18  
 import org.kuali.rice.kew.dto.DocumentTypeDTO;
 19  
 import org.kuali.rice.kew.exception.WorkflowException;
 20  
 import org.kuali.rice.krad.datadictionary.DocumentEntry;
 21  
 import org.kuali.rice.krad.service.DocumentHelperService;
 22  
 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
 23  
 
 24  
 /**
 25  
  * DocumentEntryMapper
 26  
  * 
 27  
  * 
 28  
  */
 29  0
 public abstract class DocumentEntryMapper {
 30  
     
 31  
     protected DocumentTypeDTO getDocumentType(String documentTypeName) {
 32  
         try {
 33  0
             return KRADServiceLocatorWeb.getWorkflowInfoService().getDocTypeByName(documentTypeName);
 34  0
         } catch (WorkflowException e) {
 35  0
             throw new RuntimeException("Caught Exception trying to get the Workflow Document Type", e);
 36  
         }
 37  
     }
 38  
 
 39  
     /**
 40  
      * @param entry
 41  
      * @return Map containing entries for properties common to all DocumentEntry subclasses
 42  
      */
 43  
     @SuppressWarnings("unchecked")
 44  
         protected ExportMap mapEntry(DocumentEntry entry) {
 45  0
         if (entry == null) {
 46  0
             throw new IllegalArgumentException("invalid (null) entry");
 47  
         }
 48  
 
 49  
         // simple properties
 50  0
         ExportMap entryMap = new ExportMap(entry.getJstlKey());
 51  
 
 52  0
         Class businessRulesClass = entry.getBusinessRulesClass();
 53  0
         if (businessRulesClass != null) {
 54  0
             entryMap.set("businessRulesClass", businessRulesClass.getName());
 55  
         }
 56  
 
 57  0
         entryMap.set("documentTypeName", entry.getDocumentTypeName());
 58  
 
 59  0
         DocumentTypeDTO docType = getDocumentType(entry.getDocumentTypeName());
 60  0
         entryMap.set("label", docType.getDocTypeLabel());
 61  
 
 62  0
         if (docType.getDocTypeDescription() != null) {
 63  0
             entryMap.set("description", docType.getDocTypeDescription());
 64  
         }
 65  
 
 66  0
         DocumentHelperService documentHelperService = KRADServiceLocatorWeb.getDocumentHelperService();
 67  0
         entryMap.set("documentAuthorizerClass", documentHelperService.getDocumentAuthorizer(entry.getDocumentTypeName()).getClass().getName());
 68  0
         entryMap.set("documentPresentationControllerClass", documentHelperService.getDocumentPresentationController(entry.getDocumentTypeName()).getClass().getName());
 69  
 
 70  0
         entryMap.set("allowsNoteAttachments", Boolean.toString(entry.getAllowsNoteAttachments()));
 71  
 
 72  0
         entryMap.set("allowsNoteFYI", Boolean.toString(entry.getAllowsNoteFYI()));
 73  
         
 74  0
         if (entry.getAttachmentTypesValuesFinderClass() != null) {
 75  0
             entryMap.set("attachmentTypesValuesFinderClass", entry.getAttachmentTypesValuesFinderClass().getName());
 76  
         }
 77  
 
 78  0
         entryMap.set("displayTopicFieldInNotes", Boolean.toString(entry.getDisplayTopicFieldInNotes()));
 79  
         
 80  0
         entryMap.set("usePessimisticLocking", Boolean.toString(entry.getUsePessimisticLocking()));
 81  0
         entryMap.set("useWorkflowPessimisticLocking", Boolean.toString(entry.getUseWorkflowPessimisticLocking()));
 82  0
         entryMap.set("sessionDocument", Boolean.toString(entry.isSessionDocument()));
 83  
         
 84  0
         entryMap.set(new AttributesMapBuilder().buildAttributesMap(entry));
 85  0
         entryMap.set(new CollectionsMapBuilder().buildCollectionsMap(entry));
 86  
 
 87  0
         return entryMap;
 88  
     }
 89  
 
 90  
 }