| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| MaintenanceView |
|
| 1.375;1.375 |
| 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.krad.uif.container; | |
| 12 | ||
| 13 | import org.apache.commons.lang.StringUtils; | |
| 14 | import org.kuali.rice.krad.datadictionary.MaintenanceDocumentEntry; | |
| 15 | import org.kuali.rice.krad.service.DocumentDictionaryService; | |
| 16 | import org.kuali.rice.krad.service.KRADServiceLocatorWeb; | |
| 17 | import org.kuali.rice.krad.uif.UifConstants; | |
| 18 | import org.kuali.rice.krad.uif.UifConstants.ViewType; | |
| 19 | import org.kuali.rice.krad.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.krad.uif.container.ContainerBase#performInitialization(org.kuali.rice.krad.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 = KRADServiceLocatorWeb.getDocumentDictionaryService() |
| 81 | .getMaintenanceDocumentTypeName(getDataObjectClassName()); | |
| 82 | 0 | if (StringUtils.isNotBlank(docTypeName)) { |
| 83 | 0 | documentEntry = |
| 84 | KRADServiceLocatorWeb.getDocumentDictionaryService().getMaintenanceDocumentEntry(docTypeName); | |
| 85 | } | |
| 86 | ||
| 87 | 0 | if (documentEntry != null) { |
| 88 | 0 | pushObjectToContext(UifConstants.ContextVariableNames.DOCUMENT_ENTRY, documentEntry); |
| 89 | } else { | |
| 90 | 0 | LOG.error("Unable to find maintenance document entry for data object class: " + |
| 91 | getDataObjectClassName().getName()); | |
| 92 | 0 | throw new RuntimeException("Unable to find maintenance document entry for data object class: " + |
| 93 | getDataObjectClassName().getName()); | |
| 94 | } | |
| 95 | ||
| 96 | 0 | getAbstractTypeClasses().put(getDefaultBindingObjectPath(), getDataObjectClassName()); |
| 97 | 0 | getAbstractTypeClasses().put(getOldObjectBindingPath(), getDataObjectClassName()); |
| 98 | 0 | } |
| 99 | ||
| 100 | /** | |
| 101 | * Class name for the object the maintenance document applies to | |
| 102 | * | |
| 103 | * <p> | |
| 104 | * The object class name is used to pick up a dictionary entry which will | |
| 105 | * feed the attribute field definitions and other configuration. In addition | |
| 106 | * it is used to configure the <code>Maintainable</code> which will carry | |
| 107 | * out the maintenance action | |
| 108 | * </p> | |
| 109 | * | |
| 110 | * @return Class<?> maintenance object class | |
| 111 | */ | |
| 112 | public Class<?> getDataObjectClassName() { | |
| 113 | 0 | return this.dataObjectClassName; |
| 114 | } | |
| 115 | ||
| 116 | /** | |
| 117 | * Setter for the object class name | |
| 118 | * | |
| 119 | * @param dataObjectClassName | |
| 120 | */ | |
| 121 | public void setDataObjectClassName(Class<?> dataObjectClassName) { | |
| 122 | 0 | this.dataObjectClassName = dataObjectClassName; |
| 123 | 0 | } |
| 124 | ||
| 125 | /** | |
| 126 | * Gives the binding path to the old object (record being edited) to display | |
| 127 | * for comparison | |
| 128 | * | |
| 129 | * @return String old object binding path | |
| 130 | */ | |
| 131 | public String getOldObjectBindingPath() { | |
| 132 | 0 | return this.oldObjectBindingPath; |
| 133 | } | |
| 134 | ||
| 135 | /** | |
| 136 | * Setter for the old object binding path | |
| 137 | * | |
| 138 | * @param oldObjectBindingPath | |
| 139 | */ | |
| 140 | public void setOldObjectBindingPath(String oldObjectBindingPath) { | |
| 141 | 0 | this.oldObjectBindingPath = oldObjectBindingPath; |
| 142 | 0 | } |
| 143 | ||
| 144 | /** | |
| 145 | * Indicates what maintenance action (new, edit, copy) was | |
| 146 | * requested | |
| 147 | * | |
| 148 | * @return String maintenance action | |
| 149 | */ | |
| 150 | public String getMaintenanceAction() { | |
| 151 | 0 | return maintenanceAction; |
| 152 | } | |
| 153 | ||
| 154 | /** | |
| 155 | * Setter for the maintenance action | |
| 156 | * | |
| 157 | * @param maintenanceAction | |
| 158 | */ | |
| 159 | public void setMaintenanceAction(String maintenanceAction) { | |
| 160 | 0 | this.maintenanceAction = maintenanceAction; |
| 161 | 0 | } |
| 162 | ||
| 163 | } |