Coverage Report - org.kuali.rice.kns.uif.container.MaintenanceView
 
Classes in this File Line Coverage Branch Coverage Complexity
MaintenanceView
0%
0/26
0%
0/4
1.333
 
 1  
 /*
 2  
  * Copyright 2011 The Kuali Foundation Licensed under the Educational Community
 3  
  * License, Version 1.0 (the "License"); you may not use this file except in
 4  
  * compliance with the License. You may obtain a copy of the License at
 5  
  * http://www.opensource.org/licenses/ecl1.php Unless required by applicable law
 6  
  * or agreed to in writing, software distributed under the License is
 7  
  * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 8  
  * KIND, either express or implied. See the License for the specific language
 9  
  * governing permissions and limitations under the License.
 10  
  */
 11  
 package org.kuali.rice.kns.uif.container;
 12  
 
 13  
 import org.apache.commons.lang.StringUtils;
 14  
 import org.kuali.rice.kns.datadictionary.MaintenanceDocumentEntry;
 15  
 import org.kuali.rice.kns.service.KNSServiceLocatorWeb;
 16  
 import org.kuali.rice.kns.service.MaintenanceDocumentDictionaryService;
 17  
 import org.kuali.rice.kns.uif.UifConstants;
 18  
 import org.kuali.rice.kns.uif.UifConstants.ViewType;
 19  
 import org.kuali.rice.kns.uif.core.RequestParameter;
 20  
 
 21  
 /**
 22  
  * View type for Maintenance documents
 23  
  * 
 24  
  * <p>
 25  
  * Supports primary display for a new maintenance record, in which case the
 26  
  * fields are display for populating the new record, and an edit maintenance
 27  
  * record, which is a comparison view with the old record read-only on the left
 28  
  * side and the new record (changed record) on the right side
 29  
  * </p>
 30  
  * 
 31  
  * <p>
 32  
  * The <code>MaintenanceView</code> provides the interface for the maintenance
 33  
  * framework. It works with the <code>Maintainable</code> service and
 34  
  * maintenance controller.
 35  
  * </p>
 36  
  * 
 37  
  * <p>
 38  
  * Maintenance views are primarily configured by the object class they are
 39  
  * associated with. This provides the default dictionary information for the
 40  
  * fields. If more than one maintenance view is needed for the same object
 41  
  * class, the view name can be used to further identify an unique view
 42  
  * </p>
 43  
  * 
 44  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 45  
  */
 46  
 public class MaintenanceView extends DocumentView {
 47  
     private static final long serialVersionUID = -3382802967703882341L;
 48  
 
 49  0
     private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(MaintenanceView.class);
 50  
 
 51  
     private Class<?> dataObjectClassName;
 52  
 
 53  
     private String oldObjectBindingPath;
 54  
 
 55  
     @RequestParameter
 56  
     private String maintenanceAction;
 57  
 
 58  
     public MaintenanceView() {
 59  0
         super();
 60  
 
 61  0
         setViewTypeName(ViewType.MAINTENANCE);
 62  0
     }
 63  
 
 64  
     /**
 65  
      * The following initialization is performed:
 66  
      * 
 67  
      * <ul>
 68  
      * <li>Retrieve the maintenance document entry for defaults and context</li>
 69  
      * <li>Set the abstractTypeClasses map for the maintenance object path</li>
 70  
      * </ul>
 71  
      * 
 72  
      * @see org.kuali.rice.kns.uif.container.ContainerBase#performInitialization(org.kuali.rice.kns.uif.container.View)
 73  
      */
 74  
     @Override
 75  
     public void performInitialization(View view) {
 76  0
         super.performInitialization(view);
 77  
 
 78  
         // get maintenance document entry
 79  0
         MaintenanceDocumentEntry documentEntry = null;
 80  0
         String docTypeName = getMaintenanceDocumentDictionaryService().getDocumentTypeName(getDataObjectClassName());
 81  0
         if (StringUtils.isNotBlank(docTypeName)) {
 82  0
             documentEntry = getMaintenanceDocumentDictionaryService().getMaintenanceDocumentEntry(docTypeName);
 83  
         }
 84  
 
 85  0
         if (documentEntry != null) {
 86  0
             pushObjectToContext(UifConstants.ContextVariableNames.DOCUMENT_ENTRY, documentEntry);
 87  
         } else {
 88  0
             LOG.error("Unable to find maintenance document entry for data object class: "
 89  
                     + getDataObjectClassName().getName());
 90  0
             throw new RuntimeException("Unable to find maintenance document entry for data object class: "
 91  
                     + getDataObjectClassName().getName());
 92  
         }
 93  
 
 94  0
         getAbstractTypeClasses().put(getDefaultBindingObjectPath(), getDataObjectClassName());
 95  0
         getAbstractTypeClasses().put(getOldObjectBindingPath(), getDataObjectClassName());
 96  0
     }
 97  
 
 98  
     /**
 99  
      * Class name for the object the maintenance document applies to
 100  
      * 
 101  
      * <p>
 102  
      * The object class name is used to pick up a dictionary entry which will
 103  
      * feed the attribute field definitions and other configuration. In addition
 104  
      * it is used to configure the <code>Maintainable</code> which will carry
 105  
      * out the maintenance action
 106  
      * </p>
 107  
      * 
 108  
      * @return Class<?> maintenance object class
 109  
      */
 110  
     public Class<?> getDataObjectClassName() {
 111  0
         return this.dataObjectClassName;
 112  
     }
 113  
 
 114  
     /**
 115  
      * Setter for the object class name
 116  
      * 
 117  
      * @param dataObjectClassName
 118  
      */
 119  
     public void setDataObjectClassName(Class<?> dataObjectClassName) {
 120  0
         this.dataObjectClassName = dataObjectClassName;
 121  0
     }
 122  
 
 123  
     /**
 124  
      * Gives the binding path to the old object (record being edited) to display
 125  
      * for comparison
 126  
      * 
 127  
      * @return String old object binding path
 128  
      */
 129  
     public String getOldObjectBindingPath() {
 130  0
         return this.oldObjectBindingPath;
 131  
     }
 132  
 
 133  
     /**
 134  
      * Setter for the old object binding path
 135  
      * 
 136  
      * @param oldObjectBindingPath
 137  
      */
 138  
     public void setOldObjectBindingPath(String oldObjectBindingPath) {
 139  0
         this.oldObjectBindingPath = oldObjectBindingPath;
 140  0
     }
 141  
 
 142  
     /**
 143  
      * Indicates what maintenance action (new, edit, copy) was
 144  
      * requested
 145  
      *
 146  
      * @return String maintenance action
 147  
      */
 148  
     public String getMaintenanceAction() {
 149  0
         return maintenanceAction;
 150  
     }
 151  
 
 152  
     /**
 153  
      * Setter for the maintenance action
 154  
      *
 155  
      * @param maintenanceAction
 156  
      */
 157  
     public void setMaintenanceAction(String maintenanceAction) {
 158  0
         this.maintenanceAction = maintenanceAction;
 159  0
     }
 160  
 
 161  
     protected MaintenanceDocumentDictionaryService getMaintenanceDocumentDictionaryService() {
 162  0
         return KNSServiceLocatorWeb.getMaintenanceDocumentDictionaryService();
 163  
     }
 164  
 
 165  
 }