| 1 |
|
package org.kuali.student.lum.program.server; |
| 2 |
|
|
| 3 |
|
import org.kuali.student.common.ui.server.gwt.AbstractDataService; |
| 4 |
|
import org.kuali.student.core.exceptions.InvalidParameterException; |
| 5 |
|
import org.kuali.student.core.exceptions.OperationFailedException; |
| 6 |
|
import org.kuali.student.lum.lu.service.LuService; |
| 7 |
|
import org.kuali.student.lum.program.client.ProgramClientConstants; |
| 8 |
|
import org.kuali.student.lum.program.dto.MajorDisciplineInfo; |
| 9 |
|
import org.kuali.student.lum.program.service.ProgramService; |
| 10 |
|
|
| 11 |
|
import java.util.List; |
| 12 |
|
import java.util.Map; |
| 13 |
|
|
| 14 |
|
|
| 15 |
|
@author |
| 16 |
|
|
|
|
|
| 0% |
Uncovered Elements: 47 (47) |
Complexity: 17 |
Complexity Density: 0.63 |
|
| 17 |
|
public class MajorDisciplineDataService 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: 10 (10) |
Complexity: 3 |
Complexity Density: 0.38 |
|
| 34 |
0
|
@Override... |
| 35 |
|
protected Object get(String id) throws Exception { |
| 36 |
|
|
| 37 |
0
|
MajorDisciplineInfo returnDTO; |
| 38 |
0
|
if (null == id || id.length() == 0) { |
| 39 |
0
|
returnDTO = new MajorDisciplineInfo(); |
| 40 |
0
|
returnDTO.setType(ProgramClientConstants.MAJOR_PROGRAM); |
| 41 |
0
|
returnDTO.setState(ProgramClientConstants.STATE_DRAFT); |
| 42 |
0
|
returnDTO.setCredentialProgramId(getCredentialId()); |
| 43 |
|
} else { |
| 44 |
0
|
returnDTO = programService.getMajorDiscipline(id); |
| 45 |
|
} |
| 46 |
0
|
return returnDTO; |
| 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 MajorDisciplineInfo) { |
| 52 |
0
|
MajorDisciplineInfo mdInfo = (MajorDisciplineInfo) dto; |
| 53 |
0
|
if (mdInfo.getId() == null && mdInfo.getVersionInfo() != null) { |
| 54 |
0
|
String majorVersionIndId = mdInfo.getVersionInfo().getVersionIndId(); |
| 55 |
0
|
mdInfo = programService.createNewMajorDisciplineVersion(majorVersionIndId, "New major discipline version"); |
| 56 |
0
|
} else if (mdInfo.getId() == null){ |
| 57 |
0
|
mdInfo = programService.createMajorDiscipline(mdInfo); |
| 58 |
|
} else { |
| 59 |
0
|
mdInfo = programService.updateMajorDiscipline(mdInfo); |
| 60 |
|
} |
| 61 |
0
|
return mdInfo; |
| 62 |
|
} else { |
| 63 |
0
|
throw new InvalidParameterException("Only persistence of MajorDiscipline 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 MajorDisciplineInfo.class; |
| 70 |
|
} |
| 71 |
|
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 4 |
Complexity Density: 1 |
|
| 72 |
0
|
private String getCredentialId() throws Exception {... |
| 73 |
|
|
| 74 |
0
|
List<String> credIds = luService.getCluIdsByLuType(ProgramClientConstants.CREDENTIAL_BACCALAUREATE_PROGRAM, ProgramClientConstants.STATE_ACTIVE); |
| 75 |
0
|
if (null == credIds || credIds.size() != 1) { |
| 76 |
0
|
throw new OperationFailedException("A single credential program of type " + ProgramClientConstants.CREDENTIAL_BACCALAUREATE_PROGRAM + " is required; database contains " + |
| 77 |
0
|
(null == credIds ? "0" : credIds.size() + |
| 78 |
|
".")); |
| 79 |
|
} |
| 80 |
0
|
return credIds.get(0); |
| 81 |
|
} |
| 82 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 83 |
0
|
public void setProgramService(ProgramService programService) {... |
| 84 |
0
|
this.programService = programService; |
| 85 |
|
} |
| 86 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 87 |
0
|
public void setLuService(LuService luService) {... |
| 88 |
0
|
this.luService = luService; |
| 89 |
|
} |
| 90 |
|
|
| 91 |
|
} |