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