1   /**
2    * Copyright (c) 2000-2010 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   *
12   * 
13   */
14  
15  package com.liferay.portlet.announcements.model.impl;
16  
17  import com.liferay.portal.SystemException;
18  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
19  import com.liferay.portal.kernel.util.GetterUtil;
20  import com.liferay.portal.kernel.util.HtmlUtil;
21  import com.liferay.portal.kernel.util.StringBundler;
22  import com.liferay.portal.model.impl.BaseModelImpl;
23  import com.liferay.portal.util.PortalUtil;
24  
25  import com.liferay.portlet.announcements.model.AnnouncementsDelivery;
26  import com.liferay.portlet.announcements.model.AnnouncementsDeliverySoap;
27  
28  import java.io.Serializable;
29  
30  import java.lang.reflect.Proxy;
31  
32  import java.sql.Types;
33  
34  import java.util.ArrayList;
35  import java.util.List;
36  
37  /**
38   * <a href="AnnouncementsDeliveryModelImpl.java.html"><b><i>View Source</i></b></a>
39   *
40   * <p>
41   * ServiceBuilder generated this class. Modifications in this class will be
42   * overwritten the next time is generated.
43   * </p>
44   *
45   * <p>
46   * This interface is a model that represents the AnnouncementsDelivery table in the
47   * database.
48   * </p>
49   *
50   * @author    Brian Wing Shun Chan
51   * @see       AnnouncementsDeliveryImpl
52   * @see       com.liferay.portlet.announcements.model.AnnouncementsDelivery
53   * @see       com.liferay.portlet.announcements.model.AnnouncementsDeliveryModel
54   * @generated
55   */
56  public class AnnouncementsDeliveryModelImpl extends BaseModelImpl<AnnouncementsDelivery> {
57      public static final String TABLE_NAME = "AnnouncementsDelivery";
58      public static final Object[][] TABLE_COLUMNS = {
59              { "deliveryId", new Integer(Types.BIGINT) },
60              { "companyId", new Integer(Types.BIGINT) },
61              { "userId", new Integer(Types.BIGINT) },
62              { "type_", new Integer(Types.VARCHAR) },
63              { "email", new Integer(Types.BOOLEAN) },
64              { "sms", new Integer(Types.BOOLEAN) },
65              { "website", new Integer(Types.BOOLEAN) }
66          };
67      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)";
68      public static final String TABLE_SQL_DROP = "drop table AnnouncementsDelivery";
69      public static final String DATA_SOURCE = "liferayDataSource";
70      public static final String SESSION_FACTORY = "liferaySessionFactory";
71      public static final String TX_MANAGER = "liferayTransactionManager";
72      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
73                  "value.object.entity.cache.enabled.com.liferay.portlet.announcements.model.AnnouncementsDelivery"),
74              true);
75      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
76                  "value.object.finder.cache.enabled.com.liferay.portlet.announcements.model.AnnouncementsDelivery"),
77              true);
78  
79      public static AnnouncementsDelivery toModel(
80          AnnouncementsDeliverySoap soapModel) {
81          AnnouncementsDelivery model = new AnnouncementsDeliveryImpl();
82  
83          model.setDeliveryId(soapModel.getDeliveryId());
84          model.setCompanyId(soapModel.getCompanyId());
85          model.setUserId(soapModel.getUserId());
86          model.setType(soapModel.getType());
87          model.setEmail(soapModel.getEmail());
88          model.setSms(soapModel.getSms());
89          model.setWebsite(soapModel.getWebsite());
90  
91          return model;
92      }
93  
94      public static List<AnnouncementsDelivery> toModels(
95          AnnouncementsDeliverySoap[] soapModels) {
96          List<AnnouncementsDelivery> models = new ArrayList<AnnouncementsDelivery>(soapModels.length);
97  
98          for (AnnouncementsDeliverySoap soapModel : soapModels) {
99              models.add(toModel(soapModel));
100         }
101 
102         return models;
103     }
104 
105     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
106                 "lock.expiration.time.com.liferay.portlet.announcements.model.AnnouncementsDelivery"));
107 
108     public AnnouncementsDeliveryModelImpl() {
109     }
110 
111     public long getPrimaryKey() {
112         return _deliveryId;
113     }
114 
115     public void setPrimaryKey(long pk) {
116         setDeliveryId(pk);
117     }
118 
119     public Serializable getPrimaryKeyObj() {
120         return new Long(_deliveryId);
121     }
122 
123     public long getDeliveryId() {
124         return _deliveryId;
125     }
126 
127     public void setDeliveryId(long deliveryId) {
128         _deliveryId = deliveryId;
129     }
130 
131     public long getCompanyId() {
132         return _companyId;
133     }
134 
135     public void setCompanyId(long companyId) {
136         _companyId = companyId;
137     }
138 
139     public long getUserId() {
140         return _userId;
141     }
142 
143     public void setUserId(long userId) {
144         _userId = userId;
145 
146         if (!_setOriginalUserId) {
147             _setOriginalUserId = true;
148 
149             _originalUserId = userId;
150         }
151     }
152 
153     public String getUserUuid() throws SystemException {
154         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
155     }
156 
157     public void setUserUuid(String userUuid) {
158         _userUuid = userUuid;
159     }
160 
161     public long getOriginalUserId() {
162         return _originalUserId;
163     }
164 
165     public String getType() {
166         return GetterUtil.getString(_type);
167     }
168 
169     public void setType(String type) {
170         _type = type;
171 
172         if (_originalType == null) {
173             _originalType = type;
174         }
175     }
176 
177     public String getOriginalType() {
178         return GetterUtil.getString(_originalType);
179     }
180 
181     public boolean getEmail() {
182         return _email;
183     }
184 
185     public boolean isEmail() {
186         return _email;
187     }
188 
189     public void setEmail(boolean email) {
190         _email = email;
191     }
192 
193     public boolean getSms() {
194         return _sms;
195     }
196 
197     public boolean isSms() {
198         return _sms;
199     }
200 
201     public void setSms(boolean sms) {
202         _sms = sms;
203     }
204 
205     public boolean getWebsite() {
206         return _website;
207     }
208 
209     public boolean isWebsite() {
210         return _website;
211     }
212 
213     public void setWebsite(boolean website) {
214         _website = website;
215     }
216 
217     public AnnouncementsDelivery toEscapedModel() {
218         if (isEscapedModel()) {
219             return (AnnouncementsDelivery)this;
220         }
221         else {
222             AnnouncementsDelivery model = new AnnouncementsDeliveryImpl();
223 
224             model.setNew(isNew());
225             model.setEscapedModel(true);
226 
227             model.setDeliveryId(getDeliveryId());
228             model.setCompanyId(getCompanyId());
229             model.setUserId(getUserId());
230             model.setType(HtmlUtil.escape(getType()));
231             model.setEmail(getEmail());
232             model.setSms(getSms());
233             model.setWebsite(getWebsite());
234 
235             model = (AnnouncementsDelivery)Proxy.newProxyInstance(AnnouncementsDelivery.class.getClassLoader(),
236                     new Class[] { AnnouncementsDelivery.class },
237                     new ReadOnlyBeanHandler(model));
238 
239             return model;
240         }
241     }
242 
243     public Object clone() {
244         AnnouncementsDeliveryImpl clone = new AnnouncementsDeliveryImpl();
245 
246         clone.setDeliveryId(getDeliveryId());
247         clone.setCompanyId(getCompanyId());
248         clone.setUserId(getUserId());
249         clone.setType(getType());
250         clone.setEmail(getEmail());
251         clone.setSms(getSms());
252         clone.setWebsite(getWebsite());
253 
254         return clone;
255     }
256 
257     public int compareTo(AnnouncementsDelivery announcementsDelivery) {
258         long pk = announcementsDelivery.getPrimaryKey();
259 
260         if (getPrimaryKey() < pk) {
261             return -1;
262         }
263         else if (getPrimaryKey() > pk) {
264             return 1;
265         }
266         else {
267             return 0;
268         }
269     }
270 
271     public boolean equals(Object obj) {
272         if (obj == null) {
273             return false;
274         }
275 
276         AnnouncementsDelivery announcementsDelivery = null;
277 
278         try {
279             announcementsDelivery = (AnnouncementsDelivery)obj;
280         }
281         catch (ClassCastException cce) {
282             return false;
283         }
284 
285         long pk = announcementsDelivery.getPrimaryKey();
286 
287         if (getPrimaryKey() == pk) {
288             return true;
289         }
290         else {
291             return false;
292         }
293     }
294 
295     public int hashCode() {
296         return (int)getPrimaryKey();
297     }
298 
299     public String toString() {
300         StringBundler sb = new StringBundler(15);
301 
302         sb.append("{deliveryId=");
303         sb.append(getDeliveryId());
304         sb.append(", companyId=");
305         sb.append(getCompanyId());
306         sb.append(", userId=");
307         sb.append(getUserId());
308         sb.append(", type=");
309         sb.append(getType());
310         sb.append(", email=");
311         sb.append(getEmail());
312         sb.append(", sms=");
313         sb.append(getSms());
314         sb.append(", website=");
315         sb.append(getWebsite());
316         sb.append("}");
317 
318         return sb.toString();
319     }
320 
321     public String toXmlString() {
322         StringBundler sb = new StringBundler(25);
323 
324         sb.append("<model><model-name>");
325         sb.append(
326             "com.liferay.portlet.announcements.model.AnnouncementsDelivery");
327         sb.append("</model-name>");
328 
329         sb.append(
330             "<column><column-name>deliveryId</column-name><column-value><![CDATA[");
331         sb.append(getDeliveryId());
332         sb.append("]]></column-value></column>");
333         sb.append(
334             "<column><column-name>companyId</column-name><column-value><![CDATA[");
335         sb.append(getCompanyId());
336         sb.append("]]></column-value></column>");
337         sb.append(
338             "<column><column-name>userId</column-name><column-value><![CDATA[");
339         sb.append(getUserId());
340         sb.append("]]></column-value></column>");
341         sb.append(
342             "<column><column-name>type</column-name><column-value><![CDATA[");
343         sb.append(getType());
344         sb.append("]]></column-value></column>");
345         sb.append(
346             "<column><column-name>email</column-name><column-value><![CDATA[");
347         sb.append(getEmail());
348         sb.append("]]></column-value></column>");
349         sb.append(
350             "<column><column-name>sms</column-name><column-value><![CDATA[");
351         sb.append(getSms());
352         sb.append("]]></column-value></column>");
353         sb.append(
354             "<column><column-name>website</column-name><column-value><![CDATA[");
355         sb.append(getWebsite());
356         sb.append("]]></column-value></column>");
357 
358         sb.append("</model>");
359 
360         return sb.toString();
361     }
362 
363     private long _deliveryId;
364     private long _companyId;
365     private long _userId;
366     private String _userUuid;
367     private long _originalUserId;
368     private boolean _setOriginalUserId;
369     private String _type;
370     private String _originalType;
371     private boolean _email;
372     private boolean _sms;
373     private boolean _website;
374 }