Clover Coverage Report - Kuali Student 1.1.0-M10-SNAPSHOT (Aggregated)
Coverage timestamp: Fri Dec 17 2010 05:04:51 EST
../../../../../../img/srcFileCovDistChart0.png 53% of files have more coverage
40   120   19   5
16   97   0.47   8
8     2.38  
1    
 
  CoreProgramDataService       Line # 26 40 0% 19 64 0% 0.0
 
No Tests
 
1    package org.kuali.student.lum.program.server;
2   
3    import java.util.ArrayList;
4    import java.util.List;
5    import java.util.Map;
6   
7    import org.kuali.student.common.ui.server.gwt.AbstractDataService;
8    import org.kuali.student.core.exceptions.DoesNotExistException;
9    import org.kuali.student.core.exceptions.InvalidParameterException;
10    import org.kuali.student.core.exceptions.MissingParameterException;
11    import org.kuali.student.core.exceptions.OperationFailedException;
12    import org.kuali.student.core.exceptions.PermissionDeniedException;
13    import org.kuali.student.core.search.dto.SearchParam;
14    import org.kuali.student.core.search.dto.SearchRequest;
15    import org.kuali.student.core.search.dto.SearchResult;
16    import org.kuali.student.core.search.dto.SearchResultCell;
17    import org.kuali.student.core.search.dto.SearchResultRow;
18    import org.kuali.student.lum.lu.service.LuService;
19    import org.kuali.student.lum.program.client.ProgramClientConstants;
20    import org.kuali.student.lum.program.dto.CoreProgramInfo;
21    import org.kuali.student.lum.program.service.ProgramService;
22   
23    /**
24    * @author Jim
25    */
 
26    public class CoreProgramDataService extends AbstractDataService {
27   
28    private static final long serialVersionUID = 1L;
29   
30    private ProgramService programService;
31    private LuService luService;
32   
 
33  0 toggle @Override
34    protected String getDefaultWorkflowDocumentType() {
35  0 return null;
36    }
37   
 
38  0 toggle @Override
39    protected String getDefaultMetaDataState() {
40  0 return null;
41    }
42   
 
43  0 toggle @Override
44    protected Object get(String id) throws Exception {
45  0 if (id==null || id.isEmpty()){
46  0 return findCurrentCoreProgram();
47    } else {
48  0 return programService.getCoreProgram(id);
49    }
50   
51    }
52   
 
53  0 toggle @Override
54    protected Object save(Object dto, Map<String, Object> properties) throws Exception {
55  0 if (dto instanceof CoreProgramInfo) {
56  0 CoreProgramInfo cpInfo = (CoreProgramInfo) dto;
57  0 if (cpInfo.getId() == null && cpInfo.getVersionInfo() != null) {
58  0 String coreVersionIndId = cpInfo.getVersionInfo().getVersionIndId();
59  0 cpInfo = programService.createNewCoreProgramVersion(coreVersionIndId, "New core program version");
60  0 } else if (cpInfo.getId() == null) {
61  0 cpInfo = programService.createCoreProgram(cpInfo);
62    } else {
63  0 cpInfo = programService.updateCoreProgram(cpInfo);
64    }
65  0 return cpInfo;
66    } else {
67  0 throw new InvalidParameterException("Only persistence of CoreProgram is supported by this DataService implementation.");
68    }
69    }
70   
 
71  0 toggle @Override
72    protected Class<?> getDtoClass() {
73  0 return CoreProgramInfo.class;
74    }
75   
 
76  0 toggle private CoreProgramInfo findCurrentCoreProgram() throws MissingParameterException, InvalidParameterException, DoesNotExistException, PermissionDeniedException, OperationFailedException {
77  0 SearchRequest request = new SearchRequest();
78   
79    //TODO find a better way to get this search, param and resultcolumn names
80   
81  0 CoreProgramInfo core = new CoreProgramInfo();
82  0 String coreProgramId = null;
83  0 request.setSearchKey("lu.search.mostCurrent.union");
84   
85  0 List<SearchParam> searchParams = new ArrayList<SearchParam>();
86  0 SearchParam qpv1 = new SearchParam();
87  0 qpv1.setKey("lu.queryParam.luOptionalType");
88  0 qpv1.setValue(ProgramClientConstants.CORE_PROGRAM);
89  0 searchParams.add(qpv1);
90   
91  0 request.setParams(searchParams);
92   
93  0 SearchResult searchResult = luService.search(request);
94  0 if (searchResult.getRows().size() > 0) {
95  0 for(SearchResultRow srrow : searchResult.getRows()){
96  0 List<SearchResultCell> srCells = srrow.getCells();
97  0 if(srCells != null && srCells.size() > 0){
98  0 for(SearchResultCell srcell : srCells){
99  0 if (srcell.getKey().equals("lu.resultColumn.cluId")) {
100  0 coreProgramId = srcell.getValue();
101  0 break;
102    }
103    }
104    }
105    }
106    }
107  0 if (coreProgramId != null) {
108  0 core = programService.getCoreProgram(coreProgramId);
109    }
110  0 return core;
111    }
112   
 
113  0 toggle public void setProgramService(ProgramService programService) {
114  0 this.programService = programService;
115    }
116   
 
117  0 toggle public void setLuService(LuService luService) {
118  0 this.luService = luService;
119    }
120    }