1 package org.kuali.student.r2.common.util;
2
3 import org.kuali.student.r2.core.atp.service.AtpService;
4 import org.kuali.student.enrollment.acal.service.AcademicCalendarService;
5 import org.kuali.student.enrollment.lpr.service.LprService;
6 import org.kuali.student.enrollment.lui.service.LuiService;
7 import org.kuali.student.r2.common.exceptions.InvalidParameterException;
8 import org.kuali.student.r2.core.constants.AtpServiceConstants;
9 import org.kuali.student.r2.common.util.constants.LprServiceConstants;
10 import org.kuali.student.r2.common.util.constants.LuiServiceConstants;
11
12 import java.util.Arrays;
13
14 public class KSKeyGenerator {
15
16
17
18
19
20
21
22
23
24 public static String generateKey(final String serviceName, final String dtoName, final String atpUniqueIdentifier )throws InvalidParameterException {
25
26 String key= null;
27
28 String [] namesArrayAtpType = new String[]{AcademicCalendarService.class.getName(), AtpService.class.getName()};
29 String[] namesArrayLuiType = new String[] {LuiService.class.getName()};
30 String[] namesArrayLPRType = new String[] {LprService.class.getName()};
31
32 if(Arrays.asList(namesArrayAtpType).contains(serviceName)){
33
34 key = AtpServiceConstants.ATP_KEY_PREFIX;
35
36 }else if(Arrays.asList( namesArrayLuiType ).contains(serviceName)){
37 key = LuiServiceConstants.LUI_KEY_PREFIX;
38 }else if(Arrays.asList( namesArrayLPRType ).contains(serviceName)){
39 key = LprServiceConstants.LPR_KEY_PREFIX;
40 }
41
42 if(key!=null){
43 key=key+"."+dtoName+"."+atpUniqueIdentifier;
44 }else{
45 throw new InvalidParameterException("Check if the service is defined in the names array");
46 }
47
48
49 return key;
50 }
51 }