View Javadoc
1   /**
2    * Copyright 2004-2014 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.api.paystep;
17  
18  import java.io.Serializable;
19  import java.math.BigDecimal;
20  import java.util.Collection;
21  import javax.xml.bind.annotation.XmlAccessType;
22  import javax.xml.bind.annotation.XmlAccessorType;
23  import javax.xml.bind.annotation.XmlAnyElement;
24  import javax.xml.bind.annotation.XmlElement;
25  import javax.xml.bind.annotation.XmlRootElement;
26  import javax.xml.bind.annotation.XmlType;
27  
28  import org.apache.commons.lang.StringUtils;
29  import org.joda.time.DateTime;
30  import org.joda.time.LocalDate;
31  import org.kuali.kpme.core.api.groupkey.HrGroupKey;
32  import org.kuali.kpme.core.api.groupkey.HrGroupKeyContract;
33  import org.kuali.rice.core.api.CoreConstants;
34  import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
35  import org.kuali.rice.core.api.mo.ModelBuilder;
36  import org.w3c.dom.Element;
37  
38  @XmlRootElement(name = PayStep.Constants.ROOT_ELEMENT_NAME)
39  @XmlAccessorType(XmlAccessType.NONE)
40  @XmlType(name = PayStep.Constants.TYPE_NAME, propOrder = {
41      PayStep.Elements.COMP_RATE,
42      PayStep.Elements.STEP_NUMBER,
43      PayStep.Elements.PAY_GRADE,
44      PayStep.Elements.PM_PAY_STEP_ID,
45      PayStep.Elements.SERVICE_UNIT,
46      PayStep.Elements.PAY_STEP,
47      PayStep.Elements.SALARY_GROUP,
48      PayStep.Elements.SERVICE_AMOUNT,
49      CoreConstants.CommonElements.VERSION_NUMBER,
50      CoreConstants.CommonElements.OBJECT_ID,
51      PayStep.Elements.ACTIVE,
52      PayStep.Elements.ID,
53      PayStep.Elements.EFFECTIVE_LOCAL_DATE,
54      PayStep.Elements.CREATE_TIME,
55      PayStep.Elements.USER_PRINCIPAL_ID,
56      CoreConstants.CommonElements.FUTURE_ELEMENTS
57  })
58  public final class PayStep
59      extends AbstractDataTransferObject
60      implements PayStepContract
61  {
62  
63      @XmlElement(name = Elements.COMP_RATE, required = false)
64      private final BigDecimal compRate;
65      @XmlElement(name = Elements.STEP_NUMBER, required = false)
66      private final int stepNumber;
67      @XmlElement(name = Elements.PAY_GRADE, required = false)
68      private final String payGrade;
69      @XmlElement(name = Elements.PM_PAY_STEP_ID, required = false)
70      private final String pmPayStepId;
71      @XmlElement(name = Elements.SERVICE_UNIT, required = false)
72      private final String serviceUnit;
73      @XmlElement(name = Elements.PAY_STEP, required = false)
74      private final String payStep;
75      @XmlElement(name = Elements.SALARY_GROUP, required = false)
76      private final String salaryGroup;
77      @XmlElement(name = Elements.SERVICE_AMOUNT, required = false)
78      private final int serviceAmount;
79      @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
80      private final Long versionNumber;
81      @XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
82      private final String objectId;
83      @XmlElement(name = Elements.ACTIVE, required = false)
84      private final boolean active;
85      @XmlElement(name = Elements.ID, required = false)
86      private final String id;
87      @XmlElement(name = Elements.EFFECTIVE_LOCAL_DATE, required = false)
88      private final LocalDate effectiveLocalDate;
89      @XmlElement(name = Elements.CREATE_TIME, required = false)
90      private final DateTime createTime;
91      @XmlElement(name = Elements.USER_PRINCIPAL_ID, required = false)
92      private final String userPrincipalId;
93      @SuppressWarnings("unused")
94      @XmlAnyElement
95      private final Collection<Element> _futureElements = null;
96  
97      /**
98       * Private constructor used only by JAXB.
99       * 
100      */
101     private PayStep() {
102         this.compRate = null;
103         this.stepNumber = 0;
104         this.payGrade = null;
105         this.pmPayStepId = null;
106         this.serviceUnit = null;
107         this.payStep = null;
108         this.salaryGroup = null;
109         this.serviceAmount = 0;
110         this.versionNumber = null;
111         this.objectId = null;
112         this.active = false;
113         this.id = null;
114         this.effectiveLocalDate = null;
115         this.createTime = null;
116         this.userPrincipalId = null;
117     }
118 
119     private PayStep(Builder builder) {
120         this.compRate = builder.getCompRate();
121         this.stepNumber = builder.getStepNumber();
122         this.payGrade = builder.getPayGrade();
123         this.pmPayStepId = builder.getPmPayStepId();
124         this.serviceUnit = builder.getServiceUnit();
125         this.payStep = builder.getPayStep();
126         this.salaryGroup = builder.getSalaryGroup();
127         this.serviceAmount = builder.getServiceAmount();
128         this.versionNumber = builder.getVersionNumber();
129         this.objectId = builder.getObjectId();
130         this.active = builder.isActive();
131         this.id = builder.getId();
132         this.effectiveLocalDate = builder.getEffectiveLocalDate();
133         this.createTime = builder.getCreateTime();
134         this.userPrincipalId = builder.getUserPrincipalId();
135     }
136 
137     @Override
138     public BigDecimal getCompRate() {
139         return this.compRate;
140     }
141 
142     @Override
143     public int getStepNumber() {
144         return this.stepNumber;
145     }
146 
147     @Override
148     public String getPayGrade() {
149         return this.payGrade;
150     }
151 
152     @Override
153     public String getPmPayStepId() {
154         return this.pmPayStepId;
155     }
156 
157     @Override
158     public String getServiceUnit() {
159         return this.serviceUnit;
160     }
161 
162     @Override
163     public String getPayStep() {
164         return this.payStep;
165     }
166 
167     @Override
168     public String getSalaryGroup() {
169         return this.salaryGroup;
170     }
171 
172     @Override
173     public int getServiceAmount() {
174         return this.serviceAmount;
175     }
176 
177     @Override
178     public Long getVersionNumber() {
179         return this.versionNumber;
180     }
181 
182     @Override
183     public String getObjectId() {
184         return this.objectId;
185     }
186 
187     @Override
188     public boolean isActive() {
189         return this.active;
190     }
191 
192     @Override
193     public String getId() {
194         return this.id;
195     }
196 
197     @Override
198     public LocalDate getEffectiveLocalDate() {
199         return this.effectiveLocalDate;
200     }
201 
202     @Override
203     public DateTime getCreateTime() {
204         return this.createTime;
205     }
206 
207     @Override
208     public String getUserPrincipalId() {
209         return this.userPrincipalId;
210     }
211 
212 
213     /**
214      * A builder which can be used to construct {@link PayStep} instances.  Enforces the constraints of the {@link PayStepContract}.
215      * 
216      */
217     public final static class Builder
218         implements Serializable, PayStepContract, ModelBuilder
219     {
220 
221         private BigDecimal compRate;
222         private int stepNumber;
223         private String payGrade;
224         private String pmPayStepId;
225         private String serviceUnit;
226         private String payStep;
227         private String salaryGroup;
228         private int serviceAmount;
229         private Long versionNumber;
230         private String objectId;
231         private boolean active;
232         private String id;
233         private LocalDate effectiveLocalDate;
234         private DateTime createTime;
235         private String userPrincipalId;
236 
237         private Builder(String payStep) {
238         	setPayStep(payStep);
239         }
240 
241         public static Builder create(String payStep) {
242             return new Builder(payStep);
243         }
244 
245         public static Builder create(PayStepContract contract) {
246             if (contract == null) {
247                 throw new IllegalArgumentException("contract was null");
248             }
249 
250             Builder builder = create(contract.getPayStep());
251             builder.setCompRate(contract.getCompRate());
252             builder.setStepNumber(contract.getStepNumber());
253             builder.setPayGrade(contract.getPayGrade());
254             builder.setPmPayStepId(contract.getPmPayStepId());
255             builder.setServiceUnit(contract.getServiceUnit());
256             builder.setSalaryGroup(contract.getSalaryGroup());
257             builder.setServiceAmount(contract.getServiceAmount());
258             builder.setVersionNumber(contract.getVersionNumber());
259             builder.setObjectId(contract.getObjectId());
260             builder.setActive(contract.isActive());
261             builder.setId(contract.getId());
262             builder.setEffectiveLocalDate(contract.getEffectiveLocalDate());
263             builder.setCreateTime(contract.getCreateTime());
264             builder.setUserPrincipalId(contract.getUserPrincipalId());
265             return builder;
266         }
267 
268         public PayStep build() {
269             return new PayStep(this);
270         }
271 
272         @Override
273         public BigDecimal getCompRate() {
274             return this.compRate;
275         }
276 
277         @Override
278         public int getStepNumber() {
279             return this.stepNumber;
280         }
281 
282         @Override
283         public String getPayGrade() {
284             return this.payGrade;
285         }
286 
287         @Override
288         public String getPmPayStepId() {
289             return this.pmPayStepId;
290         }
291 
292         @Override
293         public String getServiceUnit() {
294             return this.serviceUnit;
295         }
296 
297         @Override
298         public String getPayStep() {
299             return this.payStep;
300         }
301 
302         @Override
303         public String getSalaryGroup() {
304             return this.salaryGroup;
305         }
306 
307         @Override
308         public int getServiceAmount() {
309             return this.serviceAmount;
310         }
311 
312         @Override
313         public Long getVersionNumber() {
314             return this.versionNumber;
315         }
316 
317         @Override
318         public String getObjectId() {
319             return this.objectId;
320         }
321 
322         @Override
323         public boolean isActive() {
324             return this.active;
325         }
326 
327         @Override
328         public String getId() {
329             return this.id;
330         }
331 
332         @Override
333         public LocalDate getEffectiveLocalDate() {
334             return this.effectiveLocalDate;
335         }
336 
337         @Override
338         public DateTime getCreateTime() {
339             return this.createTime;
340         }
341 
342         @Override
343         public String getUserPrincipalId() {
344             return this.userPrincipalId;
345         }
346 
347         public void setCompRate(BigDecimal compRate) {
348 
349             this.compRate = compRate;
350         }
351 
352         public void setStepNumber(int stepNumber) {
353 
354             this.stepNumber = stepNumber;
355         }
356 
357         public void setPayGrade(String payGrade) {
358 
359             this.payGrade = payGrade;
360         }
361 
362         public void setPmPayStepId(String pmPayStepId) {
363 
364             this.pmPayStepId = pmPayStepId;
365         }
366 
367         public void setServiceUnit(String serviceUnit) {
368 
369             this.serviceUnit = serviceUnit;
370         }
371 
372         public void setPayStep(String payStep) {
373 
374         	if (StringUtils.isWhitespace(payStep)) {
375                 throw new IllegalArgumentException("payStep is blank");
376             }
377             this.payStep = payStep;
378         }
379 
380         public void setSalaryGroup(String salaryGroup) {
381 
382             this.salaryGroup = salaryGroup;
383         }
384 
385         public void setServiceAmount(int serviceAmount) {
386 
387             this.serviceAmount = serviceAmount;
388         }
389 
390         public void setVersionNumber(Long versionNumber) {
391 
392             this.versionNumber = versionNumber;
393         }
394 
395         public void setObjectId(String objectId) {
396 
397             this.objectId = objectId;
398         }
399 
400         public void setActive(boolean active) {
401 
402             this.active = active;
403         }
404 
405         public void setId(String id) {
406 
407             this.id = id;
408         }
409 
410         public void setEffectiveLocalDate(LocalDate effectiveLocalDate) {
411 
412             this.effectiveLocalDate = effectiveLocalDate;
413         }
414 
415         public void setCreateTime(DateTime createTime) {
416 
417             this.createTime = createTime;
418         }
419 
420         public void setUserPrincipalId(String userPrincipalId) {
421 
422             this.userPrincipalId = userPrincipalId;
423         }
424     }
425 
426 
427     /**
428      * Defines some internal constants used on this class.
429      * 
430      */
431     static class Constants {
432 
433         final static String ROOT_ELEMENT_NAME = "payStep";
434         final static String TYPE_NAME = "PayStepType";
435 
436     }
437 
438 
439     /**
440      * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML.
441      * 
442      */
443     static class Elements {
444 
445         final static String COMP_RATE = "compRate";
446         final static String STEP_NUMBER = "stepNumber";
447         final static String PAY_GRADE = "payGrade";
448         final static String PM_PAY_STEP_ID = "pmPayStepId";
449         final static String SERVICE_UNIT = "serviceUnit";
450         final static String PAY_STEP = "payStep";
451         final static String SALARY_GROUP = "salaryGroup";
452         final static String SERVICE_AMOUNT = "serviceAmount";
453         final static String ACTIVE = "active";
454         final static String ID = "id";
455         final static String EFFECTIVE_LOCAL_DATE = "effectiveLocalDate";
456         final static String CREATE_TIME = "createTime";
457         final static String USER_PRINCIPAL_ID = "userPrincipalId";
458 
459     }
460 
461 }