1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  package org.kuali.ole.fp.service.impl;
17  
18  import java.util.ArrayList;
19  import java.util.Collection;
20  import java.util.HashMap;
21  import java.util.Iterator;
22  import java.util.List;
23  
24  import org.kuali.ole.fp.businessobject.FiscalYearFunctionControl;
25  import org.kuali.ole.fp.service.FiscalYearFunctionControlService;
26  import org.kuali.ole.sys.OLEConstants;
27  import org.kuali.ole.sys.OLEPropertyConstants;
28  import org.kuali.rice.krad.service.BusinessObjectService;
29  
30  
31  
32  
33  
34  
35  public class FiscalYearFunctionControlServiceImpl implements FiscalYearFunctionControlService {
36  
37      public static String FY_FUNCTION_CONTROL_BA_ALLOWED = "BAACTV";
38      public static String FY_FUNCTION_CONTROL_BASE_AMT_ALLOWED = "BASEAD";
39  
40      private BusinessObjectService businessObjectService;
41  
42      
43  
44  
45  
46  
47  
48  
49  
50      protected boolean getActiveIndByPrimaryId(Integer postingYear, String financialSystemFunctionControlCode) {
51          HashMap<String, Object> keys = new HashMap();
52          keys.put(OLEPropertyConstants.UNIVERSITY_FISCAL_YEAR, postingYear);
53          keys.put(OLEPropertyConstants.FINANCIAL_SYSTEM_FUNCTION_CONTROL_CODE, financialSystemFunctionControlCode);
54          FiscalYearFunctionControl control = (FiscalYearFunctionControl) businessObjectService.findByPrimaryKey(FiscalYearFunctionControl.class, keys);
55          return (control != null) && control.isFinancialSystemFunctionActiveIndicator();
56      }
57  
58      
59  
60  
61  
62  
63  
64  
65      protected List getByFunctionControlCodeAndActiveInd(String financialSystemFunctionControlCode, String financialSystemFunctionActiveIndicator) {
66          HashMap values = new HashMap();
67          values.put(OLEPropertyConstants.FINANCIAL_SYSTEM_FUNCTION_CONTROL_CODE, financialSystemFunctionControlCode);
68          values.put(OLEPropertyConstants.FINANCIAL_SYSTEM_FUNCTION_ACTIVE_INDICATOR, financialSystemFunctionActiveIndicator);
69          Collection controls = businessObjectService.findMatching(FiscalYearFunctionControl.class, values);
70          return new ArrayList(controls);
71      }
72  
73      
74  
75  
76  
77  
78  
79  
80      public List getBudgetAdjustmentAllowedYears() {
81          return getByFunctionControlCodeAndActiveInd(FY_FUNCTION_CONTROL_BA_ALLOWED, "Y");
82      }
83  
84      
85  
86  
87  
88  
89  
90  
91  
92  
93      public boolean isBaseAmountChangeAllowed(Integer postingYear) {
94          return getActiveIndByPrimaryId(postingYear, FY_FUNCTION_CONTROL_BASE_AMT_ALLOWED);
95      }
96      
97  
98  
99  
100     public List<Integer> getActiveBudgetYear()
101     {
102         ArrayList<FiscalYearFunctionControl> activeYearObjects = (ArrayList<FiscalYearFunctionControl>) getByFunctionControlCodeAndActiveInd(OLEConstants.BudgetConstructionConstants.BUDGET_CONSTRUCTION_ACTIVE,OLEConstants.ACTIVE_INDICATOR);
103         ArrayList<Integer> activeYears = new ArrayList<Integer>(activeYearObjects.size());
104         Iterator<FiscalYearFunctionControl> activeYearObjectIterator = activeYearObjects.iterator();
105         int nextSlot = 0;
106         while (activeYearObjectIterator.hasNext())
107         {
108             activeYears.add(nextSlot++,activeYearObjectIterator.next().getUniversityFiscalYear());
109         }
110         return activeYears;
111     }
112 
113 
114     
115 
116 
117 
118     public boolean isApplicationUpdateFromHumanResourcesAllowed(Integer universityFiscalYear)
119     {
120         return getActiveIndByPrimaryId(universityFiscalYear, OLEConstants.BudgetConstructionConstants.BUDGET_ON_LINE_SYNCHRONIZATION_OK);
121     }
122   
123     
124 
125 
126 
127     public boolean isBatchUpdateFromHumanResourcesAllowed(Integer universityFiscalYear)
128     {
129         return getActiveIndByPrimaryId(universityFiscalYear, OLEConstants.BudgetConstructionConstants.BUDGET_BATCH_SYNCHRONIZATION_OK);
130     }
131     
132     
133 
134 
135 
136     public boolean isBatchUpdateFromPayrollAllowed (Integer universityFiscalYear)
137     {
138         return getActiveIndByPrimaryId(universityFiscalYear, OLEConstants.BudgetConstructionConstants.CSF_UPDATES_OK);
139     }
140     
141 
142     public boolean isBudgetConstructionActive(Integer universityFiscalYear)
143     {
144         return getActiveIndByPrimaryId(universityFiscalYear, OLEConstants.BudgetConstructionConstants.BUDGET_CONSTRUCTION_ACTIVE);
145     }
146 
147     
148 
149 
150 
151     public boolean isBudgetGeneralLedgerUpdateAllowed(Integer universityFiscalYear)
152     {
153         return getActiveIndByPrimaryId(universityFiscalYear, OLEConstants.BudgetConstructionConstants.BASE_BUDGET_UPDATES_OK);
154     }
155     
156     public boolean isBudgetUpdateAllowed(Integer universityFiscalYear)
157     {
158         return getActiveIndByPrimaryId(universityFiscalYear, OLEConstants.BudgetConstructionConstants.BUDGET_CONSTRUCTION_UPDATES_OK);
159     }
160     
161     
162 
163 
164 
165 
166     public BusinessObjectService getBusinessObjectService() {
167         return businessObjectService;
168     }
169 
170     
171 
172 
173 
174 
175     public void setBusinessObjectService(BusinessObjectService businessObjectService) {
176         this.businessObjectService = businessObjectService;
177     }
178 }