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
19
20 import org.kuali.rice.coreservice.api.parameter.Parameter;
21 import org.kuali.rice.coreservice.api.parameter.ParameterType;
22 import org.kuali.rice.coreservice.framework.CoreFrameworkServiceLocator;
23 import org.kuali.rice.coreservice.impl.parameter.ParameterBo;
24 import org.kuali.rice.kns.maintenance.KualiMaintainableImpl;
25
26 public class ParameterMaintenableImpl 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
34 Parameter param = null;
35 if(CoreFrameworkServiceLocator.getParameterService().parameterExists(object.getNamespaceCode(), object.getComponentCode(), object.getName())){
36 param = CoreFrameworkServiceLocator.getParameterService().getParameter(object.getNamespaceCode(),object.getComponentCode(),object.getName()) ;
37 }else{
38 ParameterType.Builder builder = ParameterType.Builder.create(object.getParameterTypeCode());
39 param = CoreFrameworkServiceLocator.getParameterService().createParameter(Parameter.Builder.create(object.getApplicationId(),
40 object.getNamespaceCode(),object.getComponentCode(), object.getName(), builder).build());
41 }
42 Parameter.Builder b = Parameter.Builder.create(param);
43 b.setValue(object.getValue());
44 b.setDescription(object.getDescription());
45 b.setEvaluationOperator(object.getEvaluationOperator());
46 b.setVersionNumber(object.getVersionNumber());
47 CoreFrameworkServiceLocator.getParameterService().updateParameter(b.build()) ;
48
49
50
51 } else {
52 throw new RuntimeException(
53 "Cannot update object of type: " + this.getDataObjectClass() + " with Parameter service");
54 }
55 }
56
57 }