1 package org.kuali.rice.krms.impl.repository;
2
3 import org.kuali.rice.core.api.criteria.QueryByCriteria;
4 import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
5 import org.kuali.rice.krad.data.DataObjectService;
6 import org.kuali.rice.krad.data.PersistenceOption;
7 import org.kuali.rice.krms.api.repository.term.TermDefinition;
8 import org.kuali.rice.krms.impl.util.KrmsImplConstants;
9
10
11
12
13
14 public class TempFixTermBoServiceImpl extends TermBoServiceImpl {
15
16 protected DataObjectService dataObjectService;
17
18 @Override
19 public void setDataObjectService(DataObjectService dataObjectService) {
20 this.dataObjectService = dataObjectService;
21 super.setDataObjectService(dataObjectService);
22 }
23
24 @Override
25 public void updateTerm(TermDefinition term) throws RiceIllegalArgumentException {
26 if (term == null) {
27 throw new IllegalArgumentException("term is null");
28 }
29
30
31 final String termId = term.getId();
32 final TermBo existing = dataObjectService.find(TermBo.class, termId);
33
34 if (existing == null) {
35 throw new IllegalStateException("the term resolver does not exist: " + term);
36 }
37
38 final TermDefinition toUpdate;
39
40 if (!existing.getId().equals(term.getId())) {
41
42 final TermDefinition.Builder builder = TermDefinition.Builder.create(term);
43 builder.setId(existing.getId());
44 toUpdate = builder.build();
45 } else {
46 toUpdate = term;
47 }
48
49
50 TermBo boToUpdate = TermBo.from(toUpdate);
51
52
53
54
55
56
57
58
59 dataObjectService.save(boToUpdate, PersistenceOption.FLUSH);
60 }
61 }