1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.student.common.kitchensink;
18
19 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
20 import org.kuali.rice.krad.maintenance.MaintainableImpl;
21 import org.kuali.rice.krad.maintenance.MaintenanceDocument;
22 import org.kuali.student.r2.common.dto.ContextInfo;
23 import org.kuali.student.r2.common.util.ContextUtils;
24 import org.kuali.student.r2.core.constants.PopulationServiceConstants;
25 import org.kuali.student.r2.core.population.dto.PopulationInfo;
26 import org.kuali.student.r2.core.population.service.PopulationService;
27
28 import javax.xml.namespace.QName;
29 import java.util.Map;
30
31
32
33
34
35
36 public class KitchenSinkPopulationInfoMaintainableImpl extends MaintainableImpl {
37
38 private transient PopulationService populationService;
39 private transient ContextInfo contextInfo;
40
41 @Override
42 public void saveDataObject() {
43 try {
44 PopulationInfo populationInfo = (PopulationInfo)getDataObject();
45
46 }
47 catch (Exception e) {
48 throw new RuntimeException(e);
49 }
50
51 }
52
53 @Override
54 public Object retrieveObjectForEditOrCopy(MaintenanceDocument document, Map<String, String> dataObjectKeys) {
55 try {
56 String populationId = dataObjectKeys.get("id");
57 PopulationInfo populationInfo = getPopulationService().getPopulation(populationId, getContextInfo());
58 return populationInfo;
59 }
60 catch (Exception e) {
61 throw new RuntimeException("Could not retrieve PopulationInfo for edit", e);
62 }
63 }
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83 private ContextInfo getContextInfo() {
84 if (null == contextInfo) {
85 contextInfo = ContextUtils.getContextInfo();
86 }
87 return contextInfo;
88 }
89
90 private PopulationService getPopulationService() {
91 if (populationService == null) {
92 populationService = (PopulationService) GlobalResourceLoader.getService(new QName(PopulationServiceConstants.NAMESPACE, "PopulationService"));
93 }
94 return populationService;
95 }
96
97 }