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