001 package org.kuali.ole.patron.api;
002
003 import org.apache.commons.lang.StringUtils;
004 import org.kuali.rice.core.api.CoreConstants;
005 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
006 import org.kuali.rice.core.api.mo.ModelBuilder;
007 import org.kuali.rice.kim.api.KimConstants;
008 import org.w3c.dom.Element;
009
010 import javax.xml.bind.annotation.*;
011 import java.io.Serializable;
012 import java.util.Collection;
013
014 /**
015 * Created with IntelliJ IDEA.
016 * User: ?
017 * Date: 5/24/12
018 * Time: 8:26 PM
019 * To change this template use File | Settings | File Templates.
020 */
021 @XmlRootElement(name = OleStatisticalCategoryDefinition.Constants.ROOT_ELEMENT_NAME)
022 @XmlAccessorType(XmlAccessType.NONE)
023 @XmlType(name = OleStatisticalCategoryDefinition.Constants.TYPE_NAME, propOrder = {
024 OleStatisticalCategoryDefinition.Elements.OLE_STATISTICAL_CATEGORY_ID,
025 OleStatisticalCategoryDefinition.Elements.OLE_STATISTICAL_CATEGORY_CODE,
026 OleStatisticalCategoryDefinition.Elements.OLE_STATISTICAL_CATEGORY_NAME,
027 OleStatisticalCategoryDefinition.Elements.OLE_STATISTICAL_CATEGORY_DESC,
028 OleStatisticalCategoryDefinition.Elements.ACTIVE_INDICATOR,
029
030 CoreConstants.CommonElements.VERSION_NUMBER,
031 //CoreConstants.CommonElements.OBJECT_ID,
032 CoreConstants.CommonElements.FUTURE_ELEMENTS
033 })
034 public final class OleStatisticalCategoryDefinition extends AbstractDataTransferObject implements OleStatisticalCategoryContract{
035
036 private static final long serialVersionUID = 1L;
037
038
039
040 @XmlElement(name = Elements.OLE_STATISTICAL_CATEGORY_ID, required = false)
041 private final String oleStatisticalCategoryId;
042
043 @XmlElement(name = Elements.OLE_STATISTICAL_CATEGORY_CODE, required = false)
044 private final String oleStatisticalCategoryCode;
045
046 @XmlElement(name = Elements.OLE_STATISTICAL_CATEGORY_NAME, required = false)
047 private final String oleStatisticalCategoryName;
048
049 @XmlElement(name = Elements.OLE_STATISTICAL_CATEGORY_DESC, required = false)
050 private final String oleStatisticalCategoryDesc;
051
052 @XmlElement(name = Elements.ACTIVE_INDICATOR, required = false)
053 private final boolean active;
054
055 @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
056 private final Long versionNumber;
057
058 /*@XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
059 private final String objectId;*/
060 @SuppressWarnings("unused")
061 @XmlAnyElement
062 private final Collection<Element> _futureElements = null;
063
064 public OleStatisticalCategoryDefinition() {
065 this.oleStatisticalCategoryId = null;
066 this.oleStatisticalCategoryCode = null;
067 this.oleStatisticalCategoryName = null;
068 this.active = false;
069 this.oleStatisticalCategoryDesc = null;
070 this.versionNumber = null;
071 //this.objectId = null;
072 }
073
074
075 private OleStatisticalCategoryDefinition(Builder builder) {
076 this.oleStatisticalCategoryId = builder.getOleStatisticalCategoryId();
077 this.oleStatisticalCategoryCode = builder.getOleStatisticalCategoryCode();
078 this.oleStatisticalCategoryName = builder.getOleStatisticalCategoryName();
079 this.oleStatisticalCategoryDesc = builder.getOleStatisticalCategoryDesc();
080 this.active = builder.isActive();
081
082 this.versionNumber = builder.getVersionNumber();
083 //this.objectId = builder.getObjectId();
084 }
085
086
087 @Override
088 public String getOleStatisticalCategoryId() {
089 return this.oleStatisticalCategoryId;
090 }
091
092 @Override
093 public String getOleStatisticalCategoryCode() {
094 return this.oleStatisticalCategoryCode;
095 }
096
097 @Override
098 public String getOleStatisticalCategoryName() {
099 return this.oleStatisticalCategoryName;
100 }
101
102 @Override
103 public String getOleStatisticalCategoryDesc() {
104 return this.oleStatisticalCategoryDesc;
105 }
106
107 @Override
108 public boolean isActive() {
109 return this.active;
110 };
111
112
113 @Override
114 public String getId() {
115 return this.oleStatisticalCategoryId;
116 }
117
118
119 @Override
120 public Long getVersionNumber() {
121 return this.versionNumber;
122 }
123
124
125 //@Override
126 /*public OleBorrowerTypeDefinition getOleBorrowerType() {
127 return this.oleBorrowerType;
128 }*/
129
130 public static class Builder
131 implements Serializable, ModelBuilder, OleStatisticalCategoryContract
132 {
133
134 private String oleStatisticalCategoryId;
135 private String oleStatisticalCategoryCode;
136 private String oleStatisticalCategoryName;
137 private String oleStatisticalCategoryDesc;
138 private boolean active;
139
140 private Long versionNumber;
141 private String objectId;
142
143 private Builder() { }
144
145 public static Builder create() {
146 return new Builder();
147 }
148
149 public static Builder create(OleStatisticalCategoryContract contract) {
150 if(contract == null) {
151 throw new IllegalArgumentException("contract was null");
152 }
153 Builder builder = create();
154 if (contract.getOleStatisticalCategoryId() != null) {
155 builder.setOleStatisticalCategoryId(contract.getOleStatisticalCategoryId());
156 }
157 if(contract.getOleStatisticalCategoryCode() != null) {
158 builder.setOleStatisticalCategoryCode(contract.getOleStatisticalCategoryCode());
159 }
160 if(contract.getOleStatisticalCategoryName() != null) {
161 builder.setOleStatisticalCategoryName(contract.getOleStatisticalCategoryName());
162 }
163 if(contract.isActive()) {
164 builder.setActive(contract.isActive());
165 }
166 if(contract.getOleStatisticalCategoryDesc() != null) {
167 builder.setOleStatisticalCategoryDesc(contract.getOleStatisticalCategoryDesc());
168 }
169
170 builder.setVersionNumber(contract.getVersionNumber());
171 /*builder.setObjectId(contract.getObjectId());
172 builder.setActive(contract.isActive());*/
173 builder.setId(contract.getId());
174 return builder;
175 }
176
177
178 public OleStatisticalCategoryDefinition build() {
179 return new OleStatisticalCategoryDefinition(this);
180 }
181
182 public String getOleStatisticalCategoryId() {
183 return oleStatisticalCategoryId;
184 }
185
186 public void setOleStatisticalCategoryId(String oleStatisticalCategoryId) {
187 this.oleStatisticalCategoryId = oleStatisticalCategoryId;
188 }
189
190 public String getOleStatisticalCategoryCode() {
191 return oleStatisticalCategoryCode;
192 }
193
194 public void setOleStatisticalCategoryCode(String oleStatisticalCategoryCode) {
195 this.oleStatisticalCategoryCode = oleStatisticalCategoryCode;
196 }
197
198 public String getOleStatisticalCategoryName() {
199 return oleStatisticalCategoryName;
200 }
201
202 public void setOleStatisticalCategoryName(String oleStatisticalCategoryName) {
203 this.oleStatisticalCategoryName = oleStatisticalCategoryName;
204 }
205
206 public String getOleStatisticalCategoryDesc() {
207 return oleStatisticalCategoryDesc;
208 }
209
210 public void setOleStatisticalCategoryDesc(String oleStatisticalCategoryDesc) {
211 this.oleStatisticalCategoryDesc = oleStatisticalCategoryDesc;
212 }
213
214 public boolean isActive() {
215 return active;
216 }
217
218 public void setActive(boolean active) {
219 this.active = active;
220 }
221
222 @Override
223 public Long getVersionNumber() {
224 return versionNumber;
225 }
226
227 public void setVersionNumber(Long versionNumber) {
228 this.versionNumber = versionNumber;
229 }
230
231 /*@Override
232 public String getObjectId() {
233 return objectId;
234 }*/
235
236 public void setObjectId(String objectId) {
237 this.objectId = objectId;
238 }
239
240 @Override
241 public String getId() {
242 return this.oleStatisticalCategoryId;
243 }
244
245
246
247 public void setId(String id) {
248 if (StringUtils.isWhitespace(id)) {
249 throw new IllegalArgumentException("id is blank");
250 }
251 this.oleStatisticalCategoryId = id;
252 }
253 }
254
255 static class Constants {
256
257 final static String ROOT_ELEMENT_NAME = "oleStatisticalCategory";
258 final static String TYPE_NAME = "oleStatisticalCategoryType";
259 final static String[] HASH_CODE_EQUALS_EXCLUDE = new String[] {CoreConstants.CommonElements.FUTURE_ELEMENTS };
260 }
261
262 static class Elements {
263 final static String OLE_STATISTICAL_CATEGORY_ID = "oleStatisticalCategoryId";
264 final static String OLE_STATISTICAL_CATEGORY_CODE = "oleStatisticalCategoryCode";
265 final static String OLE_STATISTICAL_CATEGORY_NAME = "oleStatisticalCategoryName";
266 final static String OLE_STATISTICAL_CATEGORY_DESC = "oleStatisticalCategoryDesc";
267 final static String ACTIVE_INDICATOR = "active";
268 //final static String ENTITY_ID = "entityId";
269
270 }
271 public static class Cache {
272 public static final String NAME = KimConstants.Namespaces.KIM_NAMESPACE_2_0 + "/" + Constants.TYPE_NAME;
273 }
274 }