| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.krms.impl.ui; |
| 17 | |
|
| 18 | |
import org.kuali.rice.core.api.util.tree.Node; |
| 19 | |
import org.kuali.rice.core.api.util.tree.Tree; |
| 20 | |
import org.kuali.rice.krad.bo.PersistableBusinessObjectBase; |
| 21 | |
import org.kuali.rice.krms.impl.repository.AgendaBo; |
| 22 | |
import org.kuali.rice.krms.impl.repository.AgendaItemBo; |
| 23 | |
import org.kuali.rice.krms.impl.repository.ContextBo; |
| 24 | |
|
| 25 | |
import java.util.List; |
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
public class AgendaEditor extends PersistableBusinessObjectBase { |
| 35 | |
|
| 36 | |
private static final long serialVersionUID = 1L; |
| 37 | |
|
| 38 | |
private ContextBo context; |
| 39 | |
private AgendaBo agenda; |
| 40 | |
private AgendaItemBo agendaItemLine; |
| 41 | |
private String selectedAgendaItemId; |
| 42 | |
|
| 43 | 0 | public AgendaEditor() { |
| 44 | 0 | agendaItemLine = new AgendaItemBo(); |
| 45 | 0 | } |
| 46 | |
|
| 47 | |
private void addAgendaItemAndChildren(Node<AgendaTreeNode, String> parent, AgendaItemBo agendaItem) { |
| 48 | 0 | Node<AgendaTreeNode, String> child = new Node<AgendaTreeNode, String>(); |
| 49 | 0 | child.setNodeLabel(agendaItem.getRuleText()); |
| 50 | 0 | child.setNodeType("agendaNode ruleNode"); |
| 51 | 0 | child.setData(new AgendaTreeRuleNode(agendaItem)); |
| 52 | 0 | parent.getChildren().add(child); |
| 53 | |
|
| 54 | |
|
| 55 | 0 | if (agendaItem.getAlways() != null) addAgendaItemAndChildren(parent, agendaItem.getAlways()); |
| 56 | |
|
| 57 | |
|
| 58 | 0 | if (agendaItem.getWhenTrue() != null) { |
| 59 | 0 | Node<AgendaTreeNode, String> whenTrue = new Node<AgendaTreeNode, String>(); |
| 60 | 0 | whenTrue.setNodeLabel("When TRUE"); |
| 61 | 0 | whenTrue.setNodeType("agendaNode logicNode whenTrueNode"); |
| 62 | 0 | whenTrue.setData(new AgendaTreeLogicNode()); |
| 63 | 0 | child.getChildren().add(whenTrue); |
| 64 | |
|
| 65 | 0 | addAgendaItemAndChildren(whenTrue, agendaItem.getWhenTrue()); |
| 66 | |
} |
| 67 | 0 | if (agendaItem.getWhenFalse() != null) { |
| 68 | 0 | Node<AgendaTreeNode, String> whenFalse = new Node<AgendaTreeNode, String>(); |
| 69 | 0 | whenFalse.setNodeLabel("When FALSE"); |
| 70 | 0 | whenFalse.setNodeType("agendaNode logicNode whenFalseNode"); |
| 71 | 0 | whenFalse.setData(new AgendaTreeLogicNode()); |
| 72 | 0 | child.getChildren().add(whenFalse); |
| 73 | |
|
| 74 | 0 | addAgendaItemAndChildren(whenFalse, agendaItem.getWhenFalse()); |
| 75 | |
} |
| 76 | 0 | } |
| 77 | |
|
| 78 | |
public Tree<? extends AgendaTreeNode, String> getAgendaRuleTree() { |
| 79 | 0 | Tree<AgendaTreeNode, String> agendaTree = new Tree<AgendaTreeNode, String>(); |
| 80 | |
|
| 81 | 0 | Node<AgendaTreeNode, String> rootNode = new Node<AgendaTreeNode, String>(); |
| 82 | 0 | agendaTree.setRootElement(rootNode); |
| 83 | |
|
| 84 | 0 | if (agenda != null) { |
| 85 | 0 | String firstItemId = agenda.getFirstItemId(); |
| 86 | 0 | List<AgendaItemBo> items = agenda.getItems(); |
| 87 | 0 | AgendaItemBo firstItem = null; |
| 88 | |
|
| 89 | 0 | if (items != null && firstItemId != null) { |
| 90 | 0 | for (AgendaItemBo item : items) { |
| 91 | 0 | if (firstItemId.equals(item.getId())) { |
| 92 | 0 | firstItem = item; |
| 93 | 0 | break; |
| 94 | |
} |
| 95 | |
} |
| 96 | |
} |
| 97 | |
|
| 98 | 0 | if (firstItem != null) addAgendaItemAndChildren(rootNode, firstItem); |
| 99 | |
} |
| 100 | |
|
| 101 | 0 | return agendaTree; |
| 102 | |
} |
| 103 | |
|
| 104 | |
|
| 105 | |
|
| 106 | |
|
| 107 | |
public AgendaItemBo getAgendaItemLine() { |
| 108 | 0 | return this.agendaItemLine; |
| 109 | |
} |
| 110 | |
|
| 111 | |
|
| 112 | |
|
| 113 | |
public void setAgendaItemLine(AgendaItemBo agendaItemLine) { |
| 114 | 0 | this.agendaItemLine = agendaItemLine; |
| 115 | 0 | } |
| 116 | |
|
| 117 | |
|
| 118 | |
|
| 119 | |
public String getSelectedAgendaItemId() { |
| 120 | 0 | return this.selectedAgendaItemId; |
| 121 | |
} |
| 122 | |
|
| 123 | |
|
| 124 | |
|
| 125 | |
public void setSelectedAgendaItemId(String selectedAgendaItemId) { |
| 126 | 0 | this.selectedAgendaItemId = selectedAgendaItemId; |
| 127 | 0 | } |
| 128 | |
|
| 129 | |
|
| 130 | |
|
| 131 | |
public ContextBo getContext() { |
| 132 | 0 | return this.context; |
| 133 | |
} |
| 134 | |
|
| 135 | |
|
| 136 | |
|
| 137 | |
public void setContext(ContextBo context) { |
| 138 | 0 | this.context = context; |
| 139 | 0 | } |
| 140 | |
|
| 141 | |
|
| 142 | |
|
| 143 | |
public AgendaBo getAgenda() { |
| 144 | 0 | return this.agenda; |
| 145 | |
} |
| 146 | |
|
| 147 | |
|
| 148 | |
|
| 149 | |
public void setAgenda(AgendaBo agenda) { |
| 150 | 0 | this.agenda = agenda; |
| 151 | 0 | } |
| 152 | |
|
| 153 | |
|
| 154 | |
} |