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