View Javadoc

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      protected List<MaintainableSectionDefinition> maintainableSections = new ArrayList<MaintainableSectionDefinition>();
44      protected List<String> lockingKeys = new ArrayList<String>();
45  
46      protected Map<String, MaintainableSectionDefinition> maintainableSectionMap =
47              new LinkedHashMap<String, MaintainableSectionDefinition>();
48  
49      protected boolean allowsNewOrCopy = true;
50      protected String additionalSectionsFile;
51  
52      //for issue KULRice3072, to enable PK field copy
53      protected boolean preserveLockingKeysOnCopy = false;
54  
55      // for issue KULRice3070, to enable deleting a db record using maintenance doc
56      protected boolean allowsRecordDeletion = false;
57  
58      protected boolean translateCodes = false;
59  
60      protected Class<? extends PromptBeforeValidation> promptBeforeValidationClass;
61      protected Class<? extends DerivedValuesSetter> derivedValuesSetterClass;
62      protected List<String> webScriptFiles = new ArrayList<String>(3);
63      protected List<HeaderNavigation> headerNavigationList = new ArrayList<HeaderNavigation>();
64  
65      protected Class<? extends DocumentAuthorizer> documentAuthorizerClass;
66      protected Class<? extends DocumentPresentationController> documentPresentationControllerClass;
67  
68      protected boolean sessionDocument = false;
69  
70      public MaintenanceDocumentEntry() {
71          super();
72      }
73  
74       /**
75       * @return Returns the preRulesCheckClass.
76       */
77      public Class<? extends PromptBeforeValidation> getPromptBeforeValidationClass() {
78          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          this.promptBeforeValidationClass = preRulesCheckClass;
91      }
92  
93      @Override
94      public Class<? extends Document> getStandardDocumentBaseClass() {
95          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         if (businessObjectClass == null) {
104             throw new IllegalArgumentException("invalid (null) dataObjectClass");
105         }
106 
107         setDataObjectClass(businessObjectClass);
108     }
109 
110     public Class<? extends BusinessObject> getBusinessObjectClass() {
111         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         return getDataObjectClass();
121     }
122 
123     public Class<? extends Maintainable> getMaintainableClass() {
124         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         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         return lockingKeys;
140     }
141 
142     /**
143      * Gets the allowsNewOrCopy attribute.
144      *
145      * @return Returns the allowsNewOrCopy.
146      */
147     public boolean getAllowsNewOrCopy() {
148         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         this.allowsNewOrCopy = allowsNewOrCopy;
158     }
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         super.completeValidation();
167 
168         for (MaintainableSectionDefinition maintainableSectionDefinition : maintainableSections) {
169             maintainableSectionDefinition.completeValidation(getDataObjectClass(), null);
170         }
171     }
172 
173     /**
174      * @see java.lang.Object#toString()
175      */
176     public String toString() {
177         return "MaintenanceDocumentEntry for documentType " + getDocumentTypeName();
178     }
179 
180     @Deprecated
181     public String getAdditionalSectionsFile() {
182         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         this.additionalSectionsFile = additionalSectionsFile;
194     }
195 
196     public List<String> getLockingKeys() {
197         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         for (String lockingKey : lockingKeys) {
207             if (lockingKey == null) {
208                 throw new IllegalArgumentException("invalid (null) lockingKey");
209             }
210         }
211         this.lockingKeys = lockingKeys;
212     }
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         maintainableSectionMap.clear();
230         for (MaintainableSectionDefinition maintainableSectionDefinition : maintainableSections) {
231             if (maintainableSectionDefinition == null) {
232                 throw new IllegalArgumentException("invalid (null) maintainableSectionDefinition");
233             }
234 
235             String sectionTitle = maintainableSectionDefinition.getTitle();
236             if (maintainableSectionMap.containsKey(sectionTitle)) {
237                 throw new DuplicateEntryException(
238                         "section '" + sectionTitle + "' already defined for maintenanceDocument '" +
239                                 getDocumentTypeName() + "'");
240             }
241 
242             maintainableSectionMap.put(sectionTitle, maintainableSectionDefinition);
243         }
244         this.maintainableSections = maintainableSections;
245     }
246 
247     /**
248      * @return the preserveLockingKeysOnCopy
249      */
250     public boolean getPreserveLockingKeysOnCopy() {
251         return this.preserveLockingKeysOnCopy;
252     }
253 
254     /**
255      * @param preserveLockingKeysOnCopy the preserveLockingKeysOnCopy to set
256      */
257     public void setPreserveLockingKeysOnCopy(boolean preserveLockingKeysOnCopy) {
258         this.preserveLockingKeysOnCopy = preserveLockingKeysOnCopy;
259     }
260 
261     /**
262      * @return the allowRecordDeletion
263      */
264     public boolean getAllowsRecordDeletion() {
265         return this.allowsRecordDeletion;
266     }
267 
268     /**
269      * @param allowsRecordDeletion the allowRecordDeletion to set
270      */
271     public void setAllowsRecordDeletion(boolean allowsRecordDeletion) {
272         this.allowsRecordDeletion = allowsRecordDeletion;
273     }
274 
275     @Deprecated
276     public boolean isTranslateCodes() {
277         return this.translateCodes;
278     }
279 
280     @Deprecated
281     public void setTranslateCodes(boolean translateCodes) {
282         this.translateCodes = translateCodes;
283     }
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         this.documentAuthorizerClass = documentAuthorizerClass;
292     }
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         return documentAuthorizerClass;
304     }
305 
306     public List<HeaderNavigation> getHeaderNavigationList() {
307         return headerNavigationList;
308     }
309 
310     public List<String> getWebScriptFiles() {
311         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         this.webScriptFiles = webScriptFiles;
321     }
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         this.headerNavigationList = headerNavigationList;
329     }
330 
331     public boolean isSessionDocument() {
332         return this.sessionDocument;
333     }
334 
335     public void setSessionDocument(boolean sessionDocument) {
336         this.sessionDocument = sessionDocument;
337     }
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         return this.documentPresentationControllerClass;
350     }
351 
352     /**
353      * @param documentPresentationControllerClass the documentPresentationControllerClass to set
354      */
355     public void setDocumentPresentationControllerClass(
356             Class<? extends DocumentPresentationController> documentPresentationControllerClass) {
357         this.documentPresentationControllerClass = documentPresentationControllerClass;
358     }
359 
360     /**
361      * @return the derivedValuesSetter
362      */
363     public Class<? extends DerivedValuesSetter> getDerivedValuesSetterClass() {
364         return this.derivedValuesSetterClass;
365     }
366 
367     /**
368      * @param derivedValuesSetter the derivedValuesSetter to set
369      */
370     public void setDerivedValuesSetterClass(Class<? extends DerivedValuesSetter> derivedValuesSetter) {
371         this.derivedValuesSetterClass = derivedValuesSetter;
372     }
373 }