| 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.ArrayList; |
| 19 | |
import java.util.List; |
| 20 | |
|
| 21 | |
import org.apache.commons.lang.StringUtils; |
| 22 | |
import org.kuali.rice.krad.bo.PersistableBusinessObjectBase; |
| 23 | |
import org.kuali.rice.krms.api.repository.agenda.AgendaItem; |
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | 0 | public class AgendaItemBo extends PersistableBusinessObjectBase { |
| 32 | |
|
| 33 | |
private String id; |
| 34 | |
private String agendaId; |
| 35 | |
private String ruleId; |
| 36 | |
private String subAgendaId; |
| 37 | |
private String whenTrueId; |
| 38 | |
private String whenFalseId; |
| 39 | |
private String alwaysId; |
| 40 | |
|
| 41 | |
private RuleBo rule; |
| 42 | |
|
| 43 | |
private AgendaItemBo whenTrue; |
| 44 | |
private AgendaItemBo whenFalse; |
| 45 | |
private AgendaItemBo always; |
| 46 | |
|
| 47 | |
public String getUl(AgendaItemBo firstItem) { |
| 48 | 0 | return ("<ul>" + getUlHelper(firstItem) + "</ul>"); |
| 49 | |
} |
| 50 | |
|
| 51 | |
public String getUlHelper(AgendaItemBo item) { |
| 52 | 0 | StringBuilder sb = new StringBuilder(); |
| 53 | 0 | sb.append("<li>" + ruleId + "</li>"); |
| 54 | 0 | if (whenTrue != null) { |
| 55 | 0 | sb.append("<ul><li>when true</li><ul>"); |
| 56 | 0 | sb.append(getUlHelper(whenTrue)); |
| 57 | 0 | sb.append("</ul></ul>"); |
| 58 | |
} |
| 59 | 0 | if (whenFalse != null) { |
| 60 | 0 | sb.append("<ul><li>when false</li><ul>"); |
| 61 | 0 | sb.append(getUlHelper(whenFalse)); |
| 62 | 0 | sb.append("</ul></ul>"); |
| 63 | |
} |
| 64 | 0 | if (always != null) { |
| 65 | 0 | sb.append(getUlHelper(always)); |
| 66 | |
} |
| 67 | 0 | return sb.toString(); |
| 68 | |
} |
| 69 | |
|
| 70 | |
public String getRuleText() { |
| 71 | 0 | StringBuilder resultBuilder = new StringBuilder(); |
| 72 | 0 | if (getRule() != null) { |
| 73 | 0 | if (StringUtils.isBlank(getRule().getName())) { |
| 74 | 0 | resultBuilder.append("- unnamed rule -"); |
| 75 | |
} else { |
| 76 | 0 | resultBuilder.append(getRule().getName()); |
| 77 | |
} |
| 78 | 0 | if (!StringUtils.isBlank(getRule().getDescription())) { |
| 79 | 0 | resultBuilder.append(": "); |
| 80 | 0 | resultBuilder.append(getRule().getDescription()); |
| 81 | |
} |
| 82 | |
} else { |
| 83 | 0 | throw new IllegalStateException(); |
| 84 | |
} |
| 85 | 0 | return resultBuilder.toString(); |
| 86 | |
} |
| 87 | |
|
| 88 | |
|
| 89 | |
|
| 90 | |
|
| 91 | |
|
| 92 | |
public List<AgendaItemBo> getAlwaysList() { |
| 93 | 0 | List<AgendaItemBo> results = new ArrayList<AgendaItemBo>(); |
| 94 | |
|
| 95 | 0 | AgendaItemBo currentNode = this; |
| 96 | 0 | while (currentNode.always != null) { |
| 97 | 0 | results.add(currentNode.always); |
| 98 | 0 | currentNode = currentNode.always; |
| 99 | |
} |
| 100 | |
|
| 101 | 0 | return results; |
| 102 | |
} |
| 103 | |
|
| 104 | |
|
| 105 | |
|
| 106 | |
|
| 107 | |
public String getId() { |
| 108 | 0 | return this.id; |
| 109 | |
} |
| 110 | |
|
| 111 | |
|
| 112 | |
|
| 113 | |
|
| 114 | |
public void setId(String id) { |
| 115 | 0 | this.id = id; |
| 116 | 0 | } |
| 117 | |
|
| 118 | |
|
| 119 | |
|
| 120 | |
|
| 121 | |
public String getAgendaId() { |
| 122 | 0 | return this.agendaId; |
| 123 | |
} |
| 124 | |
|
| 125 | |
|
| 126 | |
|
| 127 | |
|
| 128 | |
public void setAgendaId(String agendaId) { |
| 129 | 0 | this.agendaId = agendaId; |
| 130 | 0 | } |
| 131 | |
|
| 132 | |
|
| 133 | |
|
| 134 | |
|
| 135 | |
public String getRuleId() { |
| 136 | 0 | return this.ruleId; |
| 137 | |
} |
| 138 | |
|
| 139 | |
|
| 140 | |
|
| 141 | |
|
| 142 | |
public void setRuleId(String ruleId) { |
| 143 | 0 | this.ruleId = ruleId; |
| 144 | 0 | } |
| 145 | |
|
| 146 | |
|
| 147 | |
|
| 148 | |
|
| 149 | |
public String getSubAgendaId() { |
| 150 | 0 | return this.subAgendaId; |
| 151 | |
} |
| 152 | |
|
| 153 | |
|
| 154 | |
|
| 155 | |
|
| 156 | |
public void setSubAgendaId(String subAgendaId) { |
| 157 | 0 | this.subAgendaId = subAgendaId; |
| 158 | 0 | } |
| 159 | |
|
| 160 | |
|
| 161 | |
|
| 162 | |
|
| 163 | |
|
| 164 | |
public String getWhenTrueId() { |
| 165 | 0 | return this.whenTrueId; |
| 166 | |
} |
| 167 | |
|
| 168 | |
|
| 169 | |
|
| 170 | |
|
| 171 | |
public void setWhenTrueId(String whenTrueId) { |
| 172 | 0 | this.whenTrueId = whenTrueId; |
| 173 | 0 | } |
| 174 | |
|
| 175 | |
|
| 176 | |
|
| 177 | |
|
| 178 | |
public String getWhenFalseId() { |
| 179 | 0 | return this.whenFalseId; |
| 180 | |
} |
| 181 | |
|
| 182 | |
|
| 183 | |
|
| 184 | |
|
| 185 | |
public void setWhenFalseId(String whenFalseId) { |
| 186 | 0 | this.whenFalseId = whenFalseId; |
| 187 | 0 | } |
| 188 | |
|
| 189 | |
|
| 190 | |
|
| 191 | |
|
| 192 | |
public String getAlwaysId() { |
| 193 | 0 | return this.alwaysId; |
| 194 | |
} |
| 195 | |
|
| 196 | |
|
| 197 | |
|
| 198 | |
|
| 199 | |
public void setAlwaysId(String alwaysId) { |
| 200 | 0 | this.alwaysId = alwaysId; |
| 201 | 0 | } |
| 202 | |
|
| 203 | |
|
| 204 | |
|
| 205 | |
|
| 206 | |
public AgendaItemBo getWhenTrue() { |
| 207 | 0 | return this.whenTrue; |
| 208 | |
} |
| 209 | |
|
| 210 | |
|
| 211 | |
|
| 212 | |
|
| 213 | |
public void setWhenTrue(AgendaItemBo whenTrue) { |
| 214 | 0 | this.whenTrue = whenTrue; |
| 215 | 0 | } |
| 216 | |
|
| 217 | |
|
| 218 | |
|
| 219 | |
|
| 220 | |
public AgendaItemBo getWhenFalse() { |
| 221 | 0 | return this.whenFalse; |
| 222 | |
} |
| 223 | |
|
| 224 | |
|
| 225 | |
|
| 226 | |
|
| 227 | |
public void setWhenFalse(AgendaItemBo whenFalse) { |
| 228 | 0 | this.whenFalse = whenFalse; |
| 229 | 0 | } |
| 230 | |
|
| 231 | |
|
| 232 | |
|
| 233 | |
|
| 234 | |
public AgendaItemBo getAlways() { |
| 235 | 0 | return this.always; |
| 236 | |
} |
| 237 | |
|
| 238 | |
|
| 239 | |
|
| 240 | |
|
| 241 | |
public void setAlways(AgendaItemBo always) { |
| 242 | 0 | this.always = always; |
| 243 | 0 | } |
| 244 | |
|
| 245 | |
|
| 246 | |
|
| 247 | |
|
| 248 | |
public RuleBo getRule() { |
| 249 | 0 | return this.rule; |
| 250 | |
} |
| 251 | |
|
| 252 | |
|
| 253 | |
|
| 254 | |
|
| 255 | |
public void setRule(RuleBo rule) { |
| 256 | 0 | this.rule = rule; |
| 257 | 0 | } |
| 258 | |
|
| 259 | |
|
| 260 | |
|
| 261 | |
|
| 262 | |
|
| 263 | |
|
| 264 | |
|
| 265 | |
static AgendaItem to(AgendaItemBo bo) { |
| 266 | 0 | if (bo == null) { return null; } |
| 267 | 0 | org.kuali.rice.krms.api.repository.agenda.AgendaItem.Builder builder = |
| 268 | |
org.kuali.rice.krms.api.repository.agenda.AgendaItem.Builder.create(bo.getId(), bo.getAgendaId()); |
| 269 | 0 | builder.setRuleId(bo.getRuleId()); |
| 270 | 0 | builder.setSubAgendaId(bo.getSubAgendaId()); |
| 271 | 0 | builder.setWhenTrueId(bo.getWhenTrueId()); |
| 272 | 0 | builder.setWhenFalseId(bo.getWhenFalseId()); |
| 273 | 0 | builder.setAlwaysId(bo.getAlwaysId()); |
| 274 | |
|
| 275 | 0 | return builder.build(); |
| 276 | |
} |
| 277 | |
|
| 278 | |
|
| 279 | |
|
| 280 | |
|
| 281 | |
|
| 282 | |
|
| 283 | |
static AgendaItemBo from(AgendaItem im) { |
| 284 | 0 | if (im == null) { return null; } |
| 285 | |
|
| 286 | 0 | AgendaItemBo bo = new AgendaItemBo(); |
| 287 | 0 | bo.id = im.getId(); |
| 288 | 0 | bo.agendaId = im.getAgendaId(); |
| 289 | 0 | bo.ruleId = im.getRuleId(); |
| 290 | 0 | bo.subAgendaId = im.getSubAgendaId(); |
| 291 | 0 | bo.whenTrueId = im.getWhenTrueId(); |
| 292 | 0 | bo.whenFalseId = im.getWhenFalseId(); |
| 293 | 0 | bo.alwaysId = im.getAlwaysId(); |
| 294 | |
|
| 295 | 0 | return bo; |
| 296 | |
} |
| 297 | |
} |