1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.coreservice.web.parameter;
17
18 import org.kuali.rice.coreservice.api.CoreServiceApiServiceLocator;
19 import org.kuali.rice.coreservice.api.parameter.Parameter;
20 import org.kuali.rice.coreservice.api.parameter.ParameterKey;
21 import org.kuali.rice.coreservice.api.parameter.ParameterRepositoryService;
22 import org.kuali.rice.coreservice.api.parameter.ParameterType;
23 import org.kuali.rice.coreservice.impl.parameter.ParameterBo;
24 import org.kuali.rice.kns.maintenance.KualiMaintainableImpl;
25
26 public class ParameterMaintainableImpl extends KualiMaintainableImpl {
27 private static final long serialVersionUID = 4914145799502207182L;
28
29 @Override
30 public void saveDataObject() {
31 if (super.getDataObject() instanceof ParameterBo) {
32 ParameterBo object = (ParameterBo)getDataObject();
33 Parameter param = null;
34
35
36
37 ParameterType.Builder parameterTypeBuilder =
38 ParameterType.Builder.create(object.getParameterTypeCode());
39
40 ParameterRepositoryService parameterRepository = CoreServiceApiServiceLocator.getParameterRepositoryService();
41
42 param = parameterRepository.getParameter(
43 ParameterKey.create(object.getApplicationId(),
44 object.getNamespaceCode(),
45 object.getComponentCode(),
46 object.getName()));
47
48
49
50
51
52
53 if(param == null || !object.getApplicationId().equals(param.getApplicationId())) {
54 param = parameterRepository.createParameter(Parameter.Builder.create(object.getApplicationId(),
55 object.getNamespaceCode(), object.getComponentCode(), object.getName(), parameterTypeBuilder
56
57
58 }
59
60 Parameter.Builder b = Parameter.Builder.create(param);
61 b.setValue(object.getValue());
62 b.setDescription(object.getDescription());
63 b.setEvaluationOperator(object.getEvaluationOperator());
64 b.setParameterType(parameterTypeBuilder);
65
66 parameterRepository.updateParameter(b.build());
67
68 } else {
69 throw new RuntimeException(
70 "Cannot update object of type: " + this.getDataObjectClass() + " with Parameter repository service");
71 }
72 }
73
74 }