Coverage Report - org.kuali.student.lum.program.server.MajorDisciplineDataService
 
Classes in this File Line Coverage Branch Coverage Complexity
MajorDisciplineDataService
0%
0/23
0%
0/12
2.143
 
 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.ui.server.gwt.AbstractDataService;
 9  
 import org.kuali.student.common.validation.dto.ValidationResultInfo;
 10  
 import org.kuali.student.lum.program.client.ProgramClientConstants;
 11  
 import org.kuali.student.lum.program.dto.MajorDisciplineInfo;
 12  
 import org.kuali.student.lum.program.service.ProgramService;
 13  
 
 14  
 /**
 15  
  * @author Igor
 16  
  */
 17  0
 public class MajorDisciplineDataService extends AbstractDataService {
 18  
 
 19  
     private static final long serialVersionUID = 1L;
 20  
     
 21  
     private ProgramService programService;
 22  
 
 23  
     @Override
 24  
     protected String getDefaultWorkflowDocumentType() {
 25  0
         return null;
 26  
     }
 27  
 
 28  
     @Override
 29  
     protected String getDefaultMetaDataState() {
 30  0
         return null;
 31  
     }
 32  
 
 33  
     @Override
 34  
     protected Object get(String id) throws Exception {
 35  
             //TODO Just Major Discipline for now - need to check for other types later
 36  
         MajorDisciplineInfo returnDTO;
 37  0
         if (null == id || id.length() == 0) {
 38  0
             returnDTO = new MajorDisciplineInfo();
 39  0
             returnDTO.setType(ProgramClientConstants.MAJOR_PROGRAM);
 40  0
             returnDTO.setState(DtoConstants.STATE_DRAFT);
 41  
         } else {
 42  0
             returnDTO = programService.getMajorDiscipline(id);
 43  
         }
 44  0
         return returnDTO;
 45  
     }
 46  
 
 47  
     @Override
 48  
     protected Object save(Object dto, Map<String, Object> properties) throws Exception {
 49  0
         if (dto instanceof MajorDisciplineInfo) {
 50  0
             MajorDisciplineInfo mdInfo = (MajorDisciplineInfo) dto;
 51  0
             if (mdInfo.getId() == null && mdInfo.getVersionInfo() != null) {
 52  0
                     String majorVersionIndId = mdInfo.getVersionInfo().getVersionIndId();
 53  0
                     mdInfo = programService.createNewMajorDisciplineVersion(majorVersionIndId, "New major discipline version");
 54  0
             } else if (mdInfo.getId() == null){
 55  0
                 mdInfo = programService.createMajorDiscipline(mdInfo);
 56  
             } else {
 57  0
                 mdInfo = programService.updateMajorDiscipline(mdInfo);
 58  
             }
 59  0
             return mdInfo;
 60  
         } else {
 61  0
             throw new InvalidParameterException("Only persistence of MajorDiscipline is supported by this DataService implementation.");
 62  
         }
 63  
     }  
 64  
 
 65  
     
 66  
     @Override
 67  
         protected List<ValidationResultInfo> validate(Object dto) throws Exception {
 68  0
                 return programService.validateMajorDiscipline("OBJECT", (MajorDisciplineInfo)dto);
 69  
         }
 70  
 
 71  
         @Override
 72  
     protected Class<?> getDtoClass() {
 73  0
         return MajorDisciplineInfo.class;
 74  
     }
 75  
 
 76  
     public void setProgramService(ProgramService programService) {
 77  0
         this.programService = programService;
 78  0
     }
 79  
 
 80  
 }