001 package org.kuali.rice.krms.dto;
002
003 import org.kuali.rice.core.api.util.tree.Tree;
004 import org.kuali.rice.krad.web.form.UifFormBase;
005 import org.kuali.rice.krms.api.repository.action.ActionDefinitionContract;
006 import org.kuali.rice.krms.api.repository.proposition.PropositionDefinitionContract;
007 import org.kuali.rice.krms.api.repository.rule.RuleDefinition;
008 import org.kuali.rice.krms.api.repository.rule.RuleDefinitionContract;
009 import org.kuali.rice.krms.tree.node.CompareTreeNode;
010 import org.kuali.rice.krms.tree.node.RuleEditorTreeNode;
011 import org.kuali.rice.krms.tree.node.TreeNode;
012 import org.kuali.rice.krms.util.AlphaIterator;
013
014 import java.io.Serializable;
015 import java.util.Date;
016 import java.util.List;
017 import java.util.Map;
018
019 /**
020 * Created with IntelliJ IDEA.
021 * User: SW
022 * Date: 2012/12/03
023 * Time: 3:45 PM
024 * To change this template use File | Settings | File Templates.
025 */
026 public class RuleEditor extends UifFormBase implements RuleDefinitionContract, Serializable {
027
028 private static final long serialVersionUID = 1L;
029
030 private String key;
031
032 private String id;
033 private String namespace;
034 private String description;
035 private String name;
036 private String typeId;
037 private String propId;
038 private boolean active = true;
039 private Long versionNumber;
040
041 private PropositionEditor proposition;
042
043 private String ruleType;
044 private String copyKey;
045 private String selectedKey;
046 private String cutKey;
047 private boolean dummy;
048 private List<String> activeSelections;
049
050 //Edit with Logic
051 private String logicArea;
052 private String selectedTab;
053
054 // for Rule editor display
055 private Tree<RuleEditorTreeNode, String> editTree;
056
057 // for Rule Preview display
058 private Tree<TreeNode, String> previewTree;
059 private Tree<TreeNode, String> viewTree;
060 private transient AlphaIterator alpha;
061
062 // for Compare
063 private Tree<CompareTreeNode, String> compareTree;
064
065 //Rule Instruction
066 private String ruleInstruction;
067
068 private RuleTypeInfo ruleTypeInfo;
069
070 public RuleEditor() {
071 super();
072 }
073
074 public RuleEditor(RuleDefinitionContract definition) {
075 this.id = definition.getId();
076 this.namespace = definition.getNamespace();
077 this.name = definition.getName();
078 this.description = definition.getDescription();
079 this.typeId = definition.getTypeId();
080 this.propId = definition.getPropId();
081 this.active = definition.isActive();
082 this.proposition = createPropositionEditor(definition.getProposition());
083 this.versionNumber = definition.getVersionNumber();
084
085 //TODO: Actions
086 //this.actions = new ArrayList<ActionBo>();
087 //for (ActionDefinition action : im.getActions()){
088 //this.actions.add( ActionBo.from(action) );
089 //}
090
091 //TODO: build the set of agenda attribute BOs
092 //List<RuleAttributeBo> attrs = new ArrayList<RuleAttributeBo>();
093 //this.setAttributeBos(attrs);
094 }
095
096 public String getKey() {
097 return key;
098 }
099
100 public void setKey(String key) {
101 this.key = key;
102 }
103
104 public void setId(String id) {
105 this.id = id;
106 }
107
108 public void setDescription(String description) {
109 this.description = description;
110 }
111
112 public void setProposition(PropositionEditor proposition) {
113 this.proposition = proposition;
114 }
115
116 public void setPropId(String propId) {
117 this.propId = propId;
118 }
119
120 public void setTypeId(String typeId) {
121 this.typeId = typeId;
122 }
123
124 public void setActive(boolean active) {
125 this.active = active;
126 }
127
128 public void setName(String name) {
129 this.name = name;
130 }
131
132 public void setNamespace(String namespace) {
133 this.namespace = namespace;
134 }
135
136 public String getRuleType() {
137 return ruleType;
138 }
139
140 public void setRuleType(String ruleType) {
141 this.ruleType = ruleType;
142 }
143
144 public List<String> getActiveSelections() {
145 return activeSelections;
146 }
147
148 public void setActiveSelections(List<String> activeSelections) {
149 this.activeSelections = activeSelections;
150 }
151
152 public AlphaIterator getAlpha() {
153 if (alpha == null){
154 alpha = new AlphaIterator();
155 }
156 return alpha;
157 }
158
159 public void setAlpha(AlphaIterator alpha) {
160 this.alpha = alpha;
161 }
162
163 /**
164 * @return the selectedKey
165 */
166 public String getSelectedKey() {
167 return this.selectedKey;
168 }
169
170 /**
171 * @param selectedKey the selectedKey to set
172 */
173 public void setSelectedKey(String selectedKey) {
174 this.selectedKey = selectedKey;
175 }
176
177 /**
178 * @return the cutKey
179 */
180 public String getCutKey() {
181 return cutKey;
182 }
183
184 public void setCutKey(String cutKey) {
185 this.cutKey = cutKey;
186 }
187
188 public boolean isDummy() {
189 return dummy;
190 }
191
192 public void setDummy(boolean dummy) {
193 this.dummy = dummy;
194 }
195
196 /**
197 * @return the copyKey
198 */
199 public String getCopyKey() {
200 return copyKey;
201 }
202
203 /**
204 * @param copyKey the copyKey to set
205 */
206 public void setCopyKey(String copyKey) {
207 this.copyKey = copyKey;
208 }
209
210 public String getLogicArea() {
211 return logicArea;
212 }
213
214 public void setLogicArea(String logicArea) {
215 this.logicArea = logicArea;
216 }
217
218 @Override
219 public String getName() {
220 return this.name;
221 }
222
223 @Override
224 public String getDescription() {
225 return this.description;
226 }
227
228 @Override
229 public String getNamespace() {
230 return this.namespace;
231 }
232
233 @Override
234 public String getTypeId() {
235 return this.typeId;
236 }
237
238 @Override
239 public String getPropId() {
240 return this.propId;
241 }
242
243 @Override
244 public PropositionDefinitionContract getProposition() {
245 return proposition;
246 }
247
248 @Override
249 public List<? extends ActionDefinitionContract> getActions() {
250 return null; //To change body of implemented methods use File | Settings | File Templates.
251 }
252
253 @Override
254 public Map<String, String> getAttributes() {
255 return null; //To change body of implemented methods use File | Settings | File Templates.
256 }
257
258 @Override
259 public String getId() {
260 return this.id;
261 }
262
263 @Override
264 public boolean isActive() {
265 return this.active;
266 }
267
268 public Tree<RuleEditorTreeNode, String> getEditTree() {
269 return editTree;
270 }
271
272 public void setEditTree(Tree<RuleEditorTreeNode, String> editTree) {
273 this.editTree = editTree;
274 }
275
276 public Tree<TreeNode, String> getPreviewTree() {
277 return previewTree;
278 }
279
280 public void setPreviewTree(Tree<TreeNode, String> previewTree) {
281 this.previewTree = previewTree;
282 }
283
284
285 public Tree<TreeNode, String> getViewTree() {
286 return viewTree;
287 }
288
289 public void setViewTree(Tree<TreeNode, String> viewTree) {
290 this.viewTree = viewTree;
291 }
292
293
294 public Tree<CompareTreeNode, String> getCompareTree() {
295 return compareTree;
296 }
297
298 public void setCompareTree(Tree<CompareTreeNode, String> compareTree) {
299 this.compareTree = compareTree;
300 }
301
302 public void setVersionNumber(Long versionNumber) {
303 this.versionNumber = versionNumber;
304 }
305
306 @Override
307 public Long getVersionNumber() {
308 return versionNumber;
309 }
310
311 public String getSelectedTab() {
312 return selectedTab;
313 }
314
315 public void setSelectedTab(String selectedTab) {
316 this.selectedTab = selectedTab;
317 }
318
319 public String getRuleInstruction() {
320 return ruleInstruction;
321 }
322
323 public void setRuleInstruction(String ruleInstruction) {
324 this.ruleInstruction = ruleInstruction;
325 }
326
327 protected PropositionEditor createPropositionEditor(PropositionDefinitionContract definition){
328 return new PropositionEditor(definition);
329 }
330
331 public RuleTypeInfo getRuleTypeInfo() {
332 return ruleTypeInfo;
333 }
334
335 public void setRuleTypeInfo(RuleTypeInfo ruleTypeInfo) {
336 this.ruleTypeInfo = ruleTypeInfo;
337 }
338 }