| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.kew.api.repository.type; |
| 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 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | 0 | @XmlRootElement(name = KewTypeAttribute.Constants.ROOT_ELEMENT_NAME) |
| 40 | |
@XmlAccessorType(XmlAccessType.NONE) |
| 41 | |
@XmlType(name = KewTypeAttribute.Constants.TYPE_NAME, propOrder = { |
| 42 | |
KewTypeAttribute.Elements.ID, |
| 43 | |
KewTypeAttribute.Elements.TYPE_ID, |
| 44 | |
KewTypeAttribute.Elements.ATTR_DEFN_ID, |
| 45 | |
KewTypeAttribute.Elements.SEQ_NO, |
| 46 | |
KewTypeAttribute.Elements.ACTIVE, |
| 47 | |
KewTypeAttribute.Elements.ATTR_DEFN, |
| 48 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
| 49 | |
}) |
| 50 | 7 | public final class KewTypeAttribute extends AbstractDataTransferObject implements KewTypeAttributeContract { |
| 51 | |
private static final long serialVersionUID = -304265575559412478L; |
| 52 | |
|
| 53 | |
@XmlElement(name = Elements.ID, required=true) |
| 54 | |
private String id; |
| 55 | |
@XmlElement(name = Elements.TYPE_ID, required=true) |
| 56 | |
private String typeId; |
| 57 | |
@XmlElement(name = Elements.ATTR_DEFN_ID, required=true) |
| 58 | |
private String attributeDefinitionId; |
| 59 | |
@XmlElement(name = Elements.SEQ_NO, required=true) |
| 60 | |
private Integer sequenceNumber; |
| 61 | |
@XmlElement(name = Elements.ACTIVE, required=false) |
| 62 | |
private boolean active; |
| 63 | |
@XmlElement(name = Elements.ATTR_DEFN, required=false) |
| 64 | |
private KewAttributeDefinition attributeDefinition; |
| 65 | |
|
| 66 | 16 | @SuppressWarnings("unused") |
| 67 | |
@XmlAnyElement |
| 68 | |
private final Collection<org.w3c.dom.Element> _futureElements = null; |
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | 9 | private KewTypeAttribute() { |
| 74 | 9 | this.id = null; |
| 75 | 9 | this.typeId = null; |
| 76 | 9 | this.attributeDefinitionId = null; |
| 77 | 9 | this.sequenceNumber = null; |
| 78 | 9 | this.active = false; |
| 79 | 9 | this.attributeDefinition = null; |
| 80 | 9 | } |
| 81 | |
|
| 82 | |
|
| 83 | |
|
| 84 | |
|
| 85 | |
|
| 86 | |
|
| 87 | |
|
| 88 | 7 | private KewTypeAttribute(Builder builder) { |
| 89 | 7 | this.id = builder.getId(); |
| 90 | 7 | this.typeId = builder.getTypeId(); |
| 91 | 7 | this.attributeDefinitionId = builder.getAttributeDefinitionId(); |
| 92 | 7 | this.sequenceNumber = builder.getSequenceNumber(); |
| 93 | 7 | this.active = builder.isActive(); |
| 94 | 7 | if (builder.getAttributeDefinition() != null) { |
| 95 | 0 | this.attributeDefinition = builder.getAttributeDefinition().build(); |
| 96 | |
} |
| 97 | 7 | } |
| 98 | |
|
| 99 | |
public String getId() { |
| 100 | 2 | return this.id; |
| 101 | |
} |
| 102 | |
|
| 103 | |
public String getTypeId() { |
| 104 | 2 | return this.typeId; |
| 105 | |
} |
| 106 | |
|
| 107 | |
public String getAttributeDefinitionId() { |
| 108 | 2 | return this.attributeDefinitionId; |
| 109 | |
} |
| 110 | |
|
| 111 | |
public Integer getSequenceNumber() { |
| 112 | 2 | return this.sequenceNumber; |
| 113 | |
} |
| 114 | |
|
| 115 | |
public boolean isActive() { |
| 116 | 2 | return this.active; |
| 117 | |
} |
| 118 | |
|
| 119 | |
public KewAttributeDefinition getAttributeDefinition() { |
| 120 | 0 | return this.attributeDefinition; |
| 121 | |
} |
| 122 | |
|
| 123 | |
|
| 124 | |
|
| 125 | |
|
| 126 | 3 | public static class Builder implements KewTypeAttributeContract, ModelBuilder, Serializable { |
| 127 | |
private static final long serialVersionUID = 2729964674427296346L; |
| 128 | |
|
| 129 | |
private String id; |
| 130 | |
private String typeId; |
| 131 | |
private String attributeDefinitionId; |
| 132 | |
private Integer sequenceNumber; |
| 133 | |
private boolean active; |
| 134 | |
private KewAttributeDefinition.Builder attributeDefinition; |
| 135 | |
|
| 136 | |
|
| 137 | |
|
| 138 | |
|
| 139 | 19 | private Builder(String id, String typeId, String attributeDefinitionId, Integer sequenceNumber) { |
| 140 | 19 | setId(id); |
| 141 | 17 | setTypeId(typeId); |
| 142 | 15 | setAttributeDefinitionId(attributeDefinitionId); |
| 143 | 11 | setSequenceNumber(sequenceNumber); |
| 144 | 10 | setActive(true); |
| 145 | 10 | } |
| 146 | |
|
| 147 | |
public Builder attributeDefinition(KewAttributeDefinition.Builder attributeDefinition){ |
| 148 | 0 | setAttributeDefinition(attributeDefinition); |
| 149 | 0 | return this; |
| 150 | |
} |
| 151 | |
|
| 152 | |
|
| 153 | |
|
| 154 | |
|
| 155 | |
|
| 156 | |
|
| 157 | |
|
| 158 | |
|
| 159 | |
|
| 160 | |
|
| 161 | |
|
| 162 | |
public static Builder create(String id, String typeId, String attributeDefinitionId, Integer sequenceNumber) { |
| 163 | 19 | return new Builder(id, typeId, attributeDefinitionId, sequenceNumber); |
| 164 | |
} |
| 165 | |
|
| 166 | |
public static Builder create(KewTypeAttributeContract contract){ |
| 167 | 0 | if (contract == null) { |
| 168 | 0 | throw new IllegalArgumentException("contract is null"); |
| 169 | |
} |
| 170 | 0 | Builder builder = new Builder(contract.getId(), |
| 171 | |
contract.getTypeId(), |
| 172 | |
contract.getAttributeDefinitionId(), |
| 173 | |
contract.getSequenceNumber()); |
| 174 | 0 | if (contract.getAttributeDefinition() != null){ |
| 175 | 0 | KewAttributeDefinition.Builder attrBuilder = |
| 176 | |
KewAttributeDefinition.Builder.create(contract.getAttributeDefinition()); |
| 177 | 0 | builder.setAttributeDefinition(attrBuilder); |
| 178 | |
} |
| 179 | 0 | return builder; |
| 180 | |
} |
| 181 | |
|
| 182 | |
|
| 183 | |
|
| 184 | |
|
| 185 | |
|
| 186 | |
|
| 187 | |
|
| 188 | |
public void setId(String id) { |
| 189 | 19 | if (null != id && StringUtils.isBlank(id)) { |
| 190 | 2 | throw new IllegalArgumentException("id must be null or non-blank"); |
| 191 | |
} |
| 192 | 17 | this.id = id; |
| 193 | 17 | } |
| 194 | |
|
| 195 | |
public void setTypeId(String typeId) { |
| 196 | 17 | if (null != typeId && StringUtils.isBlank(typeId)) { |
| 197 | 2 | throw new IllegalArgumentException("typeId must be null or non-blank"); |
| 198 | |
} |
| 199 | 15 | this.typeId = typeId; |
| 200 | 15 | } |
| 201 | |
|
| 202 | |
public void setAttributeDefinitionId(String attributeDefinitionId) { |
| 203 | 15 | if (StringUtils.isBlank(attributeDefinitionId)) { |
| 204 | 4 | throw new IllegalArgumentException("the attribute definition id is blank"); |
| 205 | |
} |
| 206 | 11 | this.attributeDefinitionId = attributeDefinitionId; |
| 207 | 11 | } |
| 208 | |
|
| 209 | |
public void setSequenceNumber(Integer sequenceNumber) { |
| 210 | 11 | if (sequenceNumber == null){ |
| 211 | 1 | throw new IllegalArgumentException("the sequence number is null"); |
| 212 | |
} |
| 213 | 10 | this.sequenceNumber = sequenceNumber; |
| 214 | 10 | } |
| 215 | |
|
| 216 | |
public void setAttributeDefinition(KewAttributeDefinition.Builder attributeDefinition) { |
| 217 | 0 | this.attributeDefinition = attributeDefinition; |
| 218 | |
|
| 219 | 0 | } |
| 220 | |
|
| 221 | |
public void setActive(boolean active) { |
| 222 | 10 | this.active = active; |
| 223 | 10 | } |
| 224 | |
|
| 225 | |
public String getId() { |
| 226 | 7 | return id; |
| 227 | |
} |
| 228 | |
|
| 229 | |
public String getTypeId() { |
| 230 | 7 | return typeId; |
| 231 | |
} |
| 232 | |
|
| 233 | |
public String getAttributeDefinitionId() { |
| 234 | 7 | return attributeDefinitionId; |
| 235 | |
} |
| 236 | |
|
| 237 | |
public Integer getSequenceNumber() { |
| 238 | 7 | return sequenceNumber; |
| 239 | |
} |
| 240 | |
|
| 241 | |
public KewAttributeDefinition.Builder getAttributeDefinition() { |
| 242 | 7 | return attributeDefinition; |
| 243 | |
} |
| 244 | |
|
| 245 | |
|
| 246 | |
public boolean isActive() { |
| 247 | 7 | return active; |
| 248 | |
} |
| 249 | |
|
| 250 | |
|
| 251 | |
|
| 252 | |
|
| 253 | |
|
| 254 | |
|
| 255 | |
@Override |
| 256 | |
public KewTypeAttribute build() { |
| 257 | 7 | return new KewTypeAttribute(this); |
| 258 | |
} |
| 259 | |
|
| 260 | |
} |
| 261 | |
|
| 262 | |
|
| 263 | |
|
| 264 | |
|
| 265 | 0 | static class Constants { |
| 266 | |
final static String ROOT_ELEMENT_NAME = "KewTypeAttribute"; |
| 267 | |
final static String TYPE_NAME = "KewTypeAttributeType"; |
| 268 | |
} |
| 269 | |
|
| 270 | |
|
| 271 | |
|
| 272 | |
|
| 273 | |
|
| 274 | 0 | public static class Elements { |
| 275 | |
final static String ID = "id"; |
| 276 | |
final static String TYPE_ID = "typeId"; |
| 277 | |
final static String ATTR_DEFN_ID = "attributeDefinitionId"; |
| 278 | |
final static String SEQ_NO = "sequenceNumber"; |
| 279 | |
final static String ACTIVE = "active"; |
| 280 | |
final static String ATTR_DEFN = "attributeDefinition"; |
| 281 | |
} |
| 282 | |
} |