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.apache.commons.lang.StringUtils;
19  import org.kuali.ole.module.purap.PurapConstants;
20  import org.kuali.ole.module.purap.PurapConstants.RequisitionStatuses;
21  import org.kuali.ole.module.purap.businessobject.PurApAccountingLine;
22  import org.kuali.ole.module.purap.document.RequisitionDocument;
23  import org.kuali.ole.sys.document.validation.event.AttributedDocumentEvent;
24  
25  /**
26   * A validation that checks whether the given accounting line is accessible to the given user or not
27   */
28  public class RequisitionAccountingLineAccessibleValidation extends PurchasingAccountsPayableAccountingLineAccessibleValidation {
29  
30      /**
31       * Validates that the given accounting line is accessible for editing by the current user.
32       * <strong>This method expects a document as the first parameter and an accounting line as the second</strong>
33       *
34       * @see org.kuali.ole.sys.document.validation.Validation#validate(java.lang.Object[])
35       */
36      public boolean validate(AttributedDocumentEvent event) {
37          RequisitionDocument requisitionDocument = (RequisitionDocument) event.getDocument();
38          //for app doc status
39          //to be removed
40          //remove (requisitionDocument.isDocumentStoppedInRouteNode(NodeDetailEnum.CONTENT_REVIEW) - kfsmi-4592
41          if (requisitionDocument.isDocumentStoppedInRouteNode(RequisitionStatuses.NODE_CONTENT_REVIEW) ||
42                  StringUtils.equals(requisitionDocument.getApplicationDocumentStatus(), PurapConstants.RequisitionStatuses.APPDOC_IN_PROCESS)) {
43              // DO NOTHING: do not check that user owns acct lines; at this level, approvers can edit all detail on REQ
44  
45              return true;
46          } else {
47              boolean result = false;
48              boolean setDummyAccountIdentifier = false;
49  
50              if (needsDummyAccountIdentifier()) {
51                  ((PurApAccountingLine) getAccountingLineForValidation()).setAccountIdentifier(Integer.MAX_VALUE);  // avoid conflicts with any accouting identifier on any other accounting lines in the doc because, you know, you never know...
52                  setDummyAccountIdentifier = true;
53              }
54  
55              result = super.validate(event);
56  
57              if (setDummyAccountIdentifier) {
58                  ((PurApAccountingLine) getAccountingLineForValidation()).setAccountIdentifier(null);
59              }
60  
61              return result;
62          }
63      }
64  
65  }
66