View Javadoc

1   package org.kuali.rice.krms.dto;
2   
3   import org.kuali.rice.core.api.util.tree.Tree;
4   import org.kuali.rice.krad.web.form.UifFormBase;
5   import org.kuali.rice.krms.api.repository.action.ActionDefinitionContract;
6   import org.kuali.rice.krms.api.repository.proposition.PropositionDefinitionContract;
7   import org.kuali.rice.krms.api.repository.rule.RuleDefinition;
8   import org.kuali.rice.krms.api.repository.rule.RuleDefinitionContract;
9   import org.kuali.rice.krms.tree.node.CompareTreeNode;
10  import org.kuali.rice.krms.tree.node.RuleEditorTreeNode;
11  import org.kuali.rice.krms.tree.node.TreeNode;
12  import org.kuali.rice.krms.util.AlphaIterator;
13  
14  import java.io.Serializable;
15  import java.util.Date;
16  import java.util.List;
17  import java.util.Map;
18  
19  /**
20   * Created with IntelliJ IDEA.
21   * User: SW
22   * Date: 2012/12/03
23   * Time: 3:45 PM
24   * To change this template use File | Settings | File Templates.
25   */
26  public class RuleEditor extends UifFormBase implements RuleDefinitionContract, Serializable {
27  
28      private static final long serialVersionUID = 1L;
29  
30      private String key;
31  
32      private String id;
33      private String namespace;
34      private String description;
35      private String name;
36      private String typeId;
37      private String propId;
38      private boolean active = true;
39      private Long versionNumber;
40  
41      private PropositionEditor proposition;
42  
43      private String ruleType;
44      private String copyKey;
45      private String selectedKey;
46      private String cutKey;
47      private boolean dummy;
48      private List<String> activeSelections;
49  
50      //Edit with Logic
51      private String logicArea;
52      private String selectedTab;
53  
54      // for Rule editor display
55      private Tree<RuleEditorTreeNode, String> editTree;
56  
57      // for Rule Preview display
58      private Tree<TreeNode, String> previewTree;
59      private Tree<TreeNode, String> viewTree;
60      private transient AlphaIterator alpha;
61  
62      // for Compare
63      private Tree<CompareTreeNode, String> compareTree;
64  
65      //Rule Instruction
66      private String ruleInstruction;
67  
68      private RuleTypeInfo ruleTypeInfo;
69  
70      public RuleEditor() {
71          super();
72      }
73  
74      public RuleEditor(RuleDefinitionContract definition) {
75          this.id = definition.getId();
76          this.namespace = definition.getNamespace();
77          this.name = definition.getName();
78          this.description = definition.getDescription();
79          this.typeId = definition.getTypeId();
80          this.propId = definition.getPropId();
81          this.active = definition.isActive();
82          this.proposition = createPropositionEditor(definition.getProposition());
83          this.versionNumber = definition.getVersionNumber();
84  
85          //TODO: Actions
86          //this.actions = new ArrayList<ActionBo>();
87          //for (ActionDefinition action : im.getActions()){
88          //this.actions.add( ActionBo.from(action) );
89          //}
90  
91          //TODO: build the set of agenda attribute BOs
92          //List<RuleAttributeBo> attrs = new ArrayList<RuleAttributeBo>();
93          //this.setAttributeBos(attrs);
94      }
95  
96      public String getKey() {
97          return key;
98      }
99  
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 }