Coverage Report - org.kuali.student.common.dictionary.service.impl.DictionaryServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
DictionaryServiceImpl
0%
0/23
0%
0/2
1.125
 
 1  
 package org.kuali.student.common.dictionary.service.impl;
 2  
 
 3  
 import java.util.ArrayList;
 4  
 import java.util.HashMap;
 5  
 import java.util.List;
 6  
 import java.util.Map;
 7  
 
 8  
 import org.kuali.student.common.dictionary.dto.ObjectStructureDefinition;
 9  
 import org.kuali.student.common.dictionary.service.DictionaryService;
 10  
 import org.springframework.context.ApplicationContext;
 11  
 import org.springframework.context.ConfigurableApplicationContext;
 12  
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 13  
 import org.springframework.util.StringUtils;
 14  
 
 15  
 public class DictionaryServiceImpl implements DictionaryService{
 16  
         private String[] dictionaryContext;
 17  
         private Map<String, ObjectStructureDefinition> objectStructures;
 18  
 
 19  
         public DictionaryServiceImpl() {
 20  0
                 super();
 21  0
                 init();
 22  0
         }
 23  
 
 24  
         public DictionaryServiceImpl(String dictionaryContext) {
 25  0
                 super();
 26  0
                 String[] locations = StringUtils.tokenizeToStringArray(dictionaryContext, ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS);
 27  0
                 this.dictionaryContext = locations;
 28  0
                 init();
 29  0
         }
 30  
         
 31  
         public DictionaryServiceImpl(String[] dictionaryContext) {
 32  0
                 super();
 33  0
                 this.dictionaryContext = dictionaryContext;
 34  0
                 init();
 35  0
         }
 36  
 
 37  
         @SuppressWarnings("unchecked")
 38  
         public void init() {
 39  0
                 ApplicationContext ac = new ClassPathXmlApplicationContext(dictionaryContext);
 40  
 
 41  0
                 Map<String, ObjectStructureDefinition> beansOfType = (Map<String, ObjectStructureDefinition>) ac.getBeansOfType(ObjectStructureDefinition.class);
 42  0
                 objectStructures = new HashMap<String, ObjectStructureDefinition>();
 43  0
                 for (ObjectStructureDefinition objStr : beansOfType.values()){
 44  0
                         objectStructures.put(objStr.getName(), objStr);
 45  
                 }
 46  0
         }
 47  
 
 48  
         @Override
 49  
         public ObjectStructureDefinition getObjectStructure(String objectTypeKey) {
 50  0
                 return objectStructures.get(objectTypeKey);        
 51  
         }
 52  
 
 53  
         @Override
 54  
         public List<String> getObjectTypes() {
 55  0
                 return new ArrayList<String>(objectStructures.keySet());
 56  
         }
 57  
 
 58  
         public String[] getDictionaryContext() {
 59  0
                 return dictionaryContext;
 60  
         }
 61  
 
 62  
         public void setDictionaryContext(String[] dictionaryContext) {
 63  0
                 this.dictionaryContext = dictionaryContext;
 64  0
         }
 65  
 }