View Javadoc
1   package org.kuali.ole.deliver.api;
2   
3   import org.kuali.rice.core.api.CoreConstants;
4   import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
5   import org.kuali.rice.core.api.mo.ModelBuilder;
6   import org.kuali.rice.krms.api.KrmsConstants;
7   import org.w3c.dom.Element;
8   
9   import javax.xml.bind.annotation.*;
10  import java.io.Serializable;
11  import java.util.Collection;
12  
13  /**
14   * Created with IntelliJ IDEA.
15   * User: ?
16   * Date: 5/28/12
17   * Time: 12:09 PM
18   * To change this template use File | Settings | File Templates.
19   */
20  @XmlRootElement(name = OlePatronNotesDefinition.Constants.ROOT_ELEMENT_NAME)
21  @XmlAccessorType(XmlAccessType.NONE)
22  @XmlType(name = OlePatronNotesDefinition.Constants.TYPE_NAME, propOrder = {
23          OlePatronNotesDefinition.Elements.NOTE_ID,
24          OlePatronNotesDefinition.Elements.PATRON_ID,
25          // OlePatronNotesDefinition.Elements.NOTE_TYPE_ID,
26          OlePatronNotesDefinition.Elements.NOTE_TEXT,
27          OlePatronNotesDefinition.Elements.NOTE_TYPE,
28          OlePatronNotesDefinition.Elements.ACTIVE,
29          //OlePatronNotesDefinition.Elements.PATRON,
30          CoreConstants.CommonElements.OBJECT_ID,
31          CoreConstants.CommonElements.VERSION_NUMBER,
32          CoreConstants.CommonElements.FUTURE_ELEMENTS
33  })
34  public class OlePatronNotesDefinition extends AbstractDataTransferObject implements OlePatronNotesContract {
35  
36      private static final long serialVersionUID = 1L;
37  
38      @XmlElement(name = Elements.NOTE_ID, required = false)
39      private final String patronNoteId;
40      @XmlElement(name = Elements.PATRON_ID, required = false)
41      private final String olePatronId;
42      //@XmlElement(name = Elements.NOTE_TYPE_ID, required = false)
43      private final String patronNoteTypeId;
44      @XmlElement(name = Elements.NOTE_TEXT, required = false)
45      private final String patronNoteText;
46      @XmlElement(name = Elements.NOTE_TYPE, required = false)
47      private final OlePatronNoteTypeDefinition olePatronNoteType;
48      //@XmlElement(name = Elements.PATRON, required = false)
49      //private final OlePatronDefinition olePatron;
50  
51      @XmlElement(name = CoreConstants.CommonElements.ACTIVE, required = false)
52      private final boolean active;
53  
54      @XmlElement(name = CoreConstants.CommonElements.OBJECT_ID, required = false)
55      private final String objectId;
56  
57  
58      @XmlElement(name = CoreConstants.CommonElements.VERSION_NUMBER, required = false)
59      private final Long versionNumber;
60  
61      @SuppressWarnings("unused")
62      @XmlAnyElement
63      private final Collection<Element> _futureElements = null;
64  
65      public OlePatronNotesDefinition() {
66          patronNoteId = null;
67          olePatronId = null;
68          patronNoteTypeId = null;
69          patronNoteText = null;
70          olePatronNoteType = null;
71          //olePatron = null;
72          versionNumber = null;
73          active = false;
74          objectId = null;
75      }
76  
77      public OlePatronNotesDefinition(Builder builder) {
78          patronNoteId = builder.getPatronNoteId();
79          olePatronId = builder.getOlePatronId();
80          patronNoteTypeId = builder.getOlePatronNoteType().getPatronNoteTypeId();
81          patronNoteText = builder.getPatronNoteText();
82          olePatronNoteType = builder.getOlePatronNoteType().build();
83          //olePatron = builder.getOlePatron().build();
84          versionNumber = builder.getVersionNumber();
85          active = builder.isActive();
86          objectId = builder.getObjectId();
87      }
88  
89      public static class Builder implements OlePatronNotesContract, ModelBuilder, Serializable {
90          private static final long serialVersionUID = 1L;
91          public String patronNoteId;
92          public String olePatronId;
93          public String patronNoteTypeId;
94          public String patronNoteText;
95          public OlePatronNoteTypeDefinition.Builder olePatronNoteType;
96          public OlePatronDefinition.Builder olePatron;
97          public Long versionNumber;
98          public boolean active;
99          public String objectId;
100 
101         private Builder(String patronNoteId, String olePatronId,
102                         String patronNoteText,
103                         OlePatronNoteTypeDefinition.Builder olePatronNoteType) {
104             //OlePatronDefinition.Builder olePatron) {
105 
106             setOlePatronId(olePatronId);
107             setPatronNoteText(patronNoteText);
108             setOlePatronNoteType(olePatronNoteType);
109             setPatronNoteTypeId(olePatronNoteType.getId());
110             setPatronNoteId(patronNoteId);
111 //            setOlePatron(olePatron);
112 //            setOlePatron(olePatron);
113 
114         }
115 
116         public static Builder create(String patronNoteId, String olePatronId,
117                                      String patronNoteText,
118                                      OlePatronNoteTypeDefinition.Builder olePatronNoteType) {
119             //OlePatronDefinition.Builder olePatron) {
120             return new Builder(patronNoteId, olePatronId, patronNoteText, olePatronNoteType);
121         }
122 
123         public static Builder create(OlePatronNotesContract patronNotesDefinition) {
124             Builder builder = Builder.create(patronNotesDefinition.getPatronNoteId(),
125                     patronNotesDefinition.getOlePatronId(),
126                     patronNotesDefinition.getPatronNoteText(),
127                     OlePatronNoteTypeDefinition.Builder.create(patronNotesDefinition.getOlePatronNoteType()));
128             //OlePatronDefinition.Builder.create(patronNotesDefinition.getOlePatron()));
129             builder.setVersionNumber(patronNotesDefinition.getVersionNumber());
130             builder.setActive(patronNotesDefinition.isActive());
131             builder.setObjectId(patronNotesDefinition.getObjectId());
132             return builder;
133 
134         }
135 
136         @Override
137         public String getPatronNoteId() {
138             return this.patronNoteId;
139         }
140 
141         @Override
142         public String getOlePatronId() {
143             return this.olePatronId;
144         }
145 
146         @Override
147         public String getPatronNoteText() {
148             return this.patronNoteText;
149         }
150 
151         @Override
152         public OlePatronNoteTypeDefinition.Builder getOlePatronNoteType() {
153             return this.olePatronNoteType;
154         }
155 
156 
157         public OlePatronDefinition.Builder getOlePatron() {
158             return this.olePatron;
159         }
160 
161         @Override
162         public Long getVersionNumber() {
163             return this.versionNumber;
164         }
165 
166         @Override
167         public String getId() {
168             return this.patronNoteId;
169         }
170 
171         @Override
172         public boolean isActive() {
173             return this.active;
174         }
175 
176         @Override
177         public String getObjectId() {
178             return this.objectId;
179         }
180 
181         public void setObjectId(String objectId) {
182             this.objectId = objectId;
183         }
184 
185         public void setPatronNoteId(String patronNoteId) {
186             this.patronNoteId = patronNoteId;
187         }
188 
189         public void setOlePatronId(String olePatronId) {
190             this.olePatronId = olePatronId;
191         }
192 
193         public void setPatronNoteTypeId(String patronNoteTypeId) {
194             this.patronNoteTypeId = patronNoteTypeId;
195         }
196 
197         public void setPatronNoteText(String patronNoteText) {
198             this.patronNoteText = patronNoteText;
199         }
200 
201         public void setOlePatronNoteType(OlePatronNoteTypeDefinition.Builder olePatronNoteType) {
202             this.olePatronNoteType = olePatronNoteType;
203         }
204 
205         public void setOlePatron(OlePatronDefinition.Builder olePatron) {
206             this.olePatron = olePatron;
207         }
208 
209         public void setVersionNumber(Long versionNumber) {
210             this.versionNumber = versionNumber;
211         }
212 
213         public void setActive(boolean active) {
214             this.active = active;
215         }
216 
217         @Override
218         public OlePatronNotesDefinition build() {
219             return new OlePatronNotesDefinition(this);
220         }
221     }
222 
223     @Override
224     public String getPatronNoteId() {
225         return this.patronNoteId;
226     }
227 
228     @Override
229     public String getOlePatronId() {
230         return this.olePatronId;
231     }
232 
233     @Override
234     public String getPatronNoteText() {
235         return this.patronNoteText;
236     }
237 
238     @Override
239     public OlePatronNoteTypeDefinition getOlePatronNoteType() {
240         return this.olePatronNoteType;
241     }
242 
243     @Override
244     public boolean isActive() {
245         return this.active;
246     }
247 
248     @Override
249     public String getId() {
250         return this.patronNoteId;
251     }
252 
253     @Override
254     public Long getVersionNumber() {
255         return this.versionNumber;
256     }
257 
258     @Override
259     public String getObjectId() {
260         return this.objectId;
261     }
262 
263     /*public OlePatronDefinition getOlePatron() {
264         return this.olePatron;
265     }*/
266     static class Constants {
267         public static final String ROOT_ELEMENT_NAME = "olePatronNotesDefinition";
268         public static final String TYPE_NAME = "olePatronNotesDefinitionType";
269     }
270 
271     static class Elements {
272         public static final String NOTE_ID = "patronNoteId";
273         public static final String PATRON_ID = "olePatronId";
274         public static final String NOTE_TYPE_ID = "patronNoteTypeId";
275         public static final String NOTE_TEXT = "patronNoteText";
276         public static final String NOTE_TYPE = "olePatronNoteType";
277         public static final String PATRON = "olePatron";
278         public static final String ACTIVE = "active";
279     }
280 
281     public static class Cache {
282         public static final String NAME = KrmsConstants.Namespaces.KRMS_NAMESPACE_2_0 + "/" + Constants.TYPE_NAME;
283     }
284 }