1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.hr.time.earngroup.service;
17
18 import org.kuali.hr.time.HrBusinessObject;
19 import org.kuali.hr.time.earngroup.EarnGroup;
20 import org.kuali.hr.time.earngroup.EarnGroupDefinition;
21 import org.kuali.hr.time.service.base.TkServiceLocator;
22 import org.kuali.hr.time.util.HrBusinessObjectMaintainableImpl;
23 import org.kuali.hr.time.util.ValidationUtils;
24 import org.kuali.rice.kns.document.MaintenanceDocument;
25 import org.kuali.rice.krad.util.GlobalVariables;
26 import org.kuali.rice.krad.util.KRADConstants;
27
28 import java.util.HashSet;
29 import java.util.Map;
30 import java.util.Set;
31
32 public class EarnGroupMaintainableImpl extends HrBusinessObjectMaintainableImpl{
33
34
35
36 private static final long serialVersionUID = 1L;
37
38 @Override
39 public void addNewLineToCollection(String collectionName) {
40 if (collectionName.equals("earnGroups")) {
41 EarnGroupDefinition definition = (EarnGroupDefinition)newCollectionLines.get(collectionName );
42 if ( definition != null ) {
43 EarnGroup earnGroup = (EarnGroup)this.getBusinessObject();
44 Set<String> earnCodes = new HashSet<String>();
45 for(EarnGroupDefinition earnGroupDef : earnGroup.getEarnGroups()){
46 earnCodes.add(earnGroupDef.getEarnCode());
47 }
48 if(earnCodes.contains(definition.getEarnCode())){
49 GlobalVariables.getMessageMap().putErrorWithoutFullErrorPath(KRADConstants.MAINTENANCE_NEW_MAINTAINABLE +"earnGroups",
50 "earngroup.duplicate.earncode",definition.getEarnCode());
51 return;
52 }
53 if (!ValidationUtils.validateEarnCode(definition.getEarnCode().toUpperCase(), earnGroup.getEffectiveDate())) {
54 GlobalVariables.getMessageMap().putErrorWithoutFullErrorPath(KRADConstants.MAINTENANCE_NEW_MAINTAINABLE +"earnGroups",
55 "error.existence", "Earncode '" + definition.getEarnCode()+ "'");
56 return;
57 }
58 }
59 }
60 super.addNewLineToCollection(collectionName);
61 }
62
63 @Override
64 public void processAfterEdit( MaintenanceDocument document, Map<String,String[]> parameters ) {
65 EarnGroup earnGroup = (EarnGroup)this.getBusinessObject();
66 int count = TkServiceLocator.getEarnGroupService().getNewerEarnGroupCount(earnGroup.getEarnGroup(), earnGroup.getEffectiveDate());
67 if(count > 0) {
68 GlobalVariables.getMessageMap().putWarningWithoutFullErrorPath(KRADConstants.MAINTENANCE_NEW_MAINTAINABLE + "effectiveDate",
69 "earngroup.effectiveDate.newr.exists");
70 }
71 }
72
73 @Override
74 public HrBusinessObject getObjectById(String id) {
75 return TkServiceLocator.getEarnGroupService().getEarnGroup(id);
76 }
77
78 }