| 1 | |
package org.kuali.rice.krms.api.repository.agenda; |
| 2 | |
|
| 3 | |
import java.io.Serializable; |
| 4 | |
import java.util.Collection; |
| 5 | |
|
| 6 | |
import javax.xml.bind.annotation.XmlAccessType; |
| 7 | |
import javax.xml.bind.annotation.XmlAccessorType; |
| 8 | |
import javax.xml.bind.annotation.XmlAnyElement; |
| 9 | |
import javax.xml.bind.annotation.XmlElement; |
| 10 | |
import javax.xml.bind.annotation.XmlRootElement; |
| 11 | |
import javax.xml.bind.annotation.XmlType; |
| 12 | |
|
| 13 | |
import org.apache.commons.lang.StringUtils; |
| 14 | |
import org.kuali.rice.core.api.CoreConstants; |
| 15 | |
import org.kuali.rice.core.api.mo.AbstractDataTransferObject; |
| 16 | |
import org.kuali.rice.core.api.mo.ModelBuilder; |
| 17 | |
import org.kuali.rice.krms.api.repository.rule.RuleDefinition; |
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | 0 | @XmlRootElement(name = AgendaItem.Constants.ROOT_ELEMENT_NAME) |
| 27 | |
@XmlAccessorType(XmlAccessType.NONE) |
| 28 | |
@XmlType(name = AgendaItem.Constants.TYPE_NAME, propOrder = { |
| 29 | |
AgendaItem.Elements.ID, |
| 30 | |
AgendaItem.Elements.AGENDA_ID, |
| 31 | |
AgendaItem.Elements.RULE_ID, |
| 32 | |
AgendaItem.Elements.SUB_AGENDA_ID, |
| 33 | |
AgendaItem.Elements.WHEN_TRUE_ID, |
| 34 | |
AgendaItem.Elements.WHEN_FALSE_ID, |
| 35 | |
AgendaItem.Elements.ALWAYS_ID, |
| 36 | |
AgendaItem.Elements.RULE, |
| 37 | |
AgendaItem.Elements.SUB_AGENDA, |
| 38 | |
AgendaItem.Elements.WHEN_TRUE, |
| 39 | |
AgendaItem.Elements.WHEN_FALSE, |
| 40 | |
AgendaItem.Elements.ALWAYS, |
| 41 | |
CoreConstants.CommonElements.VERSION_NUMBER, |
| 42 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
| 43 | |
}) |
| 44 | 0 | public final class AgendaItem extends AbstractDataTransferObject implements AgendaItemContract { |
| 45 | |
private static final long serialVersionUID = 2783959459503209577L; |
| 46 | |
|
| 47 | |
@XmlElement(name = Elements.ID, required=true) |
| 48 | |
private String id; |
| 49 | |
@XmlElement(name = Elements.AGENDA_ID, required=true) |
| 50 | |
private String agendaId; |
| 51 | |
@XmlElement(name = Elements.RULE_ID, required=false) |
| 52 | |
private String ruleId; |
| 53 | |
@XmlElement(name = Elements.SUB_AGENDA_ID, required=false) |
| 54 | |
private String subAgendaId; |
| 55 | |
@XmlElement(name = Elements.WHEN_TRUE_ID, required=false) |
| 56 | |
private String whenTrueId; |
| 57 | |
@XmlElement(name = Elements.WHEN_FALSE_ID, required=false) |
| 58 | |
private String whenFalseId; |
| 59 | |
@XmlElement(name = Elements.ALWAYS_ID, required=false) |
| 60 | |
private String alwaysId; |
| 61 | |
|
| 62 | |
@XmlElement(name = Elements.RULE, required=false) |
| 63 | |
private RuleDefinition rule;; |
| 64 | |
@XmlElement(name = Elements.SUB_AGENDA, required=false) |
| 65 | |
private AgendaDefinition subAgenda; |
| 66 | |
@XmlElement(name = Elements.WHEN_TRUE, required=false) |
| 67 | |
private AgendaItem whenTrue; |
| 68 | |
@XmlElement(name = Elements.WHEN_FALSE, required=false) |
| 69 | |
private AgendaItem whenFalse; |
| 70 | |
@XmlElement(name = Elements.ALWAYS, required=false) |
| 71 | |
private AgendaItem always; |
| 72 | |
|
| 73 | |
@XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false) |
| 74 | |
private final Long versionNumber; |
| 75 | |
|
| 76 | 0 | @SuppressWarnings("unused") |
| 77 | |
@XmlAnyElement |
| 78 | |
private final Collection<org.w3c.dom.Element> _futureElements = null; |
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 82 | |
|
| 83 | |
|
| 84 | |
|
| 85 | 0 | private AgendaItem() { |
| 86 | 0 | this.id = null; |
| 87 | 0 | this.agendaId = null; |
| 88 | 0 | this.ruleId = null; |
| 89 | 0 | this.subAgendaId = null; |
| 90 | 0 | this.whenTrueId = null; |
| 91 | 0 | this.whenFalseId = null; |
| 92 | 0 | this.alwaysId = null; |
| 93 | |
|
| 94 | 0 | this.rule = null; |
| 95 | 0 | this.subAgenda = null; |
| 96 | |
|
| 97 | 0 | this.whenTrue = null; |
| 98 | 0 | this.whenFalse = null; |
| 99 | 0 | this.always = null; |
| 100 | |
|
| 101 | 0 | this.versionNumber = null; |
| 102 | 0 | } |
| 103 | |
|
| 104 | |
|
| 105 | |
|
| 106 | |
|
| 107 | |
|
| 108 | |
|
| 109 | |
|
| 110 | 0 | private AgendaItem(Builder builder) { |
| 111 | 0 | this.id = builder.getId(); |
| 112 | 0 | this.agendaId = builder.getAgendaId(); |
| 113 | 0 | this.ruleId = builder.getRuleId(); |
| 114 | 0 | this.subAgendaId = builder.getSubAgendaId(); |
| 115 | 0 | this.whenTrueId = builder.getWhenTrueId(); |
| 116 | 0 | this.whenFalseId = builder.getWhenFalseId(); |
| 117 | 0 | this.alwaysId = builder.getAlwaysId(); |
| 118 | 0 | this.versionNumber = builder.getVersionNumber(); |
| 119 | |
|
| 120 | 0 | if (builder.getRule() != null) { this.rule = builder.getRule().build(); } |
| 121 | 0 | if (builder.getSubAgenda() != null) { this.subAgenda = builder.getSubAgenda().build(); } |
| 122 | 0 | if (builder.getWhenTrue() != null) { this.whenTrue = builder.getWhenTrue().build(); } |
| 123 | 0 | if (builder.getWhenFalse() != null) { this.whenFalse = builder.getWhenFalse().build(); } |
| 124 | 0 | if (builder.getAlways() != null) { this.always = builder.getAlways().build(); } |
| 125 | 0 | } |
| 126 | |
|
| 127 | |
@Override |
| 128 | |
public String getId() { |
| 129 | 0 | return this.id; |
| 130 | |
} |
| 131 | |
|
| 132 | |
@Override |
| 133 | |
public String getAgendaId() { |
| 134 | 0 | return this.agendaId; |
| 135 | |
} |
| 136 | |
|
| 137 | |
@Override |
| 138 | |
public String getRuleId() { |
| 139 | 0 | return this.ruleId; |
| 140 | |
} |
| 141 | |
|
| 142 | |
@Override |
| 143 | |
public String getSubAgendaId() { |
| 144 | 0 | return this.subAgendaId; |
| 145 | |
} |
| 146 | |
|
| 147 | |
@Override |
| 148 | |
public String getWhenTrueId() { |
| 149 | 0 | return this.whenTrueId; |
| 150 | |
} |
| 151 | |
|
| 152 | |
@Override |
| 153 | |
public String getWhenFalseId() { |
| 154 | 0 | return this.whenFalseId; |
| 155 | |
} |
| 156 | |
|
| 157 | |
@Override |
| 158 | |
public String getAlwaysId() { |
| 159 | 0 | return this.alwaysId; |
| 160 | |
} |
| 161 | |
|
| 162 | |
@Override |
| 163 | |
public RuleDefinition getRule() { |
| 164 | 0 | return this.rule; |
| 165 | |
} |
| 166 | |
|
| 167 | |
@Override |
| 168 | |
public AgendaDefinition getSubAgenda() { |
| 169 | 0 | return this.subAgenda; |
| 170 | |
} |
| 171 | |
|
| 172 | |
@Override |
| 173 | |
public AgendaItem getWhenTrue() { |
| 174 | 0 | return this.whenTrue; |
| 175 | |
} |
| 176 | |
|
| 177 | |
@Override |
| 178 | |
public AgendaItem getWhenFalse() { |
| 179 | 0 | return this.whenFalse; |
| 180 | |
} |
| 181 | |
|
| 182 | |
@Override |
| 183 | |
public AgendaItem getAlways() { |
| 184 | 0 | return this.always; |
| 185 | |
} |
| 186 | |
|
| 187 | |
@Override |
| 188 | |
public Long getVersionNumber() { |
| 189 | 0 | return versionNumber; |
| 190 | |
} |
| 191 | |
|
| 192 | |
|
| 193 | |
|
| 194 | |
|
| 195 | 0 | public static class Builder implements AgendaItemContract, ModelBuilder, Serializable { |
| 196 | |
|
| 197 | |
private String id; |
| 198 | |
private String agendaId; |
| 199 | |
private String ruleId; |
| 200 | |
private String subAgendaId; |
| 201 | |
private String whenTrueId; |
| 202 | |
private String whenFalseId; |
| 203 | |
private String alwaysId; |
| 204 | |
private Long versionNumber; |
| 205 | |
|
| 206 | |
private RuleDefinition.Builder rule; |
| 207 | |
private AgendaDefinition.Builder subAgenda; |
| 208 | |
|
| 209 | |
private AgendaItem.Builder whenTrue; |
| 210 | |
private AgendaItem.Builder whenFalse; |
| 211 | |
private AgendaItem.Builder always; |
| 212 | |
|
| 213 | |
|
| 214 | |
|
| 215 | |
|
| 216 | |
|
| 217 | 0 | private Builder(String id, String agendaId) { |
| 218 | 0 | setId(id); |
| 219 | 0 | setAgendaId(agendaId); |
| 220 | 0 | } |
| 221 | |
|
| 222 | |
public static Builder create(String id, String agendaId){ |
| 223 | 0 | return new Builder(id, agendaId); |
| 224 | |
} |
| 225 | |
|
| 226 | |
|
| 227 | |
|
| 228 | |
|
| 229 | |
|
| 230 | |
|
| 231 | |
public static Builder create(AgendaItemContract contract) { |
| 232 | 0 | if (contract == null) { |
| 233 | 0 | throw new IllegalArgumentException("contract is null"); |
| 234 | |
} |
| 235 | 0 | Builder builder = new Builder(contract.getId(), contract.getAgendaId()); |
| 236 | 0 | builder.setRuleId(contract.getRuleId()); |
| 237 | 0 | builder.setSubAgendaId(contract.getSubAgendaId()); |
| 238 | 0 | builder.setWhenTrueId(contract.getWhenTrueId()); |
| 239 | 0 | builder.setWhenFalseId(contract.getWhenFalseId()); |
| 240 | 0 | builder.setAlwaysId(contract.getAlwaysId()); |
| 241 | |
|
| 242 | 0 | if (contract.getRule() != null){ |
| 243 | 0 | builder.setRule(RuleDefinition.Builder.create( contract.getRule() )); |
| 244 | |
} |
| 245 | 0 | if (contract.getSubAgenda() != null){ |
| 246 | 0 | builder.setSubAgenda( AgendaDefinition.Builder.create( contract.getSubAgenda())); |
| 247 | |
} |
| 248 | 0 | if (contract.getWhenTrue() != null){ |
| 249 | 0 | builder.setWhenTrue( AgendaItem.Builder.create( contract.getWhenTrue())); |
| 250 | |
} |
| 251 | 0 | if (contract.getWhenFalse() != null){ |
| 252 | 0 | builder.setWhenFalse( AgendaItem.Builder.create( contract.getWhenFalse())); |
| 253 | |
} |
| 254 | 0 | if (contract.getAlways() != null){ |
| 255 | 0 | builder.setAlways( AgendaItem.Builder.create( contract.getAlways())); |
| 256 | |
} |
| 257 | 0 | builder.setVersionNumber(contract.getVersionNumber()); |
| 258 | 0 | return builder; |
| 259 | |
} |
| 260 | |
|
| 261 | |
|
| 262 | |
|
| 263 | |
|
| 264 | |
|
| 265 | |
|
| 266 | |
|
| 267 | |
|
| 268 | |
|
| 269 | |
|
| 270 | |
|
| 271 | |
public void setId(String id) { |
| 272 | 0 | if (id != null && StringUtils.isBlank(id)) { |
| 273 | 0 | throw new IllegalArgumentException("agendaItemId is empty or whitespace."); |
| 274 | |
} |
| 275 | 0 | this.id = id; |
| 276 | 0 | } |
| 277 | |
|
| 278 | |
|
| 279 | |
|
| 280 | |
|
| 281 | |
|
| 282 | |
|
| 283 | |
|
| 284 | |
|
| 285 | |
public void setAgendaId(String agendaId) { |
| 286 | 0 | if (StringUtils.isBlank(agendaId)) { |
| 287 | 0 | throw new IllegalArgumentException("agendaId is blank"); |
| 288 | |
} |
| 289 | 0 | this.agendaId = agendaId; |
| 290 | 0 | } |
| 291 | |
|
| 292 | |
public void setRuleId(String ruleId) { |
| 293 | 0 | this.ruleId = ruleId; |
| 294 | 0 | } |
| 295 | |
|
| 296 | |
public void setSubAgendaId(String subAgendaId) { |
| 297 | 0 | this.subAgendaId = subAgendaId; |
| 298 | 0 | } |
| 299 | |
|
| 300 | |
public void setWhenTrueId(String whenTrueId) { |
| 301 | 0 | this.whenTrueId = whenTrueId; |
| 302 | 0 | } |
| 303 | |
|
| 304 | |
public void setWhenFalseId(String whenFalseId) { |
| 305 | 0 | this.whenFalseId = whenFalseId; |
| 306 | 0 | } |
| 307 | |
|
| 308 | |
public void setAlwaysId(String alwaysId) { |
| 309 | 0 | this.alwaysId = alwaysId; |
| 310 | 0 | } |
| 311 | |
|
| 312 | |
public void setRule(RuleDefinition.Builder rule) { |
| 313 | 0 | this.rule = rule; |
| 314 | 0 | } |
| 315 | |
|
| 316 | |
public void setSubAgenda(AgendaDefinition.Builder subAgenda) { |
| 317 | 0 | this.subAgenda = subAgenda; |
| 318 | 0 | } |
| 319 | |
|
| 320 | |
public void setWhenTrue(AgendaItem.Builder whenTrue) { |
| 321 | 0 | this.whenTrue = whenTrue; |
| 322 | 0 | } |
| 323 | |
|
| 324 | |
public void setWhenFalse(AgendaItem.Builder whenFalse) { |
| 325 | 0 | this.whenTrue = whenFalse; |
| 326 | 0 | } |
| 327 | |
|
| 328 | |
public void setAlways(AgendaItem.Builder always) { |
| 329 | 0 | this.always = always; |
| 330 | 0 | } |
| 331 | |
|
| 332 | |
public void setVersionNumber(Long versionNumber){ |
| 333 | 0 | this.versionNumber = versionNumber; |
| 334 | 0 | } |
| 335 | |
|
| 336 | |
@Override |
| 337 | |
public String getId() { |
| 338 | 0 | return id; |
| 339 | |
} |
| 340 | |
|
| 341 | |
@Override |
| 342 | |
public String getAgendaId() { |
| 343 | 0 | return agendaId; |
| 344 | |
} |
| 345 | |
|
| 346 | |
@Override |
| 347 | |
public String getRuleId() { |
| 348 | 0 | return ruleId; |
| 349 | |
} |
| 350 | |
|
| 351 | |
@Override |
| 352 | |
public String getSubAgendaId() { |
| 353 | 0 | return subAgendaId; |
| 354 | |
} |
| 355 | |
|
| 356 | |
@Override |
| 357 | |
public String getWhenTrueId() { |
| 358 | 0 | return whenTrueId; |
| 359 | |
} |
| 360 | |
|
| 361 | |
@Override |
| 362 | |
public String getWhenFalseId() { |
| 363 | 0 | return whenFalseId; |
| 364 | |
} |
| 365 | |
|
| 366 | |
@Override |
| 367 | |
public String getAlwaysId() { |
| 368 | 0 | return alwaysId; |
| 369 | |
} |
| 370 | |
|
| 371 | |
@Override |
| 372 | |
public RuleDefinition.Builder getRule() { |
| 373 | 0 | return rule; |
| 374 | |
} |
| 375 | |
|
| 376 | |
@Override |
| 377 | |
public AgendaDefinition.Builder getSubAgenda() { |
| 378 | 0 | return subAgenda; |
| 379 | |
} |
| 380 | |
|
| 381 | |
@Override |
| 382 | |
public AgendaItem.Builder getWhenTrue() { |
| 383 | 0 | return whenTrue; |
| 384 | |
} |
| 385 | |
|
| 386 | |
@Override |
| 387 | |
public AgendaItem.Builder getWhenFalse() { |
| 388 | 0 | return whenFalse; |
| 389 | |
} |
| 390 | |
|
| 391 | |
@Override |
| 392 | |
public AgendaItem.Builder getAlways() { |
| 393 | 0 | return always; |
| 394 | |
} |
| 395 | |
|
| 396 | |
@Override |
| 397 | |
public Long getVersionNumber() { |
| 398 | 0 | return versionNumber; |
| 399 | |
} |
| 400 | |
|
| 401 | |
|
| 402 | |
|
| 403 | |
|
| 404 | |
|
| 405 | |
|
| 406 | |
@Override |
| 407 | |
public AgendaItem build() { |
| 408 | 0 | return new AgendaItem(this); |
| 409 | |
} |
| 410 | |
|
| 411 | |
} |
| 412 | |
|
| 413 | |
|
| 414 | |
|
| 415 | |
|
| 416 | 0 | static class Constants { |
| 417 | |
final static String ROOT_ELEMENT_NAME = "AgendaItem"; |
| 418 | |
final static String TYPE_NAME = "AgendaItemType"; |
| 419 | |
} |
| 420 | |
|
| 421 | |
|
| 422 | |
|
| 423 | |
|
| 424 | |
|
| 425 | 0 | public static class Elements { |
| 426 | |
final static String ID = "id"; |
| 427 | |
final static String AGENDA_ID = "agendaId"; |
| 428 | |
final static String RULE_ID = "ruleId"; |
| 429 | |
final static String SUB_AGENDA_ID = "subAgendaId"; |
| 430 | |
final static String WHEN_TRUE_ID = "whenTrueId"; |
| 431 | |
final static String WHEN_FALSE_ID = "whenFalseId"; |
| 432 | |
final static String ALWAYS_ID = "alwaysId"; |
| 433 | |
|
| 434 | |
final static String RULE = "rule"; |
| 435 | |
final static String SUB_AGENDA = "subAgenda"; |
| 436 | |
final static String WHEN_TRUE = "whenTrue"; |
| 437 | |
final static String WHEN_FALSE = "whenFalse"; |
| 438 | |
final static String ALWAYS = "always"; |
| 439 | |
} |
| 440 | |
|
| 441 | |
} |