001 /** 002 * Copyright 2005-2012 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.rice.kns.datadictionary; 017 018 import org.kuali.rice.kns.document.authorization.DocumentAuthorizer; 019 import org.kuali.rice.kns.document.authorization.DocumentPresentationController; 020 import org.kuali.rice.kns.document.authorization.MaintenanceDocumentAuthorizerBase; 021 import org.kuali.rice.kns.document.authorization.MaintenanceDocumentPresentationControllerBase; 022 import org.kuali.rice.kns.rule.PromptBeforeValidation; 023 import org.kuali.rice.kns.web.derivedvaluesetter.DerivedValuesSetter; 024 import org.kuali.rice.krad.bo.BusinessObject; 025 import org.kuali.rice.krad.datadictionary.exception.DuplicateEntryException; 026 import org.kuali.rice.krad.document.Document; 027 import org.kuali.rice.kns.document.MaintenanceDocumentBase; 028 import org.kuali.rice.kns.maintenance.Maintainable; 029 030 import java.util.ArrayList; 031 import java.util.LinkedHashMap; 032 import java.util.List; 033 import java.util.Map; 034 035 /** 036 * @author Kuali Rice Team (rice.collab@kuali.org) 037 */ 038 @Deprecated 039 public class MaintenanceDocumentEntry extends org.kuali.rice.krad.datadictionary.MaintenanceDocumentEntry implements KNSDocumentEntry { 040 protected List<MaintainableSectionDefinition> maintainableSections = new ArrayList<MaintainableSectionDefinition>(); 041 protected List<String> lockingKeys = new ArrayList<String>(); 042 043 protected Map<String, MaintainableSectionDefinition> maintainableSectionMap = 044 new LinkedHashMap<String, MaintainableSectionDefinition>(); 045 046 protected boolean allowsNewOrCopy = true; 047 protected String additionalSectionsFile; 048 049 //for issue KULRice3072, to enable PK field copy 050 protected boolean preserveLockingKeysOnCopy = false; 051 052 // for issue KULRice3070, to enable deleting a db record using maintenance doc 053 protected boolean allowsRecordDeletion = false; 054 055 protected boolean translateCodes = false; 056 057 protected Class<? extends PromptBeforeValidation> promptBeforeValidationClass; 058 protected Class<? extends DerivedValuesSetter> derivedValuesSetterClass; 059 protected List<String> webScriptFiles = new ArrayList<String>(3); 060 protected List<HeaderNavigation> headerNavigationList = new ArrayList<HeaderNavigation>(); 061 062 protected boolean sessionDocument = false; 063 064 public MaintenanceDocumentEntry() { 065 super(); 066 067 documentAuthorizerClass = MaintenanceDocumentAuthorizerBase.class; 068 documentPresentationControllerClass = MaintenanceDocumentPresentationControllerBase.class; 069 } 070 071 /** 072 * @return Returns the preRulesCheckClass. 073 */ 074 public Class<? extends PromptBeforeValidation> getPromptBeforeValidationClass() { 075 return promptBeforeValidationClass; 076 } 077 078 /** 079 * The promptBeforeValidationClass element is the full class name of the java 080 * class which determines whether the user should be asked any questions prior to running validation. 081 * 082 * @see KualiDocumentActionBase#promptBeforeValidation(org.apache.struts.action.ActionMapping, 083 * org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, 084 * javax.servlet.http.HttpServletResponse, String) 085 */ 086 public void setPromptBeforeValidationClass(Class<? extends PromptBeforeValidation> preRulesCheckClass) { 087 this.promptBeforeValidationClass = preRulesCheckClass; 088 } 089 090 @Override 091 public Class<? extends Document> getStandardDocumentBaseClass() { 092 return MaintenanceDocumentBase.class; 093 } 094 095 /* 096 This attribute is used in many contexts, for example, in maintenance docs, it's used to specify the classname 097 of the BO being maintained. 098 */ 099 public void setBusinessObjectClass(Class<? extends BusinessObject> businessObjectClass) { 100 if (businessObjectClass == null) { 101 throw new IllegalArgumentException("invalid (null) dataObjectClass"); 102 } 103 104 setDataObjectClass(businessObjectClass); 105 } 106 107 public Class<? extends BusinessObject> getBusinessObjectClass() { 108 return (Class<? extends BusinessObject>) getDataObjectClass(); 109 } 110 111 /** 112 * @see org.kuali.rice.krad.datadictionary.DocumentEntry#getEntryClass() 113 */ 114 @SuppressWarnings("unchecked") 115 @Override 116 public Class getEntryClass() { 117 return getDataObjectClass(); 118 } 119 120 public Class<? extends Maintainable> getMaintainableClass() { 121 return (Class<? extends Maintainable>) super.getMaintainableClass(); 122 } 123 124 /** 125 * @return List of MaintainableSectionDefinition objects contained in this document 126 */ 127 public List<MaintainableSectionDefinition> getMaintainableSections() { 128 return maintainableSections; 129 } 130 131 /** 132 * @return List of all lockingKey fieldNames associated with this LookupDefinition, in the order in which they were 133 * added 134 */ 135 public List<String> getLockingKeyFieldNames() { 136 return lockingKeys; 137 } 138 139 /** 140 * Gets the allowsNewOrCopy attribute. 141 * 142 * @return Returns the allowsNewOrCopy. 143 */ 144 public boolean getAllowsNewOrCopy() { 145 return allowsNewOrCopy; 146 } 147 148 /** 149 * The allowsNewOrCopy element contains a value of true or false. 150 * If true, this indicates the maintainable should allow the 151 * new and/or copy maintenance actions. 152 */ 153 public void setAllowsNewOrCopy(boolean allowsNewOrCopy) { 154 this.allowsNewOrCopy = allowsNewOrCopy; 155 } 156 157 /** 158 * Directly validate simple fields, call completeValidation on Definition fields. 159 * 160 * @see org.kuali.rice.krad.datadictionary.DocumentEntry#completeValidation() 161 */ 162 public void completeValidation() { 163 super.completeValidation(); 164 165 for (MaintainableSectionDefinition maintainableSectionDefinition : maintainableSections) { 166 maintainableSectionDefinition.completeValidation(getDataObjectClass(), null); 167 } 168 } 169 170 /** 171 * @see java.lang.Object#toString() 172 */ 173 public String toString() { 174 return "MaintenanceDocumentEntry for documentType " + getDocumentTypeName(); 175 } 176 177 @Deprecated 178 public String getAdditionalSectionsFile() { 179 return additionalSectionsFile; 180 } 181 182 /* 183 The additionalSectionsFile element specifies the name of the location 184 of an additional JSP file to include in the maintenance document 185 after the generation sections but before the notes. 186 The location semantics are those of jsp:include. 187 */ 188 @Deprecated 189 public void setAdditionalSectionsFile(String additionalSectionsFile) { 190 this.additionalSectionsFile = additionalSectionsFile; 191 } 192 193 public List<String> getLockingKeys() { 194 return lockingKeys; 195 } 196 197 /* 198 The lockingKeys element specifies a list of fields 199 that comprise a unique key. This is used for record locking 200 during the file maintenance process. 201 */ 202 public void setLockingKeys(List<String> lockingKeys) { 203 for (String lockingKey : lockingKeys) { 204 if (lockingKey == null) { 205 throw new IllegalArgumentException("invalid (null) lockingKey"); 206 } 207 } 208 this.lockingKeys = lockingKeys; 209 } 210 211 /** 212 * The maintainableSections elements allows the maintenance document to 213 * be presented in sections. Each section can have a different title. 214 * 215 * JSTL: maintainbleSections is a Map whichis accessed by a key 216 * of "maintainableSections". This map contains entries with the 217 * following keys: 218 * "0" (for first section) 219 * "1" (for second section) 220 * etc. 221 * The corresponding value for each entry is a maintainableSection ExportMap. 222 * See MaintenanceDocumentEntryMapper.java. 223 */ 224 @Deprecated 225 public void setMaintainableSections(List<MaintainableSectionDefinition> maintainableSections) { 226 maintainableSectionMap.clear(); 227 for (MaintainableSectionDefinition maintainableSectionDefinition : maintainableSections) { 228 if (maintainableSectionDefinition == null) { 229 throw new IllegalArgumentException("invalid (null) maintainableSectionDefinition"); 230 } 231 232 String sectionTitle = maintainableSectionDefinition.getTitle(); 233 if (maintainableSectionMap.containsKey(sectionTitle)) { 234 throw new DuplicateEntryException( 235 "section '" + sectionTitle + "' already defined for maintenanceDocument '" + 236 getDocumentTypeName() + "'"); 237 } 238 239 maintainableSectionMap.put(sectionTitle, maintainableSectionDefinition); 240 } 241 this.maintainableSections = maintainableSections; 242 } 243 244 /** 245 * @return the preserveLockingKeysOnCopy 246 */ 247 public boolean getPreserveLockingKeysOnCopy() { 248 return this.preserveLockingKeysOnCopy; 249 } 250 251 /** 252 * @param preserveLockingKeysOnCopy the preserveLockingKeysOnCopy to set 253 */ 254 public void setPreserveLockingKeysOnCopy(boolean preserveLockingKeysOnCopy) { 255 this.preserveLockingKeysOnCopy = preserveLockingKeysOnCopy; 256 } 257 258 /** 259 * @return the allowRecordDeletion 260 */ 261 public boolean getAllowsRecordDeletion() { 262 return this.allowsRecordDeletion; 263 } 264 265 /** 266 * @param allowsRecordDeletion the allowRecordDeletion to set 267 */ 268 public void setAllowsRecordDeletion(boolean allowsRecordDeletion) { 269 this.allowsRecordDeletion = allowsRecordDeletion; 270 } 271 272 @Deprecated 273 public boolean isTranslateCodes() { 274 return this.translateCodes; 275 } 276 277 @Deprecated 278 public void setTranslateCodes(boolean translateCodes) { 279 this.translateCodes = translateCodes; 280 } 281 282 /** 283 * Returns the document authorizer class for the document. Only framework code should be calling this method. 284 * Client devs should use {@link DocumentTypeService#getDocumentAuthorizer(org.kuali.rice.krad.document.Document)} 285 * or 286 * {@link DocumentTypeService#getDocumentAuthorizer(String)} 287 * 288 * @return a document authorizer class 289 */ 290 @Override 291 public Class<? extends DocumentAuthorizer> getDocumentAuthorizerClass() { 292 return (Class<? extends DocumentAuthorizer>) super.getDocumentAuthorizerClass(); 293 } 294 295 /** 296 * Returns the document presentation controller class for the document. Only framework code should be calling this 297 * method. 298 * Client devs should use {@link DocumentTypeService#getDocumentPresentationController(org.kuali.rice.krad.document.Document)} 299 * or 300 * {@link DocumentTypeService#getDocumentPresentationController(String)} 301 * 302 * @return the documentPresentationControllerClass 303 */ 304 @Override 305 public Class<? extends DocumentPresentationController> getDocumentPresentationControllerClass() { 306 return (Class<? extends DocumentPresentationController>) super.getDocumentPresentationControllerClass(); 307 } 308 309 public List<HeaderNavigation> getHeaderNavigationList() { 310 return headerNavigationList; 311 } 312 313 public List<String> getWebScriptFiles() { 314 return webScriptFiles; 315 } 316 317 /** 318 * The webScriptFile element defines the name of javascript files 319 * that are necessary for processing the document. The specified 320 * javascript files will be included in the generated html. 321 */ 322 public void setWebScriptFiles(List<String> webScriptFiles) { 323 this.webScriptFiles = webScriptFiles; 324 } 325 326 /** 327 * The headerNavigation element defines a set of additional 328 * tabs which will appear on the document. 329 */ 330 public void setHeaderNavigationList(List<HeaderNavigation> headerNavigationList) { 331 this.headerNavigationList = headerNavigationList; 332 } 333 334 public boolean isSessionDocument() { 335 return this.sessionDocument; 336 } 337 338 public void setSessionDocument(boolean sessionDocument) { 339 this.sessionDocument = sessionDocument; 340 } 341 342 /** 343 * @return the derivedValuesSetter 344 */ 345 public Class<? extends DerivedValuesSetter> getDerivedValuesSetterClass() { 346 return this.derivedValuesSetterClass; 347 } 348 349 /** 350 * @param derivedValuesSetter the derivedValuesSetter to set 351 */ 352 public void setDerivedValuesSetterClass(Class<? extends DerivedValuesSetter> derivedValuesSetter) { 353 this.derivedValuesSetterClass = derivedValuesSetter; 354 } 355 }