| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.kew.api.rule; |
| 17 | |
|
| 18 | |
import java.io.Serializable; |
| 19 | |
import java.util.Collection; |
| 20 | |
import javax.xml.bind.annotation.XmlAccessType; |
| 21 | |
import javax.xml.bind.annotation.XmlAccessorType; |
| 22 | |
import javax.xml.bind.annotation.XmlAnyElement; |
| 23 | |
import javax.xml.bind.annotation.XmlElement; |
| 24 | |
import javax.xml.bind.annotation.XmlRootElement; |
| 25 | |
import javax.xml.bind.annotation.XmlType; |
| 26 | |
import org.kuali.rice.core.api.CoreConstants; |
| 27 | |
import org.kuali.rice.core.api.delegation.DelegationType; |
| 28 | |
import org.kuali.rice.core.api.mo.AbstractDataTransferObject; |
| 29 | |
import org.kuali.rice.core.api.mo.ModelBuilder; |
| 30 | |
import org.kuali.rice.kew.api.KewApiConstants; |
| 31 | |
import org.w3c.dom.Element; |
| 32 | |
|
| 33 | 0 | @XmlRootElement(name = RuleDelegation.Constants.ROOT_ELEMENT_NAME) |
| 34 | |
@XmlAccessorType(XmlAccessType.NONE) |
| 35 | |
@XmlType(name = RuleDelegation.Constants.TYPE_NAME, propOrder = { |
| 36 | |
RuleDelegation.Elements.DELEGATION_TYPE, |
| 37 | |
RuleDelegation.Elements.DELEGATION_RULE, |
| 38 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
| 39 | |
}) |
| 40 | 0 | public final class RuleDelegation |
| 41 | |
extends AbstractDataTransferObject |
| 42 | |
implements RuleDelegationContract |
| 43 | |
{ |
| 44 | |
|
| 45 | |
@XmlElement(name = Elements.DELEGATION_TYPE, required = false) |
| 46 | |
private final String delegationType; |
| 47 | |
@XmlElement(name = Elements.DELEGATION_RULE, required = false) |
| 48 | |
private final Rule delegationRule; |
| 49 | 0 | @SuppressWarnings("unused") |
| 50 | |
@XmlAnyElement |
| 51 | |
private final Collection<Element> _futureElements = null; |
| 52 | |
|
| 53 | |
|
| 54 | |
|
| 55 | |
|
| 56 | |
|
| 57 | 0 | private RuleDelegation() { |
| 58 | 0 | this.delegationType = null; |
| 59 | 0 | this.delegationRule = null; |
| 60 | 0 | } |
| 61 | |
|
| 62 | 0 | private RuleDelegation(Builder builder) { |
| 63 | 0 | this.delegationType = builder.getDelegationType() != null ? builder.getDelegationType().getCode() : null; |
| 64 | 0 | this.delegationRule = builder.getDelegationRule() == null ? null : builder.getDelegationRule().build(); |
| 65 | 0 | } |
| 66 | |
|
| 67 | |
@Override |
| 68 | |
public DelegationType getDelegationType() { |
| 69 | 0 | return DelegationType.fromCode(this.delegationType); |
| 70 | |
} |
| 71 | |
|
| 72 | |
@Override |
| 73 | |
public Rule getDelegationRule() { |
| 74 | 0 | return this.delegationRule; |
| 75 | |
} |
| 76 | |
|
| 77 | |
|
| 78 | |
|
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 82 | 0 | public final static class Builder |
| 83 | |
implements Serializable, ModelBuilder, RuleDelegationContract |
| 84 | |
{ |
| 85 | |
|
| 86 | |
private DelegationType delegationType; |
| 87 | |
private Rule.Builder delegationRule; |
| 88 | |
|
| 89 | 0 | private Builder() { |
| 90 | 0 | } |
| 91 | |
|
| 92 | |
public static Builder create() { |
| 93 | 0 | return new Builder(); |
| 94 | |
} |
| 95 | |
|
| 96 | |
public static Builder create(RuleDelegationContract contract) { |
| 97 | 0 | if (contract == null) { |
| 98 | 0 | throw new IllegalArgumentException("contract was null"); |
| 99 | |
} |
| 100 | 0 | Builder builder = create(); |
| 101 | 0 | builder.setDelegationType(contract.getDelegationType()); |
| 102 | 0 | if (contract.getDelegationRule() != null) { |
| 103 | 0 | builder.setDelegationRule(Rule.Builder.create(contract.getDelegationRule())); |
| 104 | |
} |
| 105 | 0 | return builder; |
| 106 | |
} |
| 107 | |
|
| 108 | |
public RuleDelegation build() { |
| 109 | 0 | return new RuleDelegation(this); |
| 110 | |
} |
| 111 | |
|
| 112 | |
@Override |
| 113 | |
public DelegationType getDelegationType() { |
| 114 | 0 | return this.delegationType; |
| 115 | |
} |
| 116 | |
|
| 117 | |
@Override |
| 118 | |
public Rule.Builder getDelegationRule() { |
| 119 | 0 | return this.delegationRule; |
| 120 | |
} |
| 121 | |
|
| 122 | |
public void setDelegationType(DelegationType delegationType) { |
| 123 | 0 | this.delegationType = delegationType; |
| 124 | 0 | } |
| 125 | |
|
| 126 | |
public void setDelegationRule(Rule.Builder delegationRule) { |
| 127 | 0 | this.delegationRule = delegationRule; |
| 128 | 0 | } |
| 129 | |
|
| 130 | |
} |
| 131 | |
|
| 132 | |
|
| 133 | |
|
| 134 | |
|
| 135 | |
|
| 136 | |
|
| 137 | 0 | static class Constants { |
| 138 | |
|
| 139 | |
final static String ROOT_ELEMENT_NAME = "ruleDelegation"; |
| 140 | |
final static String TYPE_NAME = "RuleDelegationType"; |
| 141 | |
|
| 142 | |
} |
| 143 | |
|
| 144 | |
|
| 145 | |
|
| 146 | |
|
| 147 | |
|
| 148 | |
|
| 149 | 0 | static class Elements { |
| 150 | |
|
| 151 | |
final static String DELEGATION_TYPE = "delegationType"; |
| 152 | |
final static String DELEGATION_RULE = "delegationRule"; |
| 153 | |
|
| 154 | |
} |
| 155 | |
|
| 156 | 0 | public static class Cache { |
| 157 | |
public static final String NAME = KewApiConstants.Namespaces.KEW_NAMESPACE_2_0 + "/" + RuleDelegation.Constants.TYPE_NAME; |
| 158 | |
} |
| 159 | |
} |