View Javadoc

1   /**
2    * Copyright 2004-2013 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.kpme.core.paystep;
17  
18  import java.math.BigDecimal;
19  
20  import org.apache.commons.lang.StringUtils;
21  import org.apache.log4j.Logger;
22  import org.kuali.kpme.core.api.paystep.PayStepContract;
23  import org.kuali.kpme.core.bo.HrBusinessObject;
24  import org.kuali.kpme.core.util.HrConstants;
25  
26  import com.google.common.collect.ImmutableList;
27  
28  public class PayStep extends HrBusinessObject implements Comparable, PayStepContract {
29  
30  	private static final Logger LOG = Logger.getLogger(PayStep.class);
31  	//KPME-2273/1965 Primary Business Keys List.	
32  	public static final ImmutableList<String> EQUAL_TO_FIELDS = new ImmutableList.Builder<String>()
33  		    .add("payStep")
34  		    .build();
35  
36  	private static final long serialVersionUID = 1L;
37  	
38  	private String pmPayStepId;
39  	private String payStep;
40  	private String institution;
41  	private String location;
42  	private String salaryGroup;
43  	private String payGrade;
44  	private int stepNumber;
45  	private BigDecimal compRate;
46  	private int serviceAmount;
47  	private String serviceUnit;
48  	private String history;
49  	
50  	@Override
51  	public boolean isActive() {
52  		return super.isActive();
53  	}
54  
55  	@Override
56  	public void setActive(boolean active) {
57  		super.setActive(active);
58  	}
59  
60  	@Override
61  	public String getObjectId() {
62  		return super.getObjectId();
63  	}
64  
65  	@Override
66  	public Long getVersionNumber() {
67  		return super.getVersionNumber();
68  	}
69  
70  	@Override
71  	public int compareTo(Object o) {
72  		if(o instanceof PayStep) {
73  			PayStep s = (PayStep) o;
74  			if(StringUtils.equals(s.salaryGroup,salaryGroup)
75  					&& StringUtils.equals(s.payGrade,payGrade)) {
76  
77  				Integer otherServiceTime = 0;
78  				if(StringUtils.equals(s.serviceUnit,HrConstants.SERVICE_TIME_YEAR))
79  					otherServiceTime = s.getServiceAmount() * 12;
80  				else
81  					otherServiceTime = s.getServiceAmount();
82  				
83  				Integer thisServiceTime = 0;
84  				if(StringUtils.equals(serviceUnit, HrConstants.SERVICE_TIME_YEAR))
85  					thisServiceTime = serviceAmount * 12;
86  				else
87  					thisServiceTime = serviceAmount;
88  				
89  				return otherServiceTime.compareTo(thisServiceTime);
90  			}
91  			else 
92  //				throw new IllegalArgumentException("pay step must be within the same salary group and pay grade");
93  				LOG.error("pay step must be within the same salary group and pay grade");
94  		}
95  			
96  		return 0;
97  	}
98  
99  	public String getPayStep() {
100 		return payStep;
101 	}
102 
103 	public void setPayStep(String payStep) {
104 		this.payStep = payStep;
105 	}
106 
107 	public String getInstitution() {
108 		return institution;
109 	}
110 
111 	public void setInstitution(String institution) {
112 		this.institution = institution;
113 	}
114 
115 	public String getLocation() {
116 		return location;
117 	}
118 
119 	public void setLocation(String location) {
120 		this.location = location;
121 	}
122 
123 	public String getSalaryGroup() {
124 		return salaryGroup;
125 	}
126 
127 	public void setSalaryGroup(String salaryGroup) {
128 		this.salaryGroup = salaryGroup;
129 	}
130 
131 	public String getPayGrade() {
132 		return payGrade;
133 	}
134 
135 	public void setPayGrade(String payGrade) {
136 		this.payGrade = payGrade;
137 	}
138 
139 	public int getStepNumber() {
140 		return stepNumber;
141 	}
142 
143 	public void setStepNumber(int stepNumber) {
144 		this.stepNumber = stepNumber;
145 	}
146 
147 	public BigDecimal getCompRate() {
148 		return compRate;
149 	}
150 
151 	public void setCompRate(BigDecimal compRate) {
152 		this.compRate = compRate;
153 	}
154 
155 	public int getServiceAmount() {
156 		return serviceAmount;
157 	}
158 
159 	public void setServiceAmount(int serviceInterval) {
160 		this.serviceAmount = serviceInterval;
161 	}
162 
163 	public String getServiceUnit() {
164 		return serviceUnit;
165 	}
166 
167 	public void setServiceUnit(String serviceUnit) {
168 		this.serviceUnit = serviceUnit;
169 	}
170 
171 	@Override
172 	public String getId() {
173 		return pmPayStepId;
174 	}
175 
176 	@Override
177 	public void setId(String id) {
178 		pmPayStepId = id;
179 	}
180 
181 	@Override
182 	protected String getUniqueKey() {
183 		return getPmPayStepId();
184 	}
185 
186 	public String getPmPayStepId() {
187 		return pmPayStepId;
188 	}
189 
190 	public void setPmPayStepId(String pmPayStepId) {
191 		this.pmPayStepId = pmPayStepId;
192 	}
193 
194 	public String getHistory() {
195 		return history;
196 	}
197 
198 	public void setHistory(String history) {
199 		this.history = history;
200 	}
201 
202 
203 }