1 /*
2 * Copyright 2006 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.fp.document.validation.impl;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import org.kuali.ole.fp.document.BudgetAdjustmentDocument;
22 import org.kuali.ole.sys.OLEConstants;
23 import org.kuali.ole.sys.businessobject.AccountingLine;
24 import org.kuali.rice.core.api.config.property.ConfigurationService;
25 import org.kuali.rice.kew.api.WorkflowDocument;
26 import org.kuali.rice.kns.rules.PromptBeforeValidationBase;
27 import org.kuali.rice.krad.document.Document;
28 import org.kuali.rice.krad.util.ObjectUtils;
29
30 /**
31 * Checks warnings and prompt conditions for ba document.
32 */
33 public class BudgetAdjustmentDocumentPreRules extends PromptBeforeValidationBase {
34 protected ConfigurationService kualiConfiguration;
35
36
37 /**
38 * Execute pre-rules for BudgetAdjustmentDocument
39 *
40 * @document document with pre-rules being applied
41 * @return true if pre-rules fire without problem
42 * @see org.kuali.rice.kns.rules.PromptBeforeValidationBase#doRules(org.kuali.rice.kns.document.MaintenanceDocument)
43 */
44 @Override
45 public boolean doPrompts(Document document) {
46 boolean preRulesOK = true;
47
48 // BudgetAdjustmentDocument budgetDocument = (BudgetAdjustmentDocument) document;
49 // preRulesOK = askLaborBenefitsGeneration(budgetDocument);
50
51 return preRulesOK;
52 }
53
54 /**
55 * TODO: remove this method once baseline accounting lines has been removed
56 */
57 protected List deepCopyAccountingLinesList(List originals) {
58 if (originals == null) {
59 return null;
60 }
61 List copiedLines = new ArrayList();
62 for (int i = 0; i < originals.size(); i++) {
63 copiedLines.add(ObjectUtils.deepCopy((AccountingLine) originals.get(i)));
64 }
65 return copiedLines;
66 }
67
68 /**
69 * Based on the routing status of the document, determines if labor benefits can be generated on the document
70 * @param budgetAdjustmentDocument the budget adjustment document that labor benefits would be generated on
71 * @return true if labor benefits can be generated, false otherwise
72 */
73 protected boolean canGenerateLaborBenefitsByRouteStatus(BudgetAdjustmentDocument budgetAdjustmentDocument) {
74 final WorkflowDocument workflowDocument = budgetAdjustmentDocument.getDocumentHeader().getWorkflowDocument();
75 if (workflowDocument.isInitiated() || workflowDocument.isSaved())
76 {
77 return true; // we're pre-route; we can add labor benefits
78 }
79 if (workflowDocument.isEnroute() && workflowDocument.getCurrentRouteNodeInstances().contains(OLEConstants.RouteLevelNames.ACCOUNT))
80 {
81 return true; // we're fiscal officers approving; we can add labor benefits
82 }
83 return false; // we're someone else and we're plum out of luck
84 }
85 }
86