1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.kuali.kfs.module.bc.document.validation.impl;
20
21 import java.util.ArrayList;
22 import java.util.Collection;
23 import java.util.List;
24
25 import org.kuali.kfs.module.bc.BCConstants.MonthSpreadDeleteType;
26 import org.kuali.kfs.module.bc.BCConstants.SynchronizationCheckType;
27 import org.kuali.kfs.module.bc.businessobject.BudgetConstructionMonthly;
28 import org.kuali.kfs.module.bc.businessobject.PendingBudgetConstructionAppointmentFunding;
29 import org.kuali.kfs.module.bc.businessobject.PendingBudgetConstructionGeneralLedger;
30 import org.kuali.kfs.module.bc.document.BudgetConstructionDocument;
31 import org.kuali.kfs.module.bc.document.validation.AddBudgetConstructionDocumentRule;
32 import org.kuali.kfs.module.bc.document.validation.AddPendingBudgetGeneralLedgerLineRule;
33 import org.kuali.kfs.module.bc.document.validation.BudgetExpansionRule;
34 import org.kuali.kfs.module.bc.document.validation.DeleteMonthlySpreadRule;
35 import org.kuali.kfs.module.bc.document.validation.DeletePendingBudgetGeneralLedgerLineRule;
36 import org.kuali.kfs.module.bc.document.validation.SalarySettingRule;
37 import org.kuali.kfs.module.bc.document.validation.SaveMonthlyBudgetRule;
38 import org.kuali.kfs.module.bc.document.validation.event.BudgetExpansionEvent;
39 import org.kuali.rice.krad.document.Document;
40 import org.kuali.rice.krad.rules.rule.BusinessRule;
41 import org.kuali.rice.krad.rules.rule.SaveDocumentRule;
42
43
44
45
46 public class BudgetConstructionRules implements BudgetExpansionRule, SalarySettingRule, SaveDocumentRule, AddBudgetConstructionDocumentRule<BudgetConstructionDocument>, AddPendingBudgetGeneralLedgerLineRule<BudgetConstructionDocument, PendingBudgetConstructionGeneralLedger>, DeletePendingBudgetGeneralLedgerLineRule<BudgetConstructionDocument, PendingBudgetConstructionGeneralLedger>, DeleteMonthlySpreadRule<BudgetConstructionDocument>, SaveMonthlyBudgetRule<BudgetConstructionDocument, BudgetConstructionMonthly> {
47 private Collection<BusinessRule> expansionRules;
48 private BudgetConstructionDocumentRules budgetConstructionDocumentRules;
49 private SalarySettingRule salarySettingRules;
50
51
52
53
54 public BudgetConstructionRules() {
55 expansionRules = new ArrayList<BusinessRule>();
56
57 try {
58 budgetConstructionDocumentRules = BudgetConstructionDocumentRules.class.newInstance();
59 expansionRules.add(budgetConstructionDocumentRules);
60
61 salarySettingRules = SalarySettingRules.class.newInstance();
62 expansionRules.add(salarySettingRules);
63 }
64 catch (InstantiationException e) {
65 throw new RuntimeException(e);
66 }
67 catch (IllegalAccessException e) {
68 throw new RuntimeException(e);
69 }
70 }
71
72
73
74
75 public boolean processExpansionRule(BudgetExpansionEvent budgetExpansionEvent) {
76 boolean valid = true;
77
78 Class<? extends BusinessRule> expansionRuleClass = budgetExpansionEvent.getExpansionRuleInterfaceClass();
79 for (BusinessRule expansionRule : expansionRules) {
80 if (expansionRuleClass.isAssignableFrom(expansionRule.getClass())) {
81 valid &= budgetExpansionEvent.invokeExpansionRuleMethod(expansionRule);
82 }
83 }
84
85 return valid;
86 }
87
88
89
90
91 public boolean processSaveDocument(Document document) {
92 return ((SaveDocumentRule) budgetConstructionDocumentRules).processSaveDocument(document);
93 }
94
95
96
97
98 public boolean processAddBudgetConstructionDocumentRules(BudgetConstructionDocument budgetConstructionDocument) {
99 return ((AddBudgetConstructionDocumentRule<BudgetConstructionDocument>) budgetConstructionDocumentRules).processAddBudgetConstructionDocumentRules(budgetConstructionDocument);
100 }
101
102
103
104
105
106 public boolean processAddPendingBudgetGeneralLedgerLineRules(BudgetConstructionDocument budgetConstructionDocument, PendingBudgetConstructionGeneralLedger pendingBudgetConstructionGeneralLedger, boolean isRevenue) {
107 return ((AddPendingBudgetGeneralLedgerLineRule<BudgetConstructionDocument, PendingBudgetConstructionGeneralLedger>) budgetConstructionDocumentRules).processAddPendingBudgetGeneralLedgerLineRules(budgetConstructionDocument, pendingBudgetConstructionGeneralLedger, isRevenue);
108 }
109
110
111
112
113
114 public boolean processDeletePendingBudgetGeneralLedgerLineRules(BudgetConstructionDocument budgetConstructionDocument, PendingBudgetConstructionGeneralLedger pendingBudgetConstructionGeneralLedger, boolean isRevenue) {
115 return ((DeletePendingBudgetGeneralLedgerLineRule<BudgetConstructionDocument, PendingBudgetConstructionGeneralLedger>) budgetConstructionDocumentRules).processDeletePendingBudgetGeneralLedgerLineRules(budgetConstructionDocument, pendingBudgetConstructionGeneralLedger, isRevenue);
116 }
117
118
119
120
121
122 public boolean processDeleteMonthlySpreadRules(BudgetConstructionDocument budgetConstructionDocument, MonthSpreadDeleteType monthSpreadDeleteType) {
123 return ((DeleteMonthlySpreadRule<BudgetConstructionDocument>) budgetConstructionDocumentRules).processDeleteMonthlySpreadRules(budgetConstructionDocument, monthSpreadDeleteType);
124 }
125
126 public boolean processSaveMonthlyBudgetRules(BudgetConstructionDocument budgetConstructionDocument, BudgetConstructionMonthly budgetConstructionMonthly){
127 return ((SaveMonthlyBudgetRule<BudgetConstructionDocument, BudgetConstructionMonthly>) budgetConstructionDocumentRules).processSaveMonthlyBudgetRules(budgetConstructionDocument, budgetConstructionMonthly);
128 }
129
130
131
132 public boolean processAddAppointmentFunding(List<PendingBudgetConstructionAppointmentFunding> existingAppointmentFundings, PendingBudgetConstructionAppointmentFunding appointmentFunding, SynchronizationCheckType synchronizationCheckType) {
133 return salarySettingRules.processAddAppointmentFunding(existingAppointmentFundings, appointmentFunding, synchronizationCheckType);
134 }
135
136
137
138
139 public boolean processSaveAppointmentFunding(PendingBudgetConstructionAppointmentFunding appointmentFunding, SynchronizationCheckType synchronizationCheckType) {
140 return salarySettingRules.processSaveAppointmentFunding(appointmentFunding, synchronizationCheckType);
141 }
142
143
144
145
146 public boolean processNormalizePayrateAndAmount(PendingBudgetConstructionAppointmentFunding appointmentFunding) {
147 return salarySettingRules.processNormalizePayrateAndAmount(appointmentFunding);
148 }
149
150
151
152
153 public boolean processAdjustSalaraySettingLinePercent(PendingBudgetConstructionAppointmentFunding appointmentFunding) {
154 return salarySettingRules.processAdjustSalaraySettingLinePercent(appointmentFunding);
155 }
156
157
158
159
160 public boolean processQuickSaveAppointmentFunding(PendingBudgetConstructionAppointmentFunding appointmentFunding) {
161 return salarySettingRules.processQuickSaveAppointmentFunding(appointmentFunding);
162 }
163 }