001    /*
002     * Copyright 2011 The Kuali Foundation.
003     * 
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     * 
008     * http://www.opensource.org/licenses/ecl2.php
009     * 
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.kfs.module.bc.document.web.struts;
017    
018    import java.util.HashMap;
019    import java.util.List;
020    import java.util.Map;
021    
022    import org.kuali.kfs.module.bc.BCConstants;
023    import org.kuali.kfs.module.bc.businessobject.BudgetConstructionPosition;
024    import org.kuali.kfs.module.bc.businessobject.PendingBudgetConstructionAppointmentFunding;
025    import org.kuali.kfs.sys.KFSPropertyConstants;
026    
027    public class PositionSalarySettingForm extends DetailSalarySettingForm {
028        private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(PositionSalarySettingForm.class);
029    
030        private boolean refreshPositionBeforeSalarySetting;
031    
032        private BudgetConstructionPosition budgetConstructionPosition;
033    
034    
035        /**
036         * Constructs a PositionSalarySettingForm.java.
037         */
038        public PositionSalarySettingForm() {
039            super();
040    
041            this.setBudgetConstructionPosition(new BudgetConstructionPosition());
042        }
043    
044        /**
045         * @see org.kuali.kfs.module.bc.document.web.struts.DetailSalarySettingForm#createNewAppointmentFundingLine()
046         */
047        @Override
048        public PendingBudgetConstructionAppointmentFunding createNewAppointmentFundingLine() {
049            PendingBudgetConstructionAppointmentFunding appointmentFunding = super.createNewAppointmentFundingLine();
050    
051            appointmentFunding.setPositionNumber(this.getBudgetConstructionPosition().getPositionNumber());
052            appointmentFunding.setFinancialObjectCode(this.getBudgetConstructionPosition().getIuDefaultObjectCode());
053    
054            return appointmentFunding;
055        }
056    
057        /**
058         * @see org.kuali.kfs.module.bc.document.web.struts.SalarySettingBaseForm#getKeyMapOfSalarySettingItem()
059         */
060        @Override
061        public Map<String, Object> getKeyMapOfSalarySettingItem() {
062            Map<String, Object> keyMap = new HashMap<String, Object>();
063    
064            keyMap.put(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, this.getUniversityFiscalYear());
065            keyMap.put(KFSPropertyConstants.POSITION_NUMBER, this.getPositionNumber());
066    
067            return keyMap;
068        }
069    
070        /**
071         * @see org.kuali.kfs.module.bc.document.web.struts.DetailSalarySettingForm#getRefreshCallerName()
072         */
073        @Override
074        public String getRefreshCallerName() {
075            return BCConstants.POSITION_SALARY_SETTING_REFRESH_CALLER;
076        }
077    
078        /**
079         * @see org.kuali.kfs.module.bc.document.web.struts.SalarySettingForm#getAppointmentFundings()
080         */
081        @Override
082        public List<PendingBudgetConstructionAppointmentFunding> getAppointmentFundings() {
083            return this.getBudgetConstructionPosition().getPendingBudgetConstructionAppointmentFunding();
084        }
085    
086        /**
087         * Gets the budgetConstructionPosition attribute.
088         * 
089         * @return Returns the budgetConstructionPosition.
090         */
091        public BudgetConstructionPosition getBudgetConstructionPosition() {
092            return this.budgetConstructionPosition;
093        }
094    
095        /**
096         * Sets the budgetConstructionPosition attribute value.
097         * 
098         * @param budgetConstructionPosition The budgetConstructionPosition to set.
099         */
100        public void setBudgetConstructionPosition(BudgetConstructionPosition budgetConstructionPosition) {
101            this.budgetConstructionPosition = budgetConstructionPosition;
102        }
103    
104        /**
105         * checks if at least one active edit-able appointment funding line has a sync flag set
106         * 
107         * @return true or false
108         */
109        public boolean isPendingPositionSalaryChange(){
110    
111            List<PendingBudgetConstructionAppointmentFunding> activeAppointmentFundings = this.getActiveFundingLines();
112            for (PendingBudgetConstructionAppointmentFunding appointmentFunding : activeAppointmentFundings){
113                if (!appointmentFunding.isDisplayOnlyMode()){
114                    if (appointmentFunding.isPositionChangeIndicator()){
115                        return true;
116                    }
117                }
118            }
119            return false;
120        }
121    
122        /**
123         * Gets the refreshPositionBeforeSalarySetting attribute.
124         * 
125         * @return Returns the refreshPositionBeforeSalarySetting.
126         */
127        public boolean isRefreshPositionBeforeSalarySetting() {
128            return refreshPositionBeforeSalarySetting;
129        }
130    
131        /**
132         * Sets the refreshPositionBeforeSalarySetting attribute value.
133         * 
134         * @param refreshPositionBeforeSalarySetting The refreshPositionBeforeSalarySetting to set.
135         */
136        public void setRefreshPositionBeforeSalarySetting(boolean refreshPositionBeforeSalarySetting) {
137            this.refreshPositionBeforeSalarySetting = refreshPositionBeforeSalarySetting;
138        }
139    
140        /**
141         * Gets the documentTitle
142         * @return
143         */
144        public String getDocumentTitle() {
145            return BCConstants.POSITION_SALARY_SETTING_TITLE;
146        }
147    }