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
017 package org.kuali.kfs.module.bc.businessobject;
018
019 import java.math.BigDecimal;
020 import java.sql.Date;
021 import java.util.HashMap;
022 import java.util.LinkedHashMap;
023 import java.util.List;
024 import java.util.Map;
025
026 import org.kuali.kfs.coa.businessobject.ResponsibilityCenter;
027 import org.kuali.kfs.module.bc.BCConstants;
028 import org.kuali.kfs.module.bc.util.BudgetParameterFinder;
029 import org.kuali.kfs.sys.KFSConstants.BudgetConstructionPositionConstants;
030 import org.kuali.kfs.sys.businessobject.SystemOptions;
031 import org.kuali.kfs.sys.context.SpringContext;
032 import org.kuali.rice.kns.bo.Inactivateable;
033 import org.kuali.rice.kns.bo.PersistableBusinessObjectBase;
034 import org.kuali.rice.kim.bo.Person;
035 import org.kuali.rice.kim.service.PersonService;
036 import org.kuali.rice.kns.util.KualiDecimal;
037 import org.kuali.rice.kns.util.TypedArrayList;
038
039
040 public class BudgetConstructionPosition extends PersistableBusinessObjectBase implements PendingBudgetConstructionAppointmentFundingAware, Position, Inactivateable {
041
042 private String positionNumber;
043 private Integer universityFiscalYear;
044 private Date positionEffectiveDate;
045 private String positionEffectiveStatus;
046 private String positionStatus;
047 private boolean budgetedPosition;
048 private boolean confidentialPosition;
049 private BigDecimal positionStandardHoursDefault;
050 private String positionRegularTemporary;
051 private BigDecimal positionFullTimeEquivalency;
052 private Integer iuNormalWorkMonths;
053 private Integer iuPayMonths;
054 private String positionDescription;
055 private String setidDepartment;
056 private String positionDepartmentIdentifier;
057 private String responsibilityCenterCode;
058 private String positionUnionCode;
059 private String positionSalaryPlanDefault;
060 private String positionGradeDefault;
061 private String setidJobCode;
062 private String jobCode;
063 private String jobCodeDescription;
064 private String setidSalary;
065 private String iuDefaultObjectCode;
066 private String iuPositionType;
067 private String positionLockUserIdentifier;
068 private boolean active;
069
070 private SystemOptions universityFiscal;
071 private List<PendingBudgetConstructionAppointmentFunding> pendingBudgetConstructionAppointmentFunding;
072 private List<BudgetConstructionPositionSelect> budgetConstructionPositionSelect;
073 private ResponsibilityCenter responsibilityCenter;
074 private Person positionLockUser;
075
076 /**
077 * Default constructor.
078 */
079 public BudgetConstructionPosition() {
080 budgetConstructionPositionSelect = new TypedArrayList(BudgetConstructionPositionSelect.class);
081 pendingBudgetConstructionAppointmentFunding = new TypedArrayList(PendingBudgetConstructionAppointmentFunding.class);
082 active = true; // assume active is true until set otherwise
083 }
084
085 /**
086 * Computes the positionFullTimeEquivalency attribute.
087 *
088 * @return Returns the compute positionFullTimeEquivalency
089 */
090 public static BigDecimal getCalculatedBCPositionFTE(BigDecimal positionStandardHoursDefault, Integer iuNormalWorkMonths, Integer iuPayMonths) {
091 if (iuPayMonths > 0) {
092 BigDecimal temp1 = positionStandardHoursDefault.divide(BudgetParameterFinder.getWeeklyWorkingHoursAsDecimal(), 4, KualiDecimal.ROUND_BEHAVIOR);
093 BigDecimal temp2 = new BigDecimal(iuNormalWorkMonths).divide(new BigDecimal(iuPayMonths), 4, KualiDecimal.ROUND_BEHAVIOR);
094 BigDecimal result = temp1.multiply(temp2);
095 result = result.setScale(2, KualiDecimal.ROUND_BEHAVIOR);
096 return result;
097 }
098 else {
099 return BigDecimal.ZERO;
100 }
101 }
102
103 /**
104 * Gets the positionNumber attribute.
105 *
106 * @return Returns the positionNumber
107 */
108 public String getPositionNumber() {
109 return positionNumber;
110 }
111
112 /**
113 * Sets the positionNumber attribute.
114 *
115 * @param positionNumber The positionNumber to set.
116 */
117 public void setPositionNumber(String positionNumber) {
118 this.positionNumber = positionNumber;
119 }
120
121 /**
122 * Gets the universityFiscalYear attribute.
123 *
124 * @return Returns the universityFiscalYear
125 */
126 public Integer getUniversityFiscalYear() {
127 return universityFiscalYear;
128 }
129
130 /**
131 * Sets the universityFiscalYear attribute.
132 *
133 * @param universityFiscalYear The universityFiscalYear to set.
134 */
135 public void setUniversityFiscalYear(Integer universityFiscalYear) {
136 this.universityFiscalYear = universityFiscalYear;
137 }
138
139 /**
140 * Gets the positionEffectiveDate attribute.
141 *
142 * @return Returns the positionEffectiveDate
143 */
144 public Date getPositionEffectiveDate() {
145 return positionEffectiveDate;
146 }
147
148 /**
149 * Sets the positionEffectiveDate attribute.
150 *
151 * @param positionEffectiveDate The positionEffectiveDate to set.
152 */
153 public void setPositionEffectiveDate(Date positionEffectiveDate) {
154 this.positionEffectiveDate = positionEffectiveDate;
155 }
156
157 /**
158 * Gets the positionEffectiveStatus attribute.
159 *
160 * @return Returns the positionEffectiveStatus.
161 */
162 public String getPositionEffectiveStatus() {
163 return (this.active ? BudgetConstructionPositionConstants.POSITION_EFFECTIVE_STATUS_ACTIVE : BudgetConstructionPositionConstants.POSITION_EFFECTIVE_STATUS_INACTIVE);
164 // return positionEffectiveStatus;
165 }
166
167 /**
168 * Sets the positionEffectiveStatus attribute value.
169 *
170 * @param positionEffectiveStatus The positionEffectiveStatus to set.
171 */
172 public void setPositionEffectiveStatus(String positionEffectiveStatus) {
173
174 // this.positionEffectiveStatus = positionEffectiveStatus;
175 this.active = Boolean.valueOf(BudgetConstructionPositionConstants.POSITION_EFFECTIVE_STATUS_ACTIVE.indexOf(positionEffectiveStatus) >= 0);
176 }
177
178 /**
179 * Gets the active attribute.
180 * @return Returns the active.
181 */
182 public boolean isActive() {
183 return active;
184 }
185
186 /**
187 * Sets the active attribute value.
188 * @param active The active to set.
189 */
190 public void setActive(boolean active) {
191 this.active = active;
192 }
193
194 /**
195 * Gets the positionStatus attribute.
196 *
197 * @return Returns the positionStatus.
198 */
199 public String getPositionStatus() {
200 return positionStatus;
201 }
202
203 /**
204 * Sets the positionStatus attribute value.
205 *
206 * @param positionStatus The positionStatus to set.
207 */
208 public void setPositionStatus(String positionStatus) {
209 this.positionStatus = positionStatus;
210 }
211
212 /**
213 * Gets the budgetedPosition attribute.
214 *
215 * @return Returns the budgetedPosition.
216 */
217 public boolean isBudgetedPosition() {
218 return budgetedPosition;
219 }
220
221 /**
222 * Sets the budgetedPosition attribute value.
223 *
224 * @param budgetedPosition The budgetedPosition to set.
225 */
226 public void setBudgetedPosition(boolean budgetedPosition) {
227 this.budgetedPosition = budgetedPosition;
228 }
229
230 /**
231 * Gets the confidentialPosition attribute.
232 *
233 * @return Returns the confidentialPosition.
234 */
235 public boolean isConfidentialPosition() {
236 return confidentialPosition;
237 }
238
239 /**
240 * Sets the confidentialPosition attribute value.
241 *
242 * @param confidentialPosition The confidentialPosition to set.
243 */
244 public void setConfidentialPosition(boolean confidentialPosition) {
245 this.confidentialPosition = confidentialPosition;
246 }
247
248 /**
249 * Gets the positionStandardHoursDefault attribute.
250 *
251 * @return Returns the positionStandardHoursDefault
252 */
253 public BigDecimal getPositionStandardHoursDefault() {
254 return positionStandardHoursDefault;
255 }
256
257 /**
258 * Sets the positionStandardHoursDefault attribute.
259 *
260 * @param positionStandardHoursDefault The positionStandardHoursDefault to set.
261 */
262 public void setPositionStandardHoursDefault(BigDecimal positionStandardHoursDefault) {
263 this.positionStandardHoursDefault = positionStandardHoursDefault;
264 }
265
266 /**
267 * Gets the positionRegularTemporary attribute.
268 *
269 * @return Returns the positionRegularTemporary
270 */
271 public String getPositionRegularTemporary() {
272 return positionRegularTemporary;
273 }
274
275 /**
276 * Sets the positionRegularTemporary attribute.
277 *
278 * @param positionRegularTemporary The positionRegularTemporary to set.
279 */
280 public void setPositionRegularTemporary(String positionRegularTemporary) {
281 this.positionRegularTemporary = positionRegularTemporary;
282 }
283
284 /**
285 * Gets the positionFullTimeEquivalency attribute.
286 *
287 * @return Returns the positionFullTimeEquivalency
288 */
289 public BigDecimal getPositionFullTimeEquivalency() {
290 return positionFullTimeEquivalency;
291 }
292
293 /**
294 * Sets the positionFullTimeEquivalency attribute.
295 *
296 * @param positionFullTimeEquivalency The positionFullTimeEquivalency to set.
297 */
298 public void setPositionFullTimeEquivalency(BigDecimal positionFullTimeEquivalency) {
299 this.positionFullTimeEquivalency = positionFullTimeEquivalency;
300 }
301
302 /**
303 * Gets the iuNormalWorkMonths attribute.
304 *
305 * @return Returns the iuNormalWorkMonths
306 */
307 public Integer getIuNormalWorkMonths() {
308 return iuNormalWorkMonths;
309 }
310
311 /**
312 * Sets the iuNormalWorkMonths attribute.
313 *
314 * @param iuNormalWorkMonths The iuNormalWorkMonths to set.
315 */
316 public void setIuNormalWorkMonths(Integer iuNormalWorkMonths) {
317 this.iuNormalWorkMonths = iuNormalWorkMonths;
318 }
319
320 /**
321 * Gets the iuPayMonths attribute.
322 *
323 * @return Returns the iuPayMonths
324 */
325 public Integer getIuPayMonths() {
326 return iuPayMonths;
327 }
328
329 /**
330 * Sets the iuPayMonths attribute.
331 *
332 * @param iuPayMonths The iuPayMonths to set.
333 */
334 public void setIuPayMonths(Integer iuPayMonths) {
335 this.iuPayMonths = iuPayMonths;
336 }
337
338 /**
339 * Gets the positionDescription attribute.
340 *
341 * @return Returns the positionDescription
342 */
343 public String getPositionDescription() {
344 return positionDescription;
345 }
346
347 /**
348 * Sets the positionDescription attribute.
349 *
350 * @param positionDescription The positionDescription to set.
351 */
352 public void setPositionDescription(String positionDescription) {
353 this.positionDescription = positionDescription;
354 }
355
356 /**
357 * Gets the setidDepartment attribute.
358 *
359 * @return Returns the setidDepartment
360 */
361 public String getSetidDepartment() {
362 return setidDepartment;
363 }
364
365 /**
366 * Sets the setidDepartment attribute.
367 *
368 * @param setidDepartment The setidDepartment to set.
369 */
370 public void setSetidDepartment(String setidDepartment) {
371 this.setidDepartment = setidDepartment;
372 }
373
374 /**
375 * Gets the positionDepartmentIdentifier attribute.
376 *
377 * @return Returns the positionDepartmentIdentifier
378 */
379 public String getPositionDepartmentIdentifier() {
380 return positionDepartmentIdentifier;
381 }
382
383 /**
384 * Sets the positionDepartmentIdentifier attribute.
385 *
386 * @param positionDepartmentIdentifier The positionDepartmentIdentifier to set.
387 */
388 public void setPositionDepartmentIdentifier(String positionDepartmentIdentifier) {
389 this.positionDepartmentIdentifier = positionDepartmentIdentifier;
390 }
391
392 /**
393 * Gets the responsibilityCenterCode attribute.
394 *
395 * @return Returns the responsibilityCenterCode
396 */
397 public String getResponsibilityCenterCode() {
398 return responsibilityCenterCode;
399 }
400
401 /**
402 * Sets the responsibilityCenterCode attribute.
403 *
404 * @param responsibilityCenterCode The responsibilityCenterCode to set.
405 */
406 public void setResponsibilityCenterCode(String responsibilityCenterCode) {
407 this.responsibilityCenterCode = responsibilityCenterCode;
408 }
409
410 /**
411 * Gets the positionUnionCode attribute.
412 *
413 * @return Returns the positionUnionCode
414 */
415 public String getPositionUnionCode() {
416 return positionUnionCode;
417 }
418
419 /**
420 * Sets the positionUnionCode attribute.
421 *
422 * @param positionUnionCode The positionUnionCode to set.
423 */
424 public void setPositionUnionCode(String positionUnionCode) {
425 this.positionUnionCode = positionUnionCode;
426 }
427
428 /**
429 * Gets the positionSalaryPlanDefault attribute.
430 *
431 * @return Returns the positionSalaryPlanDefault
432 */
433 public String getPositionSalaryPlanDefault() {
434 return positionSalaryPlanDefault;
435 }
436
437 /**
438 * Sets the positionSalaryPlanDefault attribute.
439 *
440 * @param positionSalaryPlanDefault The positionSalaryPlanDefault to set.
441 */
442 public void setPositionSalaryPlanDefault(String positionSalaryPlanDefault) {
443 this.positionSalaryPlanDefault = positionSalaryPlanDefault;
444 }
445
446 /**
447 * Gets the positionGradeDefault attribute.
448 *
449 * @return Returns the positionGradeDefault
450 */
451 public String getPositionGradeDefault() {
452 return positionGradeDefault;
453 }
454
455 /**
456 * Sets the positionGradeDefault attribute.
457 *
458 * @param positionGradeDefault The positionGradeDefault to set.
459 */
460 public void setPositionGradeDefault(String positionGradeDefault) {
461 this.positionGradeDefault = positionGradeDefault;
462 }
463
464 /**
465 * Gets the setidJobCode attribute.
466 *
467 * @return Returns the setidJobCode
468 */
469 public String getSetidJobCode() {
470 return setidJobCode;
471 }
472
473 /**
474 * Sets the setidJobCode attribute.
475 *
476 * @param setidJobCode The setidJobCode to set.
477 */
478 public void setSetidJobCode(String setidJobCode) {
479 this.setidJobCode = setidJobCode;
480 }
481
482 /**
483 * Gets the jobCode attribute.
484 *
485 * @return Returns the jobCode
486 */
487 public String getJobCode() {
488 return jobCode;
489 }
490
491 /**
492 * Sets the jobCode attribute.
493 *
494 * @param jobCode The jobCode to set.
495 */
496 public void setJobCode(String jobCode) {
497 this.jobCode = jobCode;
498 }
499
500 /**
501 * Gets the jobCodeDescription attribute.
502 *
503 * @return Returns the jobCodeDescription
504 */
505 public String getJobCodeDescription() {
506 return jobCodeDescription;
507 }
508
509 /**
510 * Sets the jobCodeDescription attribute.
511 *
512 * @param jobCodeDescription The jobCodeDescription to set.
513 */
514 public void setJobCodeDescription(String jobCodeDescription) {
515 this.jobCodeDescription = jobCodeDescription;
516 }
517
518 /**
519 * Gets the setidSalary attribute.
520 *
521 * @return Returns the setidSalary
522 */
523 public String getSetidSalary() {
524 return setidSalary;
525 }
526
527 /**
528 * Sets the setidSalary attribute.
529 *
530 * @param setidSalary The setidSalary to set.
531 */
532 public void setSetidSalary(String setidSalary) {
533 this.setidSalary = setidSalary;
534 }
535
536 /**
537 * Gets the iuDefaultObjectCode attribute.
538 *
539 * @return Returns the iuDefaultObjectCode
540 */
541 public String getIuDefaultObjectCode() {
542 return iuDefaultObjectCode;
543 }
544
545 /**
546 * Sets the iuDefaultObjectCode attribute.
547 *
548 * @param iuDefaultObjectCode The iuDefaultObjectCode to set.
549 */
550 public void setIuDefaultObjectCode(String iuDefaultObjectCode) {
551 this.iuDefaultObjectCode = iuDefaultObjectCode;
552 }
553
554 /**
555 * Gets the iuPositionType attribute.
556 *
557 * @return Returns the iuPositionType
558 */
559 public String getIuPositionType() {
560 return iuPositionType;
561 }
562
563 /**
564 * Sets the iuPositionType attribute.
565 *
566 * @param iuPositionType The iuPositionType to set.
567 */
568 public void setIuPositionType(String iuPositionType) {
569 this.iuPositionType = iuPositionType;
570 }
571
572 /**
573 * Gets the positionLockUserIdentifier attribute.
574 *
575 * @return Returns the positionLockUserIdentifier
576 */
577 public String getPositionLockUserIdentifier() {
578 return positionLockUserIdentifier;
579 }
580
581 /**
582 * Sets the positionLockUserIdentifier attribute.
583 *
584 * @param positionLockUserIdentifier The positionLockUserIdentifier to set.
585 */
586 public void setPositionLockUserIdentifier(String positionLockUserIdentifier) {
587 this.positionLockUserIdentifier = positionLockUserIdentifier;
588 }
589
590 /**
591 * Gets the responsibilityCenter attribute.
592 *
593 * @return Returns the responsibilityCenter.
594 */
595 public ResponsibilityCenter getResponsibilityCenter() {
596 return responsibilityCenter;
597 }
598
599 /**
600 * Sets the responsibilityCenter attribute value.
601 *
602 * @param responsibilityCenter The responsibilityCenter to set.
603 * @deprecated
604 */
605 public void setResponsibilityCenter(ResponsibilityCenter responsibilityCenter) {
606 this.responsibilityCenter = responsibilityCenter;
607 }
608
609 /**
610 * Gets the positionLockUser attribute value.
611 *
612 * @return Returns the positionLockUser
613 */
614 public Person getPositionLockUser() {
615 if (positionLockUserIdentifier != null) {
616 positionLockUser = SpringContext.getBean(org.kuali.rice.kim.service.PersonService.class).updatePersonIfNecessary(positionLockUserIdentifier, positionLockUser);
617 }
618 return positionLockUser;
619 }
620
621 /**
622 * Sets the positionLockUser attribute.
623 *
624 * @param positionLockUser The positionLockUser to set.
625 * @deprecated
626 */
627 public void setPositionLockUser(Person positionLockUser) {
628 this.positionLockUser = positionLockUser;
629 }
630
631 /**
632 * Gets the universityFiscal attribute.
633 *
634 * @return Returns the universityFiscal.
635 */
636 public SystemOptions getUniversityFiscal() {
637 return universityFiscal;
638 }
639
640 /**
641 * Sets the universityFiscal attribute value.
642 *
643 * @param universityFiscal The universityFiscal to set.
644 */
645 public void setUniversityFiscal(SystemOptions universityFiscal) {
646 this.universityFiscal = universityFiscal;
647 }
648
649 /**
650 * @see org.kuali.rice.kns.bo.PersistableBusinessObjectBase#buildListOfDeletionAwareLists()
651 */
652 @Override
653 public List buildListOfDeletionAwareLists() {
654
655 List managedLists = super.buildListOfDeletionAwareLists();
656 managedLists.add(getPendingBudgetConstructionAppointmentFunding());
657 return managedLists;
658 }
659
660 /**
661 * Returns a map with the primitive field names as the key and the primitive values as the map value.
662 *
663 * @return Map
664 */
665 public Map getValuesMap() {
666 Map simpleValues = new HashMap();
667
668 simpleValues.put("positionNumber", getPositionNumber());
669 simpleValues.put("universityFiscalYear", getUniversityFiscalYear());
670
671 return simpleValues;
672 }
673
674 /**
675 * @see org.kuali.rice.kns.bo.BusinessObjectBase#toStringMapper()
676 */
677 protected LinkedHashMap toStringMapper() {
678 LinkedHashMap m = new LinkedHashMap();
679 m.put("positionNumber", this.positionNumber);
680 if (this.universityFiscalYear != null) {
681 m.put("universityFiscalYear", this.universityFiscalYear.toString());
682 }
683 return m;
684 }
685
686 /**
687 * determine whether the current budget position is effective
688 *
689 * @return true if the current budget position is effective; otherwise, false
690 */
691 public boolean isEffective() {
692 return !BCConstants.POSITION_CODE_INACTIVE.equals(this.getPositionEffectiveStatus());
693 }
694
695 /**
696 * Gets the pendingBudgetConstructionAppointmentFunding attribute.
697 *
698 * @return Returns the pendingBudgetConstructionAppointmentFunding.
699 */
700 public List<PendingBudgetConstructionAppointmentFunding> getPendingBudgetConstructionAppointmentFunding() {
701 return pendingBudgetConstructionAppointmentFunding;
702 }
703
704 /**
705 * Sets the pendingBudgetConstructionAppointmentFunding attribute value.
706 *
707 * @param pendingBudgetConstructionAppointmentFunding The pendingBudgetConstructionAppointmentFunding to set.
708 */
709 @Deprecated
710 public void setPendingBudgetConstructionAppointmentFunding(List<PendingBudgetConstructionAppointmentFunding> pendingBudgetConstructionAppointmentFunding) {
711 this.pendingBudgetConstructionAppointmentFunding = pendingBudgetConstructionAppointmentFunding;
712 }
713
714 /**
715 * Gets the budgetConstructionPositionSelect attribute.
716 *
717 * @return Returns the budgetConstructionPositionSelect.
718 */
719 public List<BudgetConstructionPositionSelect> getBudgetConstructionPositionSelect() {
720 return budgetConstructionPositionSelect;
721 }
722
723 /**
724 * Sets the budgetConstructionPositionSelect attribute value.
725 *
726 * @param budgetConstructionPositionSelect The budgetConstructionPositionSelect to set.
727 */
728 @Deprecated
729 public void setBudgetConstructionPositionSelect(List<BudgetConstructionPositionSelect> budgetConstructionPositionSelect) {
730 this.budgetConstructionPositionSelect = budgetConstructionPositionSelect;
731 }
732
733 }
734