Clover Coverage Report - Kuali Student 1.1 (Aggregated)
Coverage timestamp: Sun Mar 6 2011 20:32:39 EST
../../../../../../img/srcFileCovDistChart0.png 53% of files have more coverage
27   91   17   3.38
12   72   0.63   8
8     2.12  
1    
 
  MajorDisciplineDataService       Line # 17 27 0% 17 47 0% 0.0
 
No Tests
 
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 Igor
16    */
 
17    public class MajorDisciplineDataService 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    //TODO Just Major Discipline for now - need to check for other types later
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   
 
49  0 toggle @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   
 
67  0 toggle @Override
68    protected Class<?> getDtoClass() {
69  0 return MajorDisciplineInfo.class;
70    }
71   
 
72  0 toggle 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   
 
83  0 toggle public void setProgramService(ProgramService programService) {
84  0 this.programService = programService;
85    }
86   
 
87  0 toggle public void setLuService(LuService luService) {
88  0 this.luService = luService;
89    }
90   
91    }