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