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.tklm.leave.accrual.bucket;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import org.kuali.kpme.core.api.accrualcategory.AccrualCategory;
22  import org.kuali.kpme.core.principal.PrincipalHRAttributesBo;
23  import org.kuali.kpme.tklm.api.leave.accrual.bucket.BasicLeaveBalanceContract;
24  import org.kuali.kpme.tklm.api.leave.block.LeaveBlock;
25  import org.kuali.kpme.tklm.leave.accrual.bucket.exception.MaximumBalanceException;
26  import org.kuali.kpme.tklm.leave.accrual.bucket.exception.NegativeBalanceException;
27  import org.kuali.kpme.tklm.leave.accrual.bucket.exception.UsageLimitException;
28  
29  public class BasicLeaveBalance extends LeaveBalance implements BasicLeaveBalanceContract {
30  
31  	private List<LeaveBlock> leaveBlocks;
32  
33  	public BasicLeaveBalance(AccrualCategory accrualCategory, PrincipalHRAttributesBo principalCalendar) {
34  		super(accrualCategory, principalCalendar);
35  		leaveBlocks = new ArrayList<LeaveBlock>();
36  	}
37  
38  	private final static String BALANCE_TYPE = "BASIC_BALANCE";
39  	
40  	@Override
41  	public void add(LeaveBlock leaveBlock) throws UsageLimitException,
42  			MaximumBalanceException, NegativeBalanceException {
43  		add(leaveBlock.getLeaveAmount());
44  		
45  		leaveBlocks.add(leaveBlock);
46  	}
47  
48  	@Override
49  	public void remove(LeaveBlock leaveBlock) throws UsageLimitException,
50  			MaximumBalanceException, NegativeBalanceException {
51  		remove(leaveBlock.getLeaveAmount());
52  		
53  		leaveBlocks.remove(leaveBlock);
54  	}
55  
56  	@Override
57  	public String getBalanceType() {
58  		return BALANCE_TYPE;
59  	}
60  
61  	@Override
62  	public void adjust(LeaveBlock leaveBlock) throws UsageLimitException,
63  			MaximumBalanceException, NegativeBalanceException {
64  		// TODO Auto-generated method stub
65  		
66  	}
67  
68  	@Override
69  	public void clear() {
70  		leaveBlocks.clear();
71  		super.clear();
72  	}
73  
74  }