Coverage Report - org.kuali.student.r2.common.util.KSKeyGenerator
 
Classes in this File Line Coverage Branch Coverage Complexity
KSKeyGenerator
0%
0/15
0%
0/8
6
 
 1  
 package org.kuali.student.r2.common.util;
 2  
 
 3  
 import org.kuali.student.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.common.util.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  0
 public class KSKeyGenerator  {
 15  
 
 16  
         /**
 17  
          * 
 18  
          * @param serviceName the name of the service that the create method is invoked on, for all class II services having the same base class I service the key will have same prefix
 19  
          * @param dtoName the DTO for which the name is being created, for e,g Terms will be named like FALL, SPRING, SUMMER  etc
 20  
          * @param atpUniqueIdentifier  convenient readable identifier, terms  or academic calendar could have year and month etc, LUIs could have coursename+year 
 21  
 
 22  
          * @return
 23  
          */
 24  
         public static String generateKey(final String serviceName, final String dtoName, final String atpUniqueIdentifier )throws InvalidParameterException {
 25  
                 
 26  0
                 String key= null; 
 27  
                 
 28  0
                 String [] namesArrayAtpType = new String[]{AcademicCalendarService.class.getName(), AtpService.class.getName()};
 29  0
                 String[] namesArrayLuiType = new String[] {LuiService.class.getName()};
 30  0
                 String[] namesArrayLPRType = new String[] {LprService.class.getName()};
 31  
                 
 32  0
                 if(Arrays.asList(namesArrayAtpType).contains(serviceName)){
 33  
                         
 34  0
                         key = AtpServiceConstants.ATP_KEY_PREFIX;
 35  
                         
 36  0
                 }else if(Arrays.asList( namesArrayLuiType ).contains(serviceName)){
 37  0
                         key = LuiServiceConstants.LUI_KEY_PREFIX;
 38  0
                 }else if(Arrays.asList( namesArrayLPRType ).contains(serviceName)){
 39  0
                         key = LprServiceConstants.LPR_KEY_PREFIX;
 40  
                 }
 41  
                 
 42  0
                 if(key!=null){
 43  0
                         key=key+"."+dtoName+"."+atpUniqueIdentifier;
 44  
                 }else{
 45  0
                         throw new InvalidParameterException("Check if the service is defined in the names array");
 46  
                 }
 47  
                 
 48  
                 
 49  0
                 return key;
 50  
         }
 51  
 }