| 1 |  |   | 
  | 2 |  |   | 
  | 3 |  |   | 
  | 4 |  |   | 
  | 5 |  |   | 
  | 6 |  |   | 
  | 7 |  |   | 
  | 8 |  |   | 
  | 9 |  |   | 
  | 10 |  |   | 
  | 11 |  |   | 
  | 12 |  |   | 
  | 13 |  |   | 
  | 14 |  |   | 
  | 15 |  |   | 
  | 16 |  |  package org.kuali.rice.kew.api.validation; | 
  | 17 |  |   | 
  | 18 |  |  import org.kuali.rice.core.api.CoreConstants; | 
  | 19 |  |  import org.kuali.rice.core.api.mo.AbstractDataTransferObject; | 
  | 20 |  |  import org.kuali.rice.core.api.mo.ModelBuilder; | 
  | 21 |  |  import org.kuali.rice.kew.api.rule.Rule; | 
  | 22 |  |  import org.kuali.rice.kew.api.rule.RuleContract; | 
  | 23 |  |  import org.kuali.rice.kew.api.rule.RuleDelegation; | 
  | 24 |  |  import org.kuali.rice.kew.api.rule.RuleDelegationContract; | 
  | 25 |  |  import org.w3c.dom.Element; | 
  | 26 |  |   | 
  | 27 |  |  import javax.xml.bind.annotation.XmlAccessType; | 
  | 28 |  |  import javax.xml.bind.annotation.XmlAccessorType; | 
  | 29 |  |  import javax.xml.bind.annotation.XmlAnyElement; | 
  | 30 |  |  import javax.xml.bind.annotation.XmlElement; | 
  | 31 |  |  import javax.xml.bind.annotation.XmlRootElement; | 
  | 32 |  |  import javax.xml.bind.annotation.XmlType; | 
  | 33 |  |  import java.io.Serializable; | 
  | 34 |  |  import java.util.Collection; | 
  | 35 |  |   | 
  | 36 |  |   | 
  | 37 |  |   | 
  | 38 |  |   | 
  | 39 |  |   | 
  | 40 |  |   | 
  | 41 |  |   | 
  | 42 |  |   | 
  | 43 |  |   | 
  | 44 |  |   | 
  | 45 |  |   | 
  | 46 |  |   | 
  | 47 |  |   | 
  | 48 |  |   | 
  | 49 | 0 |  @XmlRootElement(name = RuleValidationContext.Constants.ROOT_ELEMENT_NAME) | 
  | 50 |  |  @XmlAccessorType(XmlAccessType.NONE) | 
  | 51 |  |  @XmlType(name = RuleValidationContext.Constants.TYPE_NAME, propOrder = { | 
  | 52 |  |      RuleValidationContext.Elements.RULE, | 
  | 53 |  |      RuleValidationContext.Elements.RULE_DELEGATION, | 
  | 54 |  |      RuleValidationContext.Elements.RULE_AUTHOR_PRINCIPAL_ID, | 
  | 55 |  |      CoreConstants.CommonElements.FUTURE_ELEMENTS | 
  | 56 |  |  }) | 
  | 57 | 0 |  public class RuleValidationContext | 
  | 58 |  |      extends AbstractDataTransferObject | 
  | 59 |  |      implements RuleValidationContextContract { | 
  | 60 |  |   | 
  | 61 |  |      @XmlElement(name = Elements.RULE, required = true) | 
  | 62 |  |          private final Rule rule; | 
  | 63 |  |      @XmlElement(name = Elements.RULE_DELEGATION, required = true) | 
  | 64 |  |          private final RuleDelegation ruleDelegation; | 
  | 65 |  |      @XmlElement(name = Elements.RULE_AUTHOR_PRINCIPAL_ID, required = false) | 
  | 66 |  |          private final String ruleAuthorPrincipalId; | 
  | 67 |  |   | 
  | 68 | 0 |      @SuppressWarnings("unused") | 
  | 69 |  |      @XmlAnyElement | 
  | 70 |  |      private final Collection<Element> _futureElements = null; | 
  | 71 |  |   | 
  | 72 |  |       | 
  | 73 |  |   | 
  | 74 |  |   | 
  | 75 | 0 |      private RuleValidationContext() { | 
  | 76 | 0 |          this.rule = null; | 
  | 77 | 0 |          this.ruleDelegation = null; | 
  | 78 | 0 |          this.ruleAuthorPrincipalId = null; | 
  | 79 | 0 |      } | 
  | 80 |  |   | 
  | 81 | 0 |      private RuleValidationContext(Builder builder) { | 
  | 82 | 0 |          this.rule = builder.getRule().build(); | 
  | 83 | 0 |          if (builder.getRuleDelegation() != null) { | 
  | 84 | 0 |              this.ruleDelegation = builder.getRuleDelegation().build(); | 
  | 85 |  |          } else { | 
  | 86 | 0 |              this.ruleDelegation = null; | 
  | 87 |  |          } | 
  | 88 | 0 |          this.ruleAuthorPrincipalId = builder.getRuleAuthorPrincipalId(); | 
  | 89 | 0 |      } | 
  | 90 |  |   | 
  | 91 |  |           | 
  | 92 |  |   | 
  | 93 |  |   | 
  | 94 |  |      @Override | 
  | 95 |  |          public Rule getRule() { | 
  | 96 | 0 |                  return rule; | 
  | 97 |  |          } | 
  | 98 |  |   | 
  | 99 |  |           | 
  | 100 |  |   | 
  | 101 |  |   | 
  | 102 |  |   | 
  | 103 |  |      @Override | 
  | 104 |  |          public String getRuleAuthorPrincipalId() { | 
  | 105 | 0 |                  return ruleAuthorPrincipalId; | 
  | 106 |  |          } | 
  | 107 |  |   | 
  | 108 |  |           | 
  | 109 |  |   | 
  | 110 |  |   | 
  | 111 |  |   | 
  | 112 |  |      @Override | 
  | 113 |  |          public RuleDelegation getRuleDelegation() { | 
  | 114 | 0 |                  return ruleDelegation; | 
  | 115 |  |          } | 
  | 116 |  |   | 
  | 117 |  |       | 
  | 118 |  |   | 
  | 119 |  |   | 
  | 120 |  |   | 
  | 121 | 0 |      public final static class Builder | 
  | 122 |  |          implements Serializable, ModelBuilder, RuleValidationContextContract | 
  | 123 |  |      { | 
  | 124 |  |   | 
  | 125 |  |          private Rule.Builder rule; | 
  | 126 |  |              private RuleDelegation.Builder ruleDelegation; | 
  | 127 |  |          private String ruleAuthorPrincipalId; | 
  | 128 |  |   | 
  | 129 | 0 |          private Builder() { | 
  | 130 | 0 |          } | 
  | 131 |  |   | 
  | 132 |  |          public static Builder create(RuleContract rule) { | 
  | 133 | 0 |              if (rule == null) { | 
  | 134 | 0 |                  throw new IllegalArgumentException("contract was null"); | 
  | 135 |  |              } | 
  | 136 | 0 |              Builder builder = new Builder(); | 
  | 137 | 0 |              builder.setRule(Rule.Builder.create(rule)); | 
  | 138 | 0 |              return builder; | 
  | 139 |  |          } | 
  | 140 |  |   | 
  | 141 |  |          public static Builder create(RuleValidationContextContract contract) { | 
  | 142 | 0 |              return Builder.create(contract.getRule(), contract.getRuleDelegation(), contract.getRuleAuthorPrincipalId()); | 
  | 143 |  |          } | 
  | 144 |  |   | 
  | 145 |  |           | 
  | 146 |  |   | 
  | 147 |  |   | 
  | 148 |  |   | 
  | 149 |  |          public static Builder create(RuleContract rule, RuleDelegationContract ruleDelegation, String ruleAuthorPrincipalId) { | 
  | 150 | 0 |              Builder builder = Builder.create(rule); | 
  | 151 | 0 |              if (ruleDelegation != null) { | 
  | 152 | 0 |                  builder.setRuleDelegation(RuleDelegation.Builder.create(ruleDelegation)); | 
  | 153 |  |              } | 
  | 154 | 0 |              builder.setRuleAuthorPrincipalId(ruleAuthorPrincipalId); | 
  | 155 | 0 |              return builder; | 
  | 156 |  |          } | 
  | 157 |  |   | 
  | 158 |  |          public RuleValidationContext build() { | 
  | 159 | 0 |              return new RuleValidationContext(this); | 
  | 160 |  |          } | 
  | 161 |  |   | 
  | 162 |  |          @Override | 
  | 163 |  |          public Rule.Builder getRule() { | 
  | 164 | 0 |              return this.rule; | 
  | 165 |  |          } | 
  | 166 |  |   | 
  | 167 |  |          @Override | 
  | 168 |  |          public RuleDelegation.Builder getRuleDelegation() { | 
  | 169 | 0 |              return this.ruleDelegation; | 
  | 170 |  |          } | 
  | 171 |  |   | 
  | 172 |  |          @Override | 
  | 173 |  |          public String getRuleAuthorPrincipalId() { | 
  | 174 | 0 |              return this.ruleAuthorPrincipalId; | 
  | 175 |  |          } | 
  | 176 |  |   | 
  | 177 |  |          public void setRule(Rule.Builder rule) { | 
  | 178 | 0 |              this.rule = rule; | 
  | 179 | 0 |          } | 
  | 180 |  |   | 
  | 181 |  |          public void setRuleDelegation(RuleDelegation.Builder ruleDelegation) { | 
  | 182 | 0 |              this.ruleDelegation = ruleDelegation; | 
  | 183 | 0 |          } | 
  | 184 |  |   | 
  | 185 |  |          public void setRuleAuthorPrincipalId(String ruleAuthorPrincipalId) { | 
  | 186 | 0 |              this.ruleAuthorPrincipalId = ruleAuthorPrincipalId; | 
  | 187 | 0 |          } | 
  | 188 |  |   | 
  | 189 |  |      } | 
  | 190 |  |   | 
  | 191 |  |       | 
  | 192 |  |   | 
  | 193 |  |   | 
  | 194 | 0 |      static class Constants { | 
  | 195 |  |          final static String ROOT_ELEMENT_NAME = "ruleValidationContext"; | 
  | 196 |  |          final static String TYPE_NAME = "RuleValidationContextType"; | 
  | 197 |  |      } | 
  | 198 |  |   | 
  | 199 |  |       | 
  | 200 |  |   | 
  | 201 |  |   | 
  | 202 | 0 |      static class Elements { | 
  | 203 |  |          final static String RULE = "rule"; | 
  | 204 |  |          final static String RULE_DELEGATION = "ruleDelegation"; | 
  | 205 |  |          final static String RULE_AUTHOR_PRINCIPAL_ID = "ruleAuthorPrincipalId"; | 
  | 206 |  |      } | 
  | 207 |  |  } |