Coverage Report - org.kuali.rice.krad.uif.container.InquiryView
 
Classes in this File Line Coverage Branch Coverage Complexity
InquiryView
0%
0/23
0%
0/4
1.667
 
 1  
 /*
 2  
  * Copyright 2007 The Kuali Foundation
 3  
  * 
 4  
  * Licensed under the Educational Community License, Version 1.0 (the
 5  
  * "License"); 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/ecl1.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, WITHOUT
 12  
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 13  
  * License for the specific language governing permissions and limitations under
 14  
  * the License.
 15  
  */
 16  
 package org.kuali.rice.krad.uif.container;
 17  
 
 18  
 import org.kuali.rice.krad.bo.Exporter;
 19  
 import org.kuali.rice.krad.datadictionary.DataObjectEntry;
 20  
 import org.kuali.rice.krad.service.KRADServiceLocatorWeb;
 21  
 import org.kuali.rice.krad.uif.UifConstants.ViewType;
 22  
 import org.kuali.rice.krad.util.KRADConstants;
 23  
 
 24  
 /**
 25  
  * Type of <code>View</code> that provides a read-only display of a record of
 26  
  * data (object instance)
 27  
  * 
 28  
  * <p>
 29  
  * The <code>InquiryView</code> provides the interface for the Inquiry
 30  
  * framework. It works with the <code>Inquirable</code> service and inquiry
 31  
  * controller. The view does render a form to support the configuration of
 32  
  * actions to perform operations on the data.
 33  
  * </p>
 34  
  * 
 35  
  * <p>
 36  
  * Inquiry views are primarily configured by the object class they are
 37  
  * associated with. This provides the default dictionary information for the
 38  
  * fields. If more than one inquiry view is needed for the same object class,
 39  
  * the view name can be used to further identify an unique view
 40  
  * </p>
 41  
  * 
 42  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 43  
  */
 44  
 public class InquiryView extends FormView {
 45  
     private static final long serialVersionUID = 716926008488403616L;
 46  
 
 47  
     private Class<?> dataObjectClassName;
 48  
     private boolean canExport;
 49  
 
 50  
     public InquiryView() {
 51  0
         super();
 52  
 
 53  0
         setViewTypeName(ViewType.INQUIRY);
 54  0
         setValidateDirty(false);
 55  0
         setTranslateCodes(true);
 56  0
     }
 57  
 
 58  
     /**
 59  
      * <p>
 60  
      * The following initialization is performed:
 61  
      * <ul>
 62  
      * <li>Set the abstractTypeClasses map for the inquiry object path</li>
 63  
      * </ul>
 64  
      * </p>
 65  
      * 
 66  
      * @see org.kuali.rice.krad.uif.container.ContainerBase#performInitialization(org.kuali.rice.krad.uif.container.View)
 67  
      */
 68  
     @Override
 69  
     public void performInitialization(View view) {
 70  0
         super.performInitialization(view);
 71  
 
 72  0
         getAbstractTypeClasses().put(getDefaultBindingObjectPath(), getDataObjectClassName());
 73  0
         populateExportCapabilities();
 74  0
     }
 75  
 
 76  
     /**
 77  
      * Class name for the object the inquiry applies to
 78  
      * 
 79  
      * <p>
 80  
      * The object class name is used to pick up a dictionary entry which will
 81  
      * feed the attribute field definitions and other configuration. In addition
 82  
      * it is used to configure the <code>Inquirable</code> which will carry out
 83  
      * the inquiry action
 84  
      * </p>
 85  
      * 
 86  
      * @return Class<?> inquiry object class
 87  
      */
 88  
     public Class<?> getDataObjectClassName() {
 89  0
         return this.dataObjectClassName;
 90  
     }
 91  
 
 92  
     /**
 93  
      * Setter for the object class name
 94  
      * 
 95  
      * @param dataObjectClassName
 96  
      */
 97  
     public void setDataObjectClassName(Class<?> dataObjectClassName) {
 98  0
         this.dataObjectClassName = dataObjectClassName;
 99  0
     }
 100  
 
 101  
     /**
 102  
      * Examines the BusinessObject's data dictionary entry to determine if it
 103  
      * supports XML export or not and set's canExport appropriately.
 104  
      *
 105  
      */
 106  
     protected void populateExportCapabilities() {
 107  0
         DataObjectEntry dataObjectEntry = KRADServiceLocatorWeb.getDataDictionaryService().getDataDictionary().getDataObjectEntry(getDataObjectClassName().getName());
 108  0
         Class<? extends Exporter> exporterClass = dataObjectEntry.getExporterClass();
 109  0
         if (exporterClass != null) {
 110  
             try {
 111  0
                 Exporter exporter = exporterClass.newInstance();
 112  0
                 if (exporter.getSupportedFormats(dataObjectEntry.getDataObjectClass()).contains(KRADConstants.XML_FORMAT)) {
 113  0
                     canExport = true;
 114  
                 }
 115  0
             } catch (Exception e) {
 116  0
                 throw new RuntimeException("Failed to locate or create exporter class: " + exporterClass);
 117  0
             }
 118  
         }
 119  0
     }
 120  
     
 121  
     /**
 122  
          * Returns true if this Inquiry supports XML export of the BusinessObject.
 123  
          */
 124  
     public boolean isCanExport() {
 125  0
         return this.canExport;
 126  
     }
 127  
 
 128  
 }