1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portlet.announcements.model.impl;
21  
22  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23  import com.liferay.portal.kernel.util.GetterUtil;
24  import com.liferay.portal.kernel.util.HtmlUtil;
25  import com.liferay.portal.model.impl.BaseModelImpl;
26  
27  import com.liferay.portlet.announcements.model.AnnouncementsDelivery;
28  import com.liferay.portlet.announcements.model.AnnouncementsDeliverySoap;
29  import com.liferay.portlet.expando.model.ExpandoBridge;
30  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
31  
32  import java.io.Serializable;
33  
34  import java.lang.reflect.Proxy;
35  
36  import java.sql.Types;
37  
38  import java.util.ArrayList;
39  import java.util.List;
40  
41  /**
42   * <a href="AnnouncementsDeliveryModelImpl.java.html"><b><i>View Source</i></b></a>
43   *
44   * <p>
45   * ServiceBuilder generated this class. Modifications in this class will be
46   * overwritten the next time is generated.
47   * </p>
48   *
49   * <p>
50   * This class is a model that represents the <code>AnnouncementsDelivery</code> table
51   * in the database.
52   * </p>
53   *
54   * @author Brian Wing Shun Chan
55   *
56   * @see com.liferay.portlet.announcements.model.AnnouncementsDelivery
57   * @see com.liferay.portlet.announcements.model.AnnouncementsDeliveryModel
58   * @see com.liferay.portlet.announcements.model.impl.AnnouncementsDeliveryImpl
59   *
60   */
61  public class AnnouncementsDeliveryModelImpl extends BaseModelImpl<AnnouncementsDelivery> {
62      public static final String TABLE_NAME = "AnnouncementsDelivery";
63      public static final Object[][] TABLE_COLUMNS = {
64              { "deliveryId", new Integer(Types.BIGINT) },
65              
66  
67              { "companyId", new Integer(Types.BIGINT) },
68              
69  
70              { "userId", new Integer(Types.BIGINT) },
71              
72  
73              { "type_", new Integer(Types.VARCHAR) },
74              
75  
76              { "email", new Integer(Types.BOOLEAN) },
77              
78  
79              { "sms", new Integer(Types.BOOLEAN) },
80              
81  
82              { "website", new Integer(Types.BOOLEAN) }
83          };
84      public static final String TABLE_SQL_CREATE = "create table AnnouncementsDelivery (deliveryId LONG not null primary key,companyId LONG,userId LONG,type_ VARCHAR(75) null,email BOOLEAN,sms BOOLEAN,website BOOLEAN)";
85      public static final String TABLE_SQL_DROP = "drop table AnnouncementsDelivery";
86      public static final String DATA_SOURCE = "liferayDataSource";
87      public static final String SESSION_FACTORY = "liferaySessionFactory";
88      public static final String TX_MANAGER = "liferayTransactionManager";
89      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
90                  "value.object.entity.cache.enabled.com.liferay.portlet.announcements.model.AnnouncementsDelivery"),
91              true);
92      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
93                  "value.object.finder.cache.enabled.com.liferay.portlet.announcements.model.AnnouncementsDelivery"),
94              true);
95  
96      public static AnnouncementsDelivery toModel(
97          AnnouncementsDeliverySoap soapModel) {
98          AnnouncementsDelivery model = new AnnouncementsDeliveryImpl();
99  
100         model.setDeliveryId(soapModel.getDeliveryId());
101         model.setCompanyId(soapModel.getCompanyId());
102         model.setUserId(soapModel.getUserId());
103         model.setType(soapModel.getType());
104         model.setEmail(soapModel.getEmail());
105         model.setSms(soapModel.getSms());
106         model.setWebsite(soapModel.getWebsite());
107 
108         return model;
109     }
110 
111     public static List<AnnouncementsDelivery> toModels(
112         AnnouncementsDeliverySoap[] soapModels) {
113         List<AnnouncementsDelivery> models = new ArrayList<AnnouncementsDelivery>(soapModels.length);
114 
115         for (AnnouncementsDeliverySoap soapModel : soapModels) {
116             models.add(toModel(soapModel));
117         }
118 
119         return models;
120     }
121 
122     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
123                 "lock.expiration.time.com.liferay.portlet.announcements.model.AnnouncementsDelivery"));
124 
125     public AnnouncementsDeliveryModelImpl() {
126     }
127 
128     public long getPrimaryKey() {
129         return _deliveryId;
130     }
131 
132     public void setPrimaryKey(long pk) {
133         setDeliveryId(pk);
134     }
135 
136     public Serializable getPrimaryKeyObj() {
137         return new Long(_deliveryId);
138     }
139 
140     public long getDeliveryId() {
141         return _deliveryId;
142     }
143 
144     public void setDeliveryId(long deliveryId) {
145         _deliveryId = deliveryId;
146     }
147 
148     public long getCompanyId() {
149         return _companyId;
150     }
151 
152     public void setCompanyId(long companyId) {
153         _companyId = companyId;
154     }
155 
156     public long getUserId() {
157         return _userId;
158     }
159 
160     public void setUserId(long userId) {
161         _userId = userId;
162 
163         if (!_setOriginalUserId) {
164             _setOriginalUserId = true;
165 
166             _originalUserId = userId;
167         }
168     }
169 
170     public long getOriginalUserId() {
171         return _originalUserId;
172     }
173 
174     public String getType() {
175         return GetterUtil.getString(_type);
176     }
177 
178     public void setType(String type) {
179         _type = type;
180 
181         if (_originalType == null) {
182             _originalType = type;
183         }
184     }
185 
186     public String getOriginalType() {
187         return GetterUtil.getString(_originalType);
188     }
189 
190     public boolean getEmail() {
191         return _email;
192     }
193 
194     public boolean isEmail() {
195         return _email;
196     }
197 
198     public void setEmail(boolean email) {
199         _email = email;
200     }
201 
202     public boolean getSms() {
203         return _sms;
204     }
205 
206     public boolean isSms() {
207         return _sms;
208     }
209 
210     public void setSms(boolean sms) {
211         _sms = sms;
212     }
213 
214     public boolean getWebsite() {
215         return _website;
216     }
217 
218     public boolean isWebsite() {
219         return _website;
220     }
221 
222     public void setWebsite(boolean website) {
223         _website = website;
224     }
225 
226     public AnnouncementsDelivery toEscapedModel() {
227         if (isEscapedModel()) {
228             return (AnnouncementsDelivery)this;
229         }
230         else {
231             AnnouncementsDelivery model = new AnnouncementsDeliveryImpl();
232 
233             model.setNew(isNew());
234             model.setEscapedModel(true);
235 
236             model.setDeliveryId(getDeliveryId());
237             model.setCompanyId(getCompanyId());
238             model.setUserId(getUserId());
239             model.setType(HtmlUtil.escape(getType()));
240             model.setEmail(getEmail());
241             model.setSms(getSms());
242             model.setWebsite(getWebsite());
243 
244             model = (AnnouncementsDelivery)Proxy.newProxyInstance(AnnouncementsDelivery.class.getClassLoader(),
245                     new Class[] { AnnouncementsDelivery.class },
246                     new ReadOnlyBeanHandler(model));
247 
248             return model;
249         }
250     }
251 
252     public ExpandoBridge getExpandoBridge() {
253         if (_expandoBridge == null) {
254             _expandoBridge = new ExpandoBridgeImpl(AnnouncementsDelivery.class.getName(),
255                     getPrimaryKey());
256         }
257 
258         return _expandoBridge;
259     }
260 
261     public Object clone() {
262         AnnouncementsDeliveryImpl clone = new AnnouncementsDeliveryImpl();
263 
264         clone.setDeliveryId(getDeliveryId());
265         clone.setCompanyId(getCompanyId());
266         clone.setUserId(getUserId());
267         clone.setType(getType());
268         clone.setEmail(getEmail());
269         clone.setSms(getSms());
270         clone.setWebsite(getWebsite());
271 
272         return clone;
273     }
274 
275     public int compareTo(AnnouncementsDelivery announcementsDelivery) {
276         long pk = announcementsDelivery.getPrimaryKey();
277 
278         if (getPrimaryKey() < pk) {
279             return -1;
280         }
281         else if (getPrimaryKey() > pk) {
282             return 1;
283         }
284         else {
285             return 0;
286         }
287     }
288 
289     public boolean equals(Object obj) {
290         if (obj == null) {
291             return false;
292         }
293 
294         AnnouncementsDelivery announcementsDelivery = null;
295 
296         try {
297             announcementsDelivery = (AnnouncementsDelivery)obj;
298         }
299         catch (ClassCastException cce) {
300             return false;
301         }
302 
303         long pk = announcementsDelivery.getPrimaryKey();
304 
305         if (getPrimaryKey() == pk) {
306             return true;
307         }
308         else {
309             return false;
310         }
311     }
312 
313     public int hashCode() {
314         return (int)getPrimaryKey();
315     }
316 
317     public String toString() {
318         StringBuilder sb = new StringBuilder();
319 
320         sb.append("{deliveryId=");
321         sb.append(getDeliveryId());
322         sb.append(", companyId=");
323         sb.append(getCompanyId());
324         sb.append(", userId=");
325         sb.append(getUserId());
326         sb.append(", type=");
327         sb.append(getType());
328         sb.append(", email=");
329         sb.append(getEmail());
330         sb.append(", sms=");
331         sb.append(getSms());
332         sb.append(", website=");
333         sb.append(getWebsite());
334         sb.append("}");
335 
336         return sb.toString();
337     }
338 
339     public String toXmlString() {
340         StringBuilder sb = new StringBuilder();
341 
342         sb.append("<model><model-name>");
343         sb.append(
344             "com.liferay.portlet.announcements.model.AnnouncementsDelivery");
345         sb.append("</model-name>");
346 
347         sb.append(
348             "<column><column-name>deliveryId</column-name><column-value><![CDATA[");
349         sb.append(getDeliveryId());
350         sb.append("]]></column-value></column>");
351         sb.append(
352             "<column><column-name>companyId</column-name><column-value><![CDATA[");
353         sb.append(getCompanyId());
354         sb.append("]]></column-value></column>");
355         sb.append(
356             "<column><column-name>userId</column-name><column-value><![CDATA[");
357         sb.append(getUserId());
358         sb.append("]]></column-value></column>");
359         sb.append(
360             "<column><column-name>type</column-name><column-value><![CDATA[");
361         sb.append(getType());
362         sb.append("]]></column-value></column>");
363         sb.append(
364             "<column><column-name>email</column-name><column-value><![CDATA[");
365         sb.append(getEmail());
366         sb.append("]]></column-value></column>");
367         sb.append(
368             "<column><column-name>sms</column-name><column-value><![CDATA[");
369         sb.append(getSms());
370         sb.append("]]></column-value></column>");
371         sb.append(
372             "<column><column-name>website</column-name><column-value><![CDATA[");
373         sb.append(getWebsite());
374         sb.append("]]></column-value></column>");
375 
376         sb.append("</model>");
377 
378         return sb.toString();
379     }
380 
381     private long _deliveryId;
382     private long _companyId;
383     private long _userId;
384     private long _originalUserId;
385     private boolean _setOriginalUserId;
386     private String _type;
387     private String _originalType;
388     private boolean _email;
389     private boolean _sms;
390     private boolean _website;
391     private transient ExpandoBridge _expandoBridge;
392 }