View Javadoc

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