1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.krms.impl.repository |
17 | |
|
18 | |
import org.kuali.rice.krad.bo.PersistableBusinessObjectBase |
19 | |
|
20 | |
import org.kuali.rice.krms.api.repository.term.TermDefinition; |
21 | |
import org.kuali.rice.krms.api.repository.term.TermDefinitionContract |
22 | |
import java.util.Map.Entry |
23 | |
import org.kuali.rice.krms.api.repository.term.TermParameterDefinition; |
24 | |
|
25 | |
|
26 | |
public class TermBo extends PersistableBusinessObjectBase implements TermDefinitionContract { |
27 | |
|
28 | |
def String id |
29 | |
def String specificationId |
30 | |
def String description |
31 | |
|
32 | |
|
33 | 0 | def TermSpecificationBo specification = new TermSpecificationBo() |
34 | |
|
35 | |
def List<TermParameterBo> parameters |
36 | 0 | def Map<String, String> parametersMap = new HashMap<String, String>() |
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
static TermDefinition to(TermBo bo) { |
44 | 0 | if (bo == null) { return null } |
45 | 0 | return org.kuali.rice.krms.api.repository.term.TermDefinition.Builder.create(bo).build() |
46 | |
} |
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
static TermBo from(TermDefinition im) { |
54 | 0 | if (im == null) { return null } |
55 | |
|
56 | 0 | TermBo bo = new TermBo() |
57 | 0 | bo.id = im.id |
58 | 0 | bo.specificationId = im.specification.id |
59 | 0 | bo.description = im.description |
60 | 0 | bo.specification = TermSpecificationBo.from(im.specification) |
61 | 0 | bo.parameters = new ArrayList<TermParameterBo>() |
62 | 0 | for (parm in im.parameters){ |
63 | 0 | bo.parameters.add ( TermParameterBo.from(parm) ) |
64 | |
} |
65 | 0 | bo.versionNumber = im.versionNumber |
66 | 0 | return bo |
67 | |
} |
68 | |
|
69 | |
public TermSpecificationBo getSpecification(){ |
70 | 0 | return specification |
71 | |
} |
72 | |
|
73 | |
public List<TermParameterBo> getParameters(){ |
74 | 0 | return parameters |
75 | |
} |
76 | |
|
77 | |
public void exportToParametersMap() { |
78 | |
|
79 | |
|
80 | 0 | if (parameters != null) for (TermParameterBo param : parameters) { |
81 | 0 | parametersMap.put(param.name, param.value); |
82 | |
} |
83 | |
|
84 | |
} |
85 | |
|
86 | |
public void importFromParametersMap() { |
87 | |
|
88 | 0 | if (parameters == null) { |
89 | 0 | parameters = new ArrayList<TermParameterBo>() |
90 | |
} else { |
91 | 0 | parameters.clear(); |
92 | |
} |
93 | |
|
94 | 0 | for (Entry<String, String> paramEntry : parametersMap.entrySet()) { |
95 | 0 | TermParameterDefinition termDef = TermParameterDefinition.Builder.create(null, id, paramEntry.key, paramEntry.value).build(); |
96 | 0 | parameters.add(TermParameterBo.from(termDef)); |
97 | |
} |
98 | |
|
99 | |
} |
100 | |
|
101 | |
} |