Coverage Report - org.kuali.rice.krms.api.repository.agenda.AgendaItem
 
Classes in this File Line Coverage Branch Coverage Complexity
AgendaItem
0%
0/46
0%
0/10
1.378
AgendaItem$1
N/A
N/A
1.378
AgendaItem$Builder
0%
0/70
0%
0/18
1.378
AgendaItem$Constants
0%
0/1
N/A
1.378
AgendaItem$Elements
0%
0/1
N/A
1.378
 
 1  
 /**
 2  
  * Copyright 2005-2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.krms.api.repository.agenda;
 17  
 
 18  
 import java.io.Serializable;
 19  
 import java.util.Collection;
 20  
 
 21  
 import javax.xml.bind.annotation.XmlAccessType;
 22  
 import javax.xml.bind.annotation.XmlAccessorType;
 23  
 import javax.xml.bind.annotation.XmlAnyElement;
 24  
 import javax.xml.bind.annotation.XmlElement;
 25  
 import javax.xml.bind.annotation.XmlRootElement;
 26  
 import javax.xml.bind.annotation.XmlType;
 27  
 
 28  
 import org.apache.commons.lang.StringUtils;
 29  
 import org.kuali.rice.core.api.CoreConstants;
 30  
 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
 31  
 import org.kuali.rice.core.api.mo.ModelBuilder;
 32  
 import org.kuali.rice.krms.api.repository.rule.RuleDefinition;
 33  
 
 34  
 /**
 35  
  * Concrete model object implementation of KRMS Repository AgendaItem 
 36  
  * immutable. 
 37  
  * Instances of AgendaItem can be (un)marshalled to and from XML.
 38  
  *
 39  
  * @see AgendaItemContract
 40  
  */
 41  0
 @XmlRootElement(name = AgendaItem.Constants.ROOT_ELEMENT_NAME)
 42  
 @XmlAccessorType(XmlAccessType.NONE)
 43  
 @XmlType(name = AgendaItem.Constants.TYPE_NAME, propOrder = {
 44  
                 AgendaItem.Elements.ID,
 45  
                 AgendaItem.Elements.AGENDA_ID,
 46  
                 AgendaItem.Elements.RULE_ID,
 47  
                 AgendaItem.Elements.SUB_AGENDA_ID,
 48  
                 AgendaItem.Elements.WHEN_TRUE_ID,
 49  
                 AgendaItem.Elements.WHEN_FALSE_ID,
 50  
                 AgendaItem.Elements.ALWAYS_ID,
 51  
                 AgendaItem.Elements.RULE,
 52  
                 AgendaItem.Elements.SUB_AGENDA,
 53  
                 AgendaItem.Elements.WHEN_TRUE,
 54  
                 AgendaItem.Elements.WHEN_FALSE,
 55  
                 AgendaItem.Elements.ALWAYS,
 56  
         CoreConstants.CommonElements.VERSION_NUMBER,
 57  
                 CoreConstants.CommonElements.FUTURE_ELEMENTS
 58  
 })
 59  0
 public final class AgendaItem extends AbstractDataTransferObject implements AgendaItemContract {
 60  
         private static final long serialVersionUID = 2783959459503209577L;
 61  
 
 62  
         @XmlElement(name = Elements.ID, required=true)
 63  
         private String id;
 64  
         @XmlElement(name = Elements.AGENDA_ID, required=true)
 65  
         private String agendaId;
 66  
         @XmlElement(name = Elements.RULE_ID, required=false)
 67  
         private String ruleId;
 68  
         @XmlElement(name = Elements.SUB_AGENDA_ID, required=false)
 69  
         private String subAgendaId;
 70  
         @XmlElement(name = Elements.WHEN_TRUE_ID, required=false)
 71  
         private String whenTrueId;
 72  
         @XmlElement(name = Elements.WHEN_FALSE_ID, required=false)
 73  
         private String whenFalseId;
 74  
         @XmlElement(name = Elements.ALWAYS_ID, required=false)
 75  
         private String alwaysId;
 76  
         
 77  
         @XmlElement(name = Elements.RULE, required=false)
 78  
         private RuleDefinition rule;;
 79  
         @XmlElement(name = Elements.SUB_AGENDA, required=false)
 80  
         private AgendaDefinition subAgenda;
 81  
         @XmlElement(name = Elements.WHEN_TRUE, required=false)
 82  
         private AgendaItem whenTrue;
 83  
         @XmlElement(name = Elements.WHEN_FALSE, required=false)
 84  
         private AgendaItem whenFalse;
 85  
         @XmlElement(name = Elements.ALWAYS, required=false)
 86  
         private AgendaItem always;
 87  
         
 88  
     @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
 89  
     private final Long versionNumber;
 90  
             
 91  0
         @SuppressWarnings("unused")
 92  
     @XmlAnyElement
 93  
     private final Collection<org.w3c.dom.Element> _futureElements = null;
 94  
         
 95  
         
 96  
          /** 
 97  
      * This constructor should never be called.  
 98  
      * It is only present for use during JAXB unmarshalling. 
 99  
      */
 100  0
     private AgendaItem() {
 101  0
             this.id = null;
 102  0
             this.agendaId = null;
 103  0
             this.ruleId = null;
 104  0
             this.subAgendaId = null;
 105  0
             this.whenTrueId = null;
 106  0
             this.whenFalseId = null;
 107  0
             this.alwaysId = null;
 108  
             
 109  0
             this.rule = null;
 110  0
             this.subAgenda = null;
 111  
             
 112  0
             this.whenTrue = null;
 113  0
             this.whenFalse = null;
 114  0
             this.always = null;
 115  
             
 116  0
         this.versionNumber = null;
 117  0
     }
 118  
     
 119  
     /**
 120  
          * Constructs a KRMS Repository AgendaItem object from the given builder.  
 121  
          * This constructor is private and should only ever be invoked from the builder.
 122  
          * 
 123  
          * @param builder the Builder from which to construct the AgendaItem
 124  
          */
 125  0
     private AgendaItem(Builder builder) {
 126  0
             this.id = builder.getId();
 127  0
             this.agendaId = builder.getAgendaId();
 128  0
             this.ruleId = builder.getRuleId();
 129  0
             this.subAgendaId = builder.getSubAgendaId();
 130  0
             this.whenTrueId = builder.getWhenTrueId();
 131  0
             this.whenFalseId = builder.getWhenFalseId();
 132  0
             this.alwaysId = builder.getAlwaysId();
 133  0
         this.versionNumber = builder.getVersionNumber();
 134  
 
 135  0
             if (builder.getRule() != null) { this.rule = builder.getRule().build(); }
 136  0
             if (builder.getSubAgenda() != null) { this.subAgenda = builder.getSubAgenda().build(); }
 137  0
             if (builder.getWhenTrue() != null) { this.whenTrue  = builder.getWhenTrue().build(); }
 138  0
             if (builder.getWhenFalse() != null) { this.whenFalse = builder.getWhenFalse().build(); }
 139  0
             if (builder.getAlways() != null) { this.always = builder.getAlways().build(); }
 140  0
     }
 141  
 
 142  
         @Override
 143  
         public String getId() {
 144  0
                 return this.id;
 145  
         }
 146  
 
 147  
         @Override
 148  
         public String getAgendaId() {
 149  0
                 return this.agendaId;
 150  
         }
 151  
 
 152  
         @Override
 153  
         public String getRuleId() {
 154  0
                 return this.ruleId;
 155  
         }
 156  
 
 157  
         @Override
 158  
         public String getSubAgendaId() {
 159  0
                 return this.subAgendaId;
 160  
         }
 161  
 
 162  
         @Override
 163  
         public String getWhenTrueId() {
 164  0
                 return this.whenTrueId;
 165  
         }
 166  
 
 167  
         @Override
 168  
         public String getWhenFalseId() {
 169  0
                 return this.whenFalseId;
 170  
         }
 171  
 
 172  
         @Override
 173  
         public String getAlwaysId() {
 174  0
                 return this.alwaysId;
 175  
         }
 176  
 
 177  
         @Override
 178  
         public RuleDefinition getRule() {
 179  0
                 return this.rule; 
 180  
         }
 181  
 
 182  
         @Override
 183  
         public AgendaDefinition getSubAgenda() {
 184  0
                 return this.subAgenda; 
 185  
         }
 186  
 
 187  
         @Override
 188  
         public AgendaItem getWhenTrue() {
 189  0
                 return this.whenTrue; 
 190  
         }
 191  
 
 192  
         @Override
 193  
         public AgendaItem getWhenFalse() {
 194  0
                 return this.whenFalse; 
 195  
         }
 196  
 
 197  
         @Override
 198  
         public AgendaItem getAlways() {
 199  0
                 return this.always; 
 200  
         }
 201  
 
 202  
     @Override
 203  
     public Long getVersionNumber() {
 204  0
         return versionNumber;
 205  
     }
 206  
         
 207  
         /**
 208  
      * This builder is used to construct instances of KRMS Repository AgendaItem.  It enforces the constraints of the {@link AgendaItemContract}.
 209  
      */
 210  0
     public static class Builder implements AgendaItemContract, ModelBuilder, Serializable {
 211  
                 
 212  
         private String id;
 213  
         private String agendaId;
 214  
         private String ruleId;
 215  
         private String subAgendaId;
 216  
         private String whenTrueId;
 217  
         private String whenFalseId;
 218  
         private String alwaysId;
 219  
         private Long versionNumber;
 220  
         
 221  
         private RuleDefinition.Builder rule;
 222  
         private AgendaDefinition.Builder subAgenda;
 223  
         
 224  
         private AgendaItem.Builder whenTrue;
 225  
         private AgendaItem.Builder whenFalse;
 226  
         private AgendaItem.Builder always;
 227  
         
 228  
 
 229  
                 /**
 230  
                  * Private constructor for creating a builder with all of it's required attributes.
 231  
                  */
 232  0
         private Builder(String id, String agendaId) {
 233  0
                 setId(id);
 234  0
                 setAgendaId(agendaId);
 235  0
         }
 236  
         
 237  
         public static Builder create(String id, String agendaId){
 238  0
                 return new Builder(id, agendaId);
 239  
         }
 240  
         /**
 241  
          * Creates a builder by populating it with data from the given {@link AgendaItemContract}.
 242  
          * 
 243  
          * @param contract the contract from which to populate this builder
 244  
          * @return an instance of the builder populated with data from the contract
 245  
          */
 246  
         public static Builder create(AgendaItemContract contract) {
 247  0
                 if (contract == null) {
 248  0
                 throw new IllegalArgumentException("contract is null");
 249  
                 }
 250  0
                 Builder builder =  new Builder(contract.getId(), contract.getAgendaId());
 251  0
                 builder.setRuleId(contract.getRuleId());
 252  0
                 builder.setSubAgendaId(contract.getSubAgendaId());
 253  0
                 builder.setWhenTrueId(contract.getWhenTrueId());
 254  0
                 builder.setWhenFalseId(contract.getWhenFalseId());
 255  0
                 builder.setAlwaysId(contract.getAlwaysId());
 256  
                 
 257  0
                 if (contract.getRule() != null){
 258  0
                         builder.setRule(RuleDefinition.Builder.create( contract.getRule() ));
 259  
                 }
 260  0
                 if (contract.getSubAgenda() != null){
 261  0
                         builder.setSubAgenda( AgendaDefinition.Builder.create( contract.getSubAgenda()));
 262  
                 }
 263  0
                 if (contract.getWhenTrue() != null){
 264  0
                         builder.setWhenTrue( AgendaItem.Builder.create( contract.getWhenTrue()));
 265  
                 }
 266  0
                 if (contract.getWhenFalse() != null){
 267  0
                         builder.setWhenFalse( AgendaItem.Builder.create( contract.getWhenFalse()));
 268  
                 }
 269  0
                 if (contract.getAlways() != null){
 270  0
                         builder.setAlways( AgendaItem.Builder.create( contract.getAlways()));
 271  
                 }
 272  0
             builder.setVersionNumber(contract.getVersionNumber());
 273  0
                 return builder;
 274  
         }
 275  
 
 276  
                 /**
 277  
                  * Sets the value of the id on this builder to the given value.
 278  
                  * 
 279  
                  * @param id the primary id. (may be null), must not be or blank.
 280  
                  * </p><p>This value is generated by the system.
 281  
                  * For new items (not yet persisted) this field is null. 
 282  
                  * For existing items this field is the generated id. 
 283  
                  * @throws IllegalArgumentException if the id is blank
 284  
                  */
 285  
 
 286  
         public void setId(String id) {
 287  0
             if (id != null && StringUtils.isBlank(id)) {
 288  0
                 throw new IllegalArgumentException("agendaItemId is empty or whitespace.");
 289  
             }
 290  0
                         this.id = id;
 291  0
                 }
 292  
 
 293  
 
 294  
         /**
 295  
          * 
 296  
          * This method ...
 297  
          * 
 298  
          * @param agendaId
 299  
          */
 300  
         public void setAgendaId(String agendaId) {
 301  0
             if (StringUtils.isBlank(agendaId)) {
 302  0
                 throw new IllegalArgumentException("agendaId is blank");
 303  
             }
 304  0
                         this.agendaId = agendaId;
 305  0
                 }
 306  
                 
 307  
                 public void setRuleId(String ruleId) {
 308  0
                         this.ruleId = ruleId;
 309  0
                 }
 310  
 
 311  
                 public void setSubAgendaId(String subAgendaId) {
 312  0
                         this.subAgendaId = subAgendaId;
 313  0
                 }
 314  
 
 315  
                 public void setWhenTrueId(String whenTrueId) {
 316  0
                         this.whenTrueId = whenTrueId;
 317  0
                 }
 318  
 
 319  
                 public void setWhenFalseId(String whenFalseId) {
 320  0
                         this.whenFalseId = whenFalseId;
 321  0
                 }
 322  
 
 323  
                 public void setAlwaysId(String alwaysId) {
 324  0
                         this.alwaysId = alwaysId;
 325  0
                 }
 326  
 
 327  
                 public void setRule(RuleDefinition.Builder rule) {
 328  0
                         this.rule = rule;
 329  0
                 }
 330  
 
 331  
                 public void setSubAgenda(AgendaDefinition.Builder subAgenda) {
 332  0
                         this.subAgenda = subAgenda;
 333  0
                 }
 334  
 
 335  
                 public void setWhenTrue(AgendaItem.Builder whenTrue) {
 336  0
                         this.whenTrue = whenTrue;
 337  0
                 }
 338  
 
 339  
                 public void setWhenFalse(AgendaItem.Builder whenFalse) {
 340  0
                         this.whenTrue = whenFalse;
 341  0
                 }
 342  
 
 343  
                 public void setAlways(AgendaItem.Builder always) {
 344  0
                         this.always = always;
 345  0
                 }
 346  
 
 347  
                 public void setVersionNumber(Long versionNumber){
 348  0
             this.versionNumber = versionNumber;
 349  0
         }
 350  
                         
 351  
                 @Override
 352  
                 public String getId() {
 353  0
                         return id;
 354  
                 }
 355  
 
 356  
                 @Override
 357  
                 public String getAgendaId() {
 358  0
                         return agendaId;
 359  
                 }
 360  
 
 361  
                 @Override
 362  
                 public String getRuleId() {
 363  0
                         return ruleId;
 364  
                 }
 365  
 
 366  
                 @Override
 367  
                 public String getSubAgendaId() {
 368  0
                         return subAgendaId;
 369  
                 }
 370  
 
 371  
                 @Override
 372  
                 public String getWhenTrueId() {
 373  0
                         return whenTrueId;
 374  
                 }
 375  
 
 376  
                 @Override
 377  
                 public String getWhenFalseId() {
 378  0
                         return whenFalseId;
 379  
                 }
 380  
 
 381  
                 @Override
 382  
                 public String getAlwaysId() {
 383  0
                         return alwaysId;
 384  
                 }
 385  
 
 386  
                 @Override
 387  
                 public RuleDefinition.Builder getRule() {
 388  0
                         return rule;
 389  
                 }
 390  
 
 391  
                 @Override
 392  
                 public AgendaDefinition.Builder getSubAgenda() {
 393  0
                         return subAgenda;
 394  
                 }
 395  
 
 396  
                 @Override
 397  
                 public AgendaItem.Builder getWhenTrue() {
 398  0
                         return whenTrue;
 399  
                 }
 400  
 
 401  
                 @Override
 402  
                 public AgendaItem.Builder getWhenFalse() {
 403  0
                         return whenFalse;
 404  
                 }
 405  
 
 406  
                 @Override
 407  
                 public AgendaItem.Builder getAlways() {
 408  0
                         return always;
 409  
                 }
 410  
 
 411  
         @Override
 412  
         public Long getVersionNumber() {
 413  0
             return versionNumber;
 414  
         }
 415  
 
 416  
                 /**
 417  
                  * Builds an instance of a AgendaItem based on the current state of the builder.
 418  
                  * 
 419  
                  * @return the fully-constructed AgendaItem
 420  
                  */
 421  
         @Override
 422  
         public AgendaItem build() {
 423  0
             return new AgendaItem(this);
 424  
         }
 425  
                 
 426  
     }
 427  
         
 428  
         /**
 429  
          * Defines some internal constants used on this class.
 430  
          */
 431  0
         static class Constants {
 432  
                 final static String ROOT_ELEMENT_NAME = "AgendaItem";
 433  
                 final static String TYPE_NAME = "AgendaItemType";
 434  
         }
 435  
         
 436  
         /**
 437  
          * A private class which exposes constants which define the XML element names to use
 438  
          * when this object is marshalled to XML.
 439  
          */
 440  0
         public static class Elements {
 441  
                 final static String ID = "id";
 442  
                 final static String AGENDA_ID = "agendaId";
 443  
                 final static String RULE_ID = "ruleId";
 444  
                 final static String SUB_AGENDA_ID = "subAgendaId";
 445  
                 final static String WHEN_TRUE_ID = "whenTrueId";
 446  
                 final static String WHEN_FALSE_ID = "whenFalseId";
 447  
                 final static String ALWAYS_ID = "alwaysId";
 448  
 
 449  
                 final static String RULE = "rule";
 450  
                 final static String SUB_AGENDA = "subAgenda";
 451  
                 final static String WHEN_TRUE = "whenTrue";
 452  
                 final static String WHEN_FALSE = "whenFalse";
 453  
                 final static String ALWAYS = "always";
 454  
         }
 455  
 
 456  
 }