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 java.util.Map.Entry |
19 | |
|
20 | |
import org.kuali.rice.krad.bo.PersistableBusinessObjectBase |
21 | |
import org.kuali.rice.krms.api.repository.context.ContextDefinition; |
22 | |
import org.kuali.rice.krms.api.repository.context.ContextDefinitionContract; |
23 | |
|
24 | |
|
25 | |
public class ContextBo extends PersistableBusinessObjectBase implements ContextDefinitionContract { |
26 | |
|
27 | |
String id |
28 | |
String name |
29 | |
String namespace |
30 | |
String typeId |
31 | |
String description |
32 | |
|
33 | 0 | List<AgendaBo> agendas = new ArrayList<AgendaBo>() |
34 | |
|
35 | 0 | List<ContextAttributeBo> attributeBos = new ArrayList<ContextAttributeBo>() |
36 | 0 | List<ContextValidEventBo> validEvents = new ArrayList<ContextValidEventBo>() |
37 | 0 | List<ContextValidActionBo> validActions = new ArrayList<ContextValidActionBo>() |
38 | |
|
39 | |
Long versionNumber |
40 | |
|
41 | |
|
42 | |
@Override |
43 | |
public List<AgendaBo> getAgendas(){ |
44 | 0 | return agendas |
45 | |
} |
46 | |
|
47 | |
@Override |
48 | |
public Map<String, String> getAttributes() { |
49 | 0 | Map<String, String> attributes = new HashMap<String, String>(); |
50 | 0 | for (attr in attributeBos) { |
51 | 0 | attributes.put( attr.attributeDefinition.name, attr.value ) |
52 | |
} |
53 | 0 | return attributes; |
54 | |
} |
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
static ContextDefinition to(ContextBo bo) { |
62 | 0 | if (bo == null) { return null } |
63 | 0 | return org.kuali.rice.krms.api.repository.context.ContextDefinition.Builder.create(bo).build() |
64 | |
} |
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
static ContextBo from(ContextDefinition im) { |
72 | 0 | if (im == null) { return null } |
73 | |
|
74 | 0 | ContextBo bo = new ContextBo() |
75 | 0 | bo.id = im.id |
76 | 0 | bo.namespace = im.namespace |
77 | 0 | bo.name = im.name |
78 | 0 | bo.typeId = im.typeId |
79 | 0 | bo.description = im.description |
80 | 0 | bo.agendas = new ArrayList<AgendaBo>() |
81 | 0 | for (agenda in im.agendas){ |
82 | 0 | bo.agendas.add( AgendaBo.from(agenda) ) |
83 | |
} |
84 | |
|
85 | 0 | List<ContextAttributeBo> attrs = new ArrayList<ContextAttributeBo>(); |
86 | |
|
87 | |
|
88 | 0 | ContextAttributeBo attributeBo; |
89 | 0 | for (Entry<String,String> entry : im.getAttributes().entrySet()){ |
90 | 0 | KrmsAttributeDefinitionBo attrDefBo = KrmsRepositoryServiceLocator |
91 | |
.getKrmsAttributeDefinitionService() |
92 | 0 | .getKrmsAttributeBo(entry.getKey(), im.getNamespace()); |
93 | 0 | attributeBo = new ContextAttributeBo(); |
94 | 0 | attributeBo.setContextId( im.getId() ); |
95 | 0 | attributeBo.setAttributeDefinitionId( attrDefBo.getId() ); |
96 | 0 | attributeBo.setValue( entry.getValue() ); |
97 | 0 | attributeBo.setAttributeDefinition( attrDefBo ); |
98 | 0 | attrs.add( attributeBo ); |
99 | |
} |
100 | 0 | bo.setAttributeBos(attrs); |
101 | |
|
102 | 0 | bo.versionNumber = im.versionNumber |
103 | 0 | return bo |
104 | |
} |
105 | |
} |