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 |
16 |
|
|
|
|
| 0% |
Uncovered Elements: 40 (40) |
Complexity: 15 |
Complexity Density: 0.71 |
|
17 |
|
public class CredentialProgramDataService extends AbstractDataService { |
18 |
|
|
19 |
|
private static final long serialVersionUID = 1L; |
20 |
|
|
21 |
|
private ProgramService programService; |
22 |
|
private LuService luService; |
23 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
24 |
0
|
@Override... |
25 |
|
protected String getDefaultWorkflowDocumentType() { |
26 |
0
|
return null; |
27 |
|
} |
28 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
29 |
0
|
@Override... |
30 |
|
protected String getDefaultMetaDataState() { |
31 |
0
|
return null; |
32 |
|
} |
33 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 5 |
Complexity Density: 0.83 |
|
34 |
0
|
@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 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 5 |
Complexity Density: 0.5 |
|
49 |
0
|
@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 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
67 |
0
|
@Override... |
68 |
|
protected Class<?> getDtoClass() { |
69 |
0
|
return CredentialProgramInfo.class; |
70 |
|
} |
71 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
72 |
0
|
public void setProgramService(ProgramService programService) {... |
73 |
0
|
this.programService = programService; |
74 |
|
} |
75 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
76 |
0
|
public void setLuService(LuService luService) {... |
77 |
0
|
this.luService = luService; |
78 |
|
} |
79 |
|
} |