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 |
19 |
|
|
|
|
| 0% |
Uncovered Elements: 42 (42) |
Complexity: 16 |
Complexity Density: 0.73 |
|
20 |
|
public class CredentialProgramDataService extends AbstractDataService { |
21 |
|
|
22 |
|
private static final long serialVersionUID = 1L; |
23 |
|
|
24 |
|
private ProgramService programService; |
25 |
|
private LuService luService; |
26 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
27 |
0
|
@Override... |
28 |
|
protected String getDefaultWorkflowDocumentType() { |
29 |
0
|
return null; |
30 |
|
} |
31 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
32 |
0
|
@Override... |
33 |
|
protected String getDefaultMetaDataState() { |
34 |
0
|
return null; |
35 |
|
} |
36 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 5 |
Complexity Density: 0.83 |
|
37 |
0
|
@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 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 5 |
Complexity Density: 0.5 |
|
52 |
0
|
@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 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
70 |
0
|
@Override... |
71 |
|
protected List<ValidationResultInfo> validate(Object dto) throws Exception { |
72 |
0
|
return programService.validateCredentialProgram("OBJECT", (CredentialProgramInfo)dto); |
73 |
|
} |
74 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
75 |
0
|
@Override... |
76 |
|
protected Class<?> getDtoClass() { |
77 |
0
|
return CredentialProgramInfo.class; |
78 |
|
} |
79 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
80 |
0
|
public void setProgramService(ProgramService programService) {... |
81 |
0
|
this.programService = programService; |
82 |
|
} |
83 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
84 |
0
|
public void setLuService(LuService luService) {... |
85 |
0
|
this.luService = luService; |
86 |
|
} |
87 |
|
} |