View Javadoc
1   /*
2    * Copyright 2008 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.ole.module.purap.document.validation.impl;
17  
18  import org.kuali.ole.module.purap.businessobject.PurApAccountingLine;
19  import org.kuali.ole.sys.document.validation.impl.AccountingLineAccessibleValidation;
20  import org.kuali.rice.kew.api.WorkflowDocument;
21  
22  import java.util.Set;
23  
24  /**
25   * A validation that checks whether the given accounting line is accessible to the given user or not
26   */
27  public class PurchasingAccountsPayableAccountingLineAccessibleValidation extends AccountingLineAccessibleValidation {
28  
29      /**
30       * Determines the route levels for a given document.
31       *
32       * @param workflowDocument The workflow document from which the current route levels are to be obtained.
33       * @return List The List of current route levels of the given document.
34       */
35      protected static Set<String> getCurrentRouteLevels(WorkflowDocument workflowDocument) {
36          Set<String> currentNodeNames = workflowDocument.getCurrentNodeNames();
37          return currentNodeNames;
38      }
39  
40      @Override
41      protected String getGroupName() {
42          return "source";
43      }
44  
45      @Override
46      protected String getAccountingLineCollectionProperty() {
47          return "items.sourceAccountingLines";
48      }
49  
50      /**
51       * @return true if a dummy account identifier should be set on the accounting line, false otherwise
52       */
53      protected boolean needsDummyAccountIdentifier() {
54          if (((PurApAccountingLine) getAccountingLineForValidation()).getAccountIdentifier() != null) {
55              return false;
56          }
57  
58          final WorkflowDocument workflowDocument = getAccountingDocumentForValidation().getDocumentHeader().getWorkflowDocument();
59          if (workflowDocument.isInitiated() || workflowDocument.isSaved()) {
60              return false;
61          }
62  
63          return true;
64      }
65  }
66