Coverage Report - org.kuali.rice.kns.datadictionary.MaintenanceDocumentEntry
 
Classes in this File Line Coverage Branch Coverage Complexity
MaintenanceDocumentEntry
0%
0/80
0%
0/14
1.297
 
 1  
 /**
 2  
  * Copyright 2005-2011 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.kns.datadictionary;
 17  
 
 18  
 import org.kuali.rice.kns.rule.PromptBeforeValidation;
 19  
 import org.kuali.rice.kns.web.derivedvaluesetter.DerivedValuesSetter;
 20  
 import org.kuali.rice.krad.bo.BusinessObject;
 21  
 import org.kuali.rice.krad.datadictionary.DataDictionary;
 22  
 import org.kuali.rice.krad.datadictionary.ReferenceDefinition;
 23  
 import org.kuali.rice.krad.datadictionary.exception.AttributeValidationException;
 24  
 import org.kuali.rice.krad.datadictionary.exception.ClassValidationException;
 25  
 import org.kuali.rice.krad.datadictionary.exception.DuplicateEntryException;
 26  
 import org.kuali.rice.krad.document.Document;
 27  
 import org.kuali.rice.kns.document.MaintenanceDocumentBase;
 28  
 import org.kuali.rice.krad.document.authorization.DocumentAuthorizer;
 29  
 import org.kuali.rice.krad.document.authorization.DocumentPresentationController;
 30  
 import org.kuali.rice.krad.document.authorization.MaintenanceDocumentAuthorizer;
 31  
 import org.kuali.rice.kns.maintenance.Maintainable;
 32  
 
 33  
 import java.util.ArrayList;
 34  
 import java.util.LinkedHashMap;
 35  
 import java.util.List;
 36  
 import java.util.Map;
 37  
 
 38  
 /**
 39  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 40  
  */
 41  
 @Deprecated
 42  
 public class MaintenanceDocumentEntry extends org.kuali.rice.krad.datadictionary.MaintenanceDocumentEntry implements KNSDocumentEntry {
 43  0
     protected List<MaintainableSectionDefinition> maintainableSections = new ArrayList<MaintainableSectionDefinition>();
 44  0
     protected List<String> lockingKeys = new ArrayList<String>();
 45  
 
 46  0
     protected Map<String, MaintainableSectionDefinition> maintainableSectionMap =
 47  
             new LinkedHashMap<String, MaintainableSectionDefinition>();
 48  
 
 49  0
     protected boolean allowsNewOrCopy = true;
 50  
     protected String additionalSectionsFile;
 51  
 
 52  
     //for issue KULRice3072, to enable PK field copy
 53  0
     protected boolean preserveLockingKeysOnCopy = false;
 54  
 
 55  
     // for issue KULRice3070, to enable deleting a db record using maintenance doc
 56  0
     protected boolean allowsRecordDeletion = false;
 57  
 
 58  0
     protected boolean translateCodes = false;
 59  
 
 60  
     protected Class<? extends PromptBeforeValidation> promptBeforeValidationClass;
 61  
     protected Class<? extends DerivedValuesSetter> derivedValuesSetterClass;
 62  0
     protected List<String> webScriptFiles = new ArrayList<String>(3);
 63  0
     protected List<HeaderNavigation> headerNavigationList = new ArrayList<HeaderNavigation>();
 64  
 
 65  
     protected Class<? extends DocumentAuthorizer> documentAuthorizerClass;
 66  
     protected Class<? extends DocumentPresentationController> documentPresentationControllerClass;
 67  
 
 68  0
     protected boolean sessionDocument = false;
 69  
 
 70  
     public MaintenanceDocumentEntry() {
 71  0
         super();
 72  0
     }
 73  
 
 74  
      /**
 75  
      * @return Returns the preRulesCheckClass.
 76  
      */
 77  
     public Class<? extends PromptBeforeValidation> getPromptBeforeValidationClass() {
 78  0
         return promptBeforeValidationClass;
 79  
     }
 80  
 
 81  
     /**
 82  
      * The promptBeforeValidationClass element is the full class name of the java
 83  
      * class which determines whether the user should be asked any questions prior to running validation.
 84  
      *
 85  
      * @see KualiDocumentActionBase#promptBeforeValidation(org.apache.struts.action.ActionMapping,
 86  
      *      org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest,
 87  
      *      javax.servlet.http.HttpServletResponse, String)
 88  
      */
 89  
     public void setPromptBeforeValidationClass(Class<? extends PromptBeforeValidation> preRulesCheckClass) {
 90  0
         this.promptBeforeValidationClass = preRulesCheckClass;
 91  0
     }
 92  
 
 93  
     @Override
 94  
     public Class<? extends Document> getStandardDocumentBaseClass() {
 95  0
         return MaintenanceDocumentBase.class;
 96  
     }
 97  
 
 98  
     /*
 99  
            This attribute is used in many contexts, for example, in maintenance docs, it's used to specify the classname
 100  
            of the BO being maintained.
 101  
     */
 102  
     public void setBusinessObjectClass(Class<? extends BusinessObject> businessObjectClass) {
 103  0
         if (businessObjectClass == null) {
 104  0
             throw new IllegalArgumentException("invalid (null) dataObjectClass");
 105  
         }
 106  
 
 107  0
         setDataObjectClass(businessObjectClass);
 108  0
     }
 109  
 
 110  
     public Class<? extends BusinessObject> getBusinessObjectClass() {
 111  0
         return (Class<? extends BusinessObject>) getDataObjectClass();
 112  
     }
 113  
 
 114  
     /**
 115  
      * @see org.kuali.rice.krad.datadictionary.DocumentEntry#getEntryClass()
 116  
      */
 117  
     @SuppressWarnings("unchecked")
 118  
     @Override
 119  
     public Class getEntryClass() {
 120  0
         return getDataObjectClass();
 121  
     }
 122  
 
 123  
     public Class<? extends Maintainable> getMaintainableClass() {
 124  0
         return (Class<? extends Maintainable>) super.getMaintainableClass();
 125  
     }
 126  
 
 127  
     /**
 128  
      * @return List of MaintainableSectionDefinition objects contained in this document
 129  
      */
 130  
     public List<MaintainableSectionDefinition> getMaintainableSections() {
 131  0
         return maintainableSections;
 132  
     }
 133  
 
 134  
     /**
 135  
      * @return List of all lockingKey fieldNames associated with this LookupDefinition, in the order in which they were
 136  
      *         added
 137  
      */
 138  
     public List<String> getLockingKeyFieldNames() {
 139  0
         return lockingKeys;
 140  
     }
 141  
 
 142  
     /**
 143  
      * Gets the allowsNewOrCopy attribute.
 144  
      *
 145  
      * @return Returns the allowsNewOrCopy.
 146  
      */
 147  
     public boolean getAllowsNewOrCopy() {
 148  0
         return allowsNewOrCopy;
 149  
     }
 150  
 
 151  
     /**
 152  
      * The allowsNewOrCopy element contains a value of true or false.
 153  
      * If true, this indicates the maintainable should allow the
 154  
      * new and/or copy maintenance actions.
 155  
      */
 156  
     public void setAllowsNewOrCopy(boolean allowsNewOrCopy) {
 157  0
         this.allowsNewOrCopy = allowsNewOrCopy;
 158  0
     }
 159  
 
 160  
     /**
 161  
      * Directly validate simple fields, call completeValidation on Definition fields.
 162  
      *
 163  
      * @see org.kuali.rice.krad.datadictionary.DocumentEntry#completeValidation()
 164  
      */
 165  
     public void completeValidation() {
 166  0
         super.completeValidation();
 167  
 
 168  0
         for (MaintainableSectionDefinition maintainableSectionDefinition : maintainableSections) {
 169  0
             maintainableSectionDefinition.completeValidation(getDataObjectClass(), null);
 170  
         }
 171  0
     }
 172  
 
 173  
     /**
 174  
      * @see java.lang.Object#toString()
 175  
      */
 176  
     public String toString() {
 177  0
         return "MaintenanceDocumentEntry for documentType " + getDocumentTypeName();
 178  
     }
 179  
 
 180  
     @Deprecated
 181  
     public String getAdditionalSectionsFile() {
 182  0
         return additionalSectionsFile;
 183  
     }
 184  
 
 185  
     /*
 186  
            The additionalSectionsFile element specifies the name of the location
 187  
            of an additional JSP file to include in the maintenance document
 188  
            after the generation sections but before the notes.
 189  
            The location semantics are those of jsp:include.
 190  
     */
 191  
     @Deprecated
 192  
     public void setAdditionalSectionsFile(String additionalSectionsFile) {
 193  0
         this.additionalSectionsFile = additionalSectionsFile;
 194  0
     }
 195  
 
 196  
     public List<String> getLockingKeys() {
 197  0
         return lockingKeys;
 198  
     }
 199  
 
 200  
     /*
 201  
            The lockingKeys element specifies a list of fields
 202  
            that comprise a unique key.  This is used for record locking
 203  
            during the file maintenance process.
 204  
     */
 205  
     public void setLockingKeys(List<String> lockingKeys) {
 206  0
         for (String lockingKey : lockingKeys) {
 207  0
             if (lockingKey == null) {
 208  0
                 throw new IllegalArgumentException("invalid (null) lockingKey");
 209  
             }
 210  
         }
 211  0
         this.lockingKeys = lockingKeys;
 212  0
     }
 213  
 
 214  
     /**
 215  
      * The maintainableSections elements allows the maintenance document to
 216  
      * be presented in sections.  Each section can have a different title.
 217  
      *
 218  
      * JSTL: maintainbleSections is a Map whichis accessed by a key
 219  
      * of "maintainableSections".  This map contains entries with the
 220  
      * following keys:
 221  
      * "0"   (for first section)
 222  
      * "1"   (for second section)
 223  
      * etc.
 224  
      * The corresponding value for each entry is a maintainableSection ExportMap.
 225  
      * See MaintenanceDocumentEntryMapper.java.
 226  
      */
 227  
     @Deprecated
 228  
     public void setMaintainableSections(List<MaintainableSectionDefinition> maintainableSections) {
 229  0
         maintainableSectionMap.clear();
 230  0
         for (MaintainableSectionDefinition maintainableSectionDefinition : maintainableSections) {
 231  0
             if (maintainableSectionDefinition == null) {
 232  0
                 throw new IllegalArgumentException("invalid (null) maintainableSectionDefinition");
 233  
             }
 234  
 
 235  0
             String sectionTitle = maintainableSectionDefinition.getTitle();
 236  0
             if (maintainableSectionMap.containsKey(sectionTitle)) {
 237  0
                 throw new DuplicateEntryException(
 238  
                         "section '" + sectionTitle + "' already defined for maintenanceDocument '" +
 239  
                                 getDocumentTypeName() + "'");
 240  
             }
 241  
 
 242  0
             maintainableSectionMap.put(sectionTitle, maintainableSectionDefinition);
 243  0
         }
 244  0
         this.maintainableSections = maintainableSections;
 245  0
     }
 246  
 
 247  
     /**
 248  
      * @return the preserveLockingKeysOnCopy
 249  
      */
 250  
     public boolean getPreserveLockingKeysOnCopy() {
 251  0
         return this.preserveLockingKeysOnCopy;
 252  
     }
 253  
 
 254  
     /**
 255  
      * @param preserveLockingKeysOnCopy the preserveLockingKeysOnCopy to set
 256  
      */
 257  
     public void setPreserveLockingKeysOnCopy(boolean preserveLockingKeysOnCopy) {
 258  0
         this.preserveLockingKeysOnCopy = preserveLockingKeysOnCopy;
 259  0
     }
 260  
 
 261  
     /**
 262  
      * @return the allowRecordDeletion
 263  
      */
 264  
     public boolean getAllowsRecordDeletion() {
 265  0
         return this.allowsRecordDeletion;
 266  
     }
 267  
 
 268  
     /**
 269  
      * @param allowsRecordDeletion the allowRecordDeletion to set
 270  
      */
 271  
     public void setAllowsRecordDeletion(boolean allowsRecordDeletion) {
 272  0
         this.allowsRecordDeletion = allowsRecordDeletion;
 273  0
     }
 274  
 
 275  
     @Deprecated
 276  
     public boolean isTranslateCodes() {
 277  0
         return this.translateCodes;
 278  
     }
 279  
 
 280  
     @Deprecated
 281  
     public void setTranslateCodes(boolean translateCodes) {
 282  0
         this.translateCodes = translateCodes;
 283  0
     }
 284  
 
 285  
       /**
 286  
      * The documentAuthorizerClass element is the full class name of the
 287  
      * java class which will determine what features are available to the
 288  
      * user based on the user role and document state.
 289  
      */
 290  
     public void setDocumentAuthorizerClass(Class<? extends DocumentAuthorizer> documentAuthorizerClass) {
 291  0
         this.documentAuthorizerClass = documentAuthorizerClass;
 292  0
     }
 293  
 
 294  
     /**
 295  
      * Returns the document authorizer class for the document.  Only framework code should be calling this method.
 296  
      * Client devs should use {@link DocumentTypeService#getDocumentAuthorizer(org.kuali.rice.krad.document.Document)}
 297  
      * or
 298  
      * {@link DocumentTypeService#getDocumentAuthorizer(String)}
 299  
      *
 300  
      * @return a document authorizer class
 301  
      */
 302  
     public Class<? extends DocumentAuthorizer> getDocumentAuthorizerClass() {
 303  0
         return documentAuthorizerClass;
 304  
     }
 305  
 
 306  
     public List<HeaderNavigation> getHeaderNavigationList() {
 307  0
         return headerNavigationList;
 308  
     }
 309  
 
 310  
     public List<String> getWebScriptFiles() {
 311  0
         return webScriptFiles;
 312  
     }
 313  
 
 314  
     /**
 315  
      * The webScriptFile element defines the name of javascript files
 316  
      * that are necessary for processing the document.  The specified
 317  
      * javascript files will be included in the generated html.
 318  
      */
 319  
     public void setWebScriptFiles(List<String> webScriptFiles) {
 320  0
         this.webScriptFiles = webScriptFiles;
 321  0
     }
 322  
 
 323  
     /**
 324  
      * The headerNavigation element defines a set of additional
 325  
      * tabs which will appear on the document.
 326  
      */
 327  
     public void setHeaderNavigationList(List<HeaderNavigation> headerNavigationList) {
 328  0
         this.headerNavigationList = headerNavigationList;
 329  0
     }
 330  
 
 331  
     public boolean isSessionDocument() {
 332  0
         return this.sessionDocument;
 333  
     }
 334  
 
 335  
     public void setSessionDocument(boolean sessionDocument) {
 336  0
         this.sessionDocument = sessionDocument;
 337  0
     }
 338  
 
 339  
     /**
 340  
      * Returns the document presentation controller class for the document.  Only framework code should be calling this
 341  
      * method.
 342  
      * Client devs should use {@link DocumentTypeService#getDocumentPresentationController(org.kuali.rice.krad.document.Document)}
 343  
      * or
 344  
      * {@link DocumentTypeService#getDocumentPresentationController(String)}
 345  
      *
 346  
      * @return the documentPresentationControllerClass
 347  
      */
 348  
     public Class<? extends DocumentPresentationController> getDocumentPresentationControllerClass() {
 349  0
         return this.documentPresentationControllerClass;
 350  
     }
 351  
 
 352  
     /**
 353  
      * @param documentPresentationControllerClass the documentPresentationControllerClass to set
 354  
      */
 355  
     public void setDocumentPresentationControllerClass(
 356  
             Class<? extends DocumentPresentationController> documentPresentationControllerClass) {
 357  0
         this.documentPresentationControllerClass = documentPresentationControllerClass;
 358  0
     }
 359  
 
 360  
     /**
 361  
      * @return the derivedValuesSetter
 362  
      */
 363  
     public Class<? extends DerivedValuesSetter> getDerivedValuesSetterClass() {
 364  0
         return this.derivedValuesSetterClass;
 365  
     }
 366  
 
 367  
     /**
 368  
      * @param derivedValuesSetter the derivedValuesSetter to set
 369  
      */
 370  
     public void setDerivedValuesSetterClass(Class<? extends DerivedValuesSetter> derivedValuesSetter) {
 371  0
         this.derivedValuesSetterClass = derivedValuesSetter;
 372  0
     }
 373  
 }