| 1 |  |   | 
  | 2 |  |   | 
  | 3 |  |   | 
  | 4 |  |   | 
  | 5 |  |   | 
  | 6 |  |   | 
  | 7 |  |   | 
  | 8 |  |   | 
  | 9 |  |   | 
  | 10 |  |   | 
  | 11 |  |   | 
  | 12 |  |   | 
  | 13 |  |   | 
  | 14 |  |   | 
  | 15 |  |   | 
  | 16 |  |  package org.kuali.student.lum.common.server; | 
  | 17 |  |   | 
  | 18 |  |  import org.kuali.student.common.exceptions.DoesNotExistException; | 
  | 19 |  |  import org.kuali.student.common.exceptions.InvalidParameterException; | 
  | 20 |  |  import org.kuali.student.common.ui.server.gwt.AbstractDataService; | 
  | 21 |  |  import org.kuali.student.common.validation.dto.ValidationResultInfo; | 
  | 22 |  |  import org.kuali.student.lum.lo.dto.LoCategoryInfo; | 
  | 23 |  |  import org.kuali.student.lum.lo.dto.LoInfo; | 
  | 24 |  |  import org.kuali.student.lum.lo.service.LearningObjectiveService; | 
  | 25 |  |   | 
  | 26 |  |  import org.kuali.student.lum.program.dto.MajorDisciplineInfo; | 
  | 27 |  |   | 
  | 28 |  |  import java.util.List; | 
  | 29 |  |  import java.util.Map; | 
  | 30 |  |   | 
  | 31 | 0 |  public class LoCategoryDataService extends AbstractDataService { | 
  | 32 |  |   | 
  | 33 |  |      private static final long serialVersionUID = 1L; | 
  | 34 |  |       | 
  | 35 |  |      private LearningObjectiveService loService; | 
  | 36 |  |   | 
  | 37 |  |      @Override | 
  | 38 |  |      protected String getDefaultWorkflowDocumentType() { | 
  | 39 | 0 |          return null; | 
  | 40 |  |      } | 
  | 41 |  |   | 
  | 42 |  |      @Override | 
  | 43 |  |      protected String getDefaultMetaDataState() { | 
  | 44 | 0 |          return null; | 
  | 45 |  |      } | 
  | 46 |  |   | 
  | 47 |  |      @Override | 
  | 48 |  |      protected Object get(String id) throws Exception { | 
  | 49 |  |   | 
  | 50 |  |           | 
  | 51 |  |          Object returnDTO ; | 
  | 52 |  |   | 
  | 53 |  |          try { | 
  | 54 | 0 |              returnDTO = loService.getLoCategory(id); | 
  | 55 |  |          } | 
  | 56 | 0 |          catch (DoesNotExistException e) { | 
  | 57 | 0 |              throw new InvalidParameterException("Only LoCategoryInfo supported by this DataService implementation."); | 
  | 58 | 0 |          } | 
  | 59 | 0 |          return  returnDTO; | 
  | 60 |  |      } | 
  | 61 |  |   | 
  | 62 |  |      @Override | 
  | 63 |  |      protected Object save(Object dto, Map<String, Object> properties) throws Exception { | 
  | 64 | 0 |          if (dto instanceof LoCategoryInfo) { | 
  | 65 | 0 |              LoCategoryInfo loCatInfo = (LoCategoryInfo) dto; | 
  | 66 | 0 |              if (loCatInfo.getId() == null ) { | 
  | 67 | 0 |                      loCatInfo = loService.createLoCategory(loCatInfo.getLoRepository(), loCatInfo.getType(), loCatInfo); | 
  | 68 |  |              } else { | 
  | 69 | 0 |                  loCatInfo = loService.updateLoCategory(loCatInfo.getId(), loCatInfo); | 
  | 70 |  |              } | 
  | 71 | 0 |              return loCatInfo; | 
  | 72 |  |          } else  { | 
  | 73 | 0 |              throw new InvalidParameterException("Only LoCategoryInfo supported by this DataService implementation."); | 
  | 74 |  |          } | 
  | 75 |  |      } | 
  | 76 |  |   | 
  | 77 |  |      @Override | 
  | 78 |  |          protected List<ValidationResultInfo> validate(Object dto) throws Exception { | 
  | 79 | 0 |                  return loService.validateLoCategory("OBJECT", (LoCategoryInfo)dto); | 
  | 80 |  |          } | 
  | 81 |  |   | 
  | 82 |  |          @Override | 
  | 83 |  |      protected Class<?> getDtoClass() { | 
  | 84 | 0 |          return LoCategoryInfo.class; | 
  | 85 |  |      } | 
  | 86 |  |   | 
  | 87 |  |      public void setLearningObjectiveService(LearningObjectiveService loService) { | 
  | 88 | 0 |          this.loService = loService; | 
  | 89 | 0 |      } | 
  | 90 |  |   | 
  | 91 |  |   | 
  | 92 |  |  } |