1 | |
package org.kuali.rice.krms.impl.repository |
2 | |
|
3 | |
import java.util.Map.Entry; |
4 | |
|
5 | |
import org.kuali.rice.krad.bo.PersistableBusinessObjectBase |
6 | |
|
7 | |
import org.kuali.rice.krms.api.repository.action.ActionDefinition; |
8 | |
import org.kuali.rice.krms.api.repository.action.ActionDefinitionContract; |
9 | |
|
10 | |
public class ActionBo extends PersistableBusinessObjectBase implements ActionDefinitionContract { |
11 | |
|
12 | |
def String id |
13 | |
def String namespace |
14 | |
def String name |
15 | |
def String description |
16 | |
def String typeId |
17 | |
def String ruleId |
18 | |
def Integer sequenceNumber |
19 | |
|
20 | |
def Set<ActionAttributeBo> attributeBos |
21 | |
|
22 | |
public Map<String, String> getAttributes() { |
23 | 20 | HashMap<String, String> attributes = new HashMap<String, String>(); |
24 | 20 | for (attr in attributeBos) { |
25 | 20 | attributes.put( attr.attributeDefinition.name, attr.value ) |
26 | |
} |
27 | 20 | return attributes; |
28 | |
} |
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
static ActionDefinition to(ActionBo bo) { |
36 | 14 | if (bo == null) { return null } |
37 | 10 | return org.kuali.rice.krms.api.repository.action.ActionDefinition.Builder.create(bo).build() |
38 | |
} |
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
static ActionBo from(ActionDefinition im) { |
46 | 2 | if (im == null) { return null } |
47 | |
|
48 | 2 | ActionBo bo = new ActionBo() |
49 | 2 | bo.id = im.id |
50 | 2 | bo.namespace = im.namespace |
51 | 2 | bo.name = im.name |
52 | 2 | bo.typeId = im.typeId |
53 | 2 | bo.description = im.description |
54 | 2 | bo.ruleId = im.ruleId |
55 | 2 | bo.sequenceNumber = im.sequenceNumber |
56 | 2 | bo.versionNumber = im.versionNumber |
57 | |
|
58 | |
|
59 | 2 | Set<ActionAttributeBo> attrs = new HashSet<ActionAttributeBo>(); |
60 | |
|
61 | |
|
62 | 2 | ActionAttributeBo attributeBo; |
63 | 2 | for (Entry<String,String> entry : im.getAttributes().entrySet()){ |
64 | 2 | KrmsAttributeDefinitionBo attrDefBo = KrmsRepositoryServiceLocator |
65 | |
.getKrmsAttributeDefinitionService() |
66 | 2 | .getKrmsAttributeBo(entry.getKey(), im.getNamespace()); |
67 | 2 | attributeBo = new ActionAttributeBo(); |
68 | 2 | attributeBo.setActionId( im.getId() ); |
69 | 2 | attributeBo.setAttributeDefinitionId( attrDefBo.getId() ); |
70 | 2 | attributeBo.setValue( entry.getValue() ); |
71 | 2 | attributeBo.setAttributeDefinition( attrDefBo ); |
72 | 2 | attrs.add( attributeBo ); |
73 | |
} |
74 | 2 | bo.setAttributeBos(attrs); |
75 | 2 | return bo |
76 | |
} |
77 | |
|
78 | |
} |