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.time.rules.overtime.weekly.web;
17  
18  import java.math.BigDecimal;
19  import java.util.HashSet;
20  import java.util.Set;
21  
22  import org.kuali.kpme.tklm.time.rules.overtime.weekly.WeeklyOvertimeRule;
23  import org.kuali.kpme.tklm.time.rules.overtime.weekly.WeeklyOvertimeRuleGroup;
24  import org.kuali.rice.kns.maintenance.KualiMaintainableImpl;
25  import org.kuali.rice.krad.util.GlobalVariables;
26  import org.kuali.rice.krad.util.KRADConstants;
27  
28  public class WeeklyOvertimeRuleGroupMaintainableImpl extends KualiMaintainableImpl{
29  
30  	/**
31  	 * 
32  	 */
33  	private static final long serialVersionUID = 1L;
34  
35  
36  	@Override
37      public void addNewLineToCollection(String collectionName) {
38          if (collectionName.equals("lstWeeklyOvertimeRules")) {
39          	WeeklyOvertimeRule aRule = (WeeklyOvertimeRule)newCollectionLines.get(collectionName );
40              if ( aRule != null ) {
41              	WeeklyOvertimeRuleGroup aGroup = (WeeklyOvertimeRuleGroup)this.getBusinessObject();
42              	Set<BigDecimal> steps = new HashSet<BigDecimal>();
43              	for(WeeklyOvertimeRule wotr : aGroup.getLstWeeklyOvertimeRules()){
44              		steps.add(wotr.getStep());
45              	}
46              	if(steps.contains(aRule.getStep())){
47              		GlobalVariables.getMessageMap().putErrorWithoutFullErrorPath(KRADConstants.MAINTENANCE_NEW_MAINTAINABLE +"lstWeeklyOvertimeRules", 
48              				"weeklyOvertimeRule.duplicate.step",aRule.getStep().toString());
49              		return;
50      			} 
51              }
52          }
53         super.addNewLineToCollection(collectionName);
54      }
55  
56  }