Clover Coverage Report - Kuali Student 1.2-M4-SNAPSHOT (Aggregated)
Coverage timestamp: Wed Jul 20 2011 11:14:35 EDT
../../../../../../img/srcFileCovDistChart0.png 41% of files have more coverage
22   87   16   2.75
12   71   0.73   8
8     2  
1    
 
  CredentialProgramDataService       Line # 20 22 0% 16 42 0% 0.0
 
No Tests
 
1    package org.kuali.student.lum.program.server;
2   
3    import java.util.List;
4    import java.util.Map;
5   
6    import org.kuali.student.common.dto.DtoConstants;
7    import org.kuali.student.common.exceptions.InvalidParameterException;
8    import org.kuali.student.common.exceptions.OperationFailedException;
9    import org.kuali.student.common.ui.server.gwt.AbstractDataService;
10    import org.kuali.student.common.validation.dto.ValidationResultInfo;
11    import org.kuali.student.lum.lu.service.LuService;
12    import org.kuali.student.lum.program.client.ProgramClientConstants;
13    import org.kuali.student.lum.program.dto.CredentialProgramInfo;
14    import org.kuali.student.lum.program.dto.MajorDisciplineInfo;
15    import org.kuali.student.lum.program.service.ProgramService;
16   
17    /**
18    * @author Igor
19    */
 
20    public class CredentialProgramDataService extends AbstractDataService {
21   
22    private static final long serialVersionUID = 1L;
23   
24    private ProgramService programService;
25    private LuService luService;
26   
 
27  0 toggle @Override
28    protected String getDefaultWorkflowDocumentType() {
29  0 return null;
30    }
31   
 
32  0 toggle @Override
33    protected String getDefaultMetaDataState() {
34  0 return null;
35    }
36   
 
37  0 toggle @Override
38    protected Object get(String id) throws Exception {
39  0 if (ProgramClientConstants.CREDENTIAL_PROGRAM_TYPES.contains(id)){
40  0 List<String> credIds = luService.getCluIdsByLuType(id, DtoConstants.STATE_ACTIVE);
41  0 if (null == credIds || credIds.size() != 1) {
42  0 throw new OperationFailedException("A single credential program of type " + id + " is required; database contains " +
43  0 (null == credIds ? "0" : credIds.size() +
44    "."));
45    }
46  0 return programService.getCredentialProgram(credIds.get(0));
47    } else {
48  0 return programService.getCredentialProgram(id);
49    }
50    }
51   
 
52  0 toggle @Override
53    protected Object save(Object dto, Map<String, Object> properties) throws Exception {
54  0 if (dto instanceof CredentialProgramInfo) {
55  0 CredentialProgramInfo cpInfo = (CredentialProgramInfo) dto;
56  0 if (cpInfo.getId() == null && cpInfo.getVersionInfo() != null) {
57  0 String credentialVersionIndId = cpInfo.getVersionInfo().getVersionIndId();
58  0 cpInfo = programService.createNewCredentialProgramVersion(credentialVersionIndId, "New credential program version");
59  0 } else if (cpInfo.getId() == null) {
60  0 cpInfo = programService.createCredentialProgram(cpInfo);
61    } else {
62  0 cpInfo = programService.updateCredentialProgram(cpInfo);
63    }
64  0 return cpInfo;
65    } else {
66  0 throw new InvalidParameterException("Only persistence of CredentialProgram is supported by this DataService implementation.");
67    }
68    }
69   
 
70  0 toggle @Override
71    protected List<ValidationResultInfo> validate(Object dto) throws Exception {
72  0 return programService.validateCredentialProgram("OBJECT", (CredentialProgramInfo)dto);
73    }
74   
 
75  0 toggle @Override
76    protected Class<?> getDtoClass() {
77  0 return CredentialProgramInfo.class;
78    }
79   
 
80  0 toggle public void setProgramService(ProgramService programService) {
81  0 this.programService = programService;
82    }
83   
 
84  0 toggle public void setLuService(LuService luService) {
85  0 this.luService = luService;
86    }
87    }