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.kernel.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.GetterUtil;
27  import com.liferay.portal.kernel.util.HtmlUtil;
28  import com.liferay.portal.model.impl.BaseModelImpl;
29  
30  import com.liferay.portlet.announcements.model.AnnouncementsDelivery;
31  import com.liferay.portlet.announcements.model.AnnouncementsDeliverySoap;
32  import com.liferay.portlet.expando.model.ExpandoBridge;
33  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
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 {
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 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         if (deliveryId != _deliveryId) {
146             _deliveryId = deliveryId;
147         }
148     }
149 
150     public long getCompanyId() {
151         return _companyId;
152     }
153 
154     public void setCompanyId(long companyId) {
155         if (companyId != _companyId) {
156             _companyId = companyId;
157         }
158     }
159 
160     public long getUserId() {
161         return _userId;
162     }
163 
164     public void setUserId(long userId) {
165         if (userId != _userId) {
166             _userId = userId;
167         }
168     }
169 
170     public String getType() {
171         return GetterUtil.getString(_type);
172     }
173 
174     public void setType(String type) {
175         if (((type == null) && (_type != null)) ||
176                 ((type != null) && (_type == null)) ||
177                 ((type != null) && (_type != null) && !type.equals(_type))) {
178             _type = type;
179         }
180     }
181 
182     public boolean getEmail() {
183         return _email;
184     }
185 
186     public boolean isEmail() {
187         return _email;
188     }
189 
190     public void setEmail(boolean email) {
191         if (email != _email) {
192             _email = email;
193         }
194     }
195 
196     public boolean getSms() {
197         return _sms;
198     }
199 
200     public boolean isSms() {
201         return _sms;
202     }
203 
204     public void setSms(boolean sms) {
205         if (sms != _sms) {
206             _sms = sms;
207         }
208     }
209 
210     public boolean getWebsite() {
211         return _website;
212     }
213 
214     public boolean isWebsite() {
215         return _website;
216     }
217 
218     public void setWebsite(boolean website) {
219         if (website != _website) {
220             _website = website;
221         }
222     }
223 
224     public AnnouncementsDelivery toEscapedModel() {
225         if (isEscapedModel()) {
226             return (AnnouncementsDelivery)this;
227         }
228         else {
229             AnnouncementsDelivery model = new AnnouncementsDeliveryImpl();
230 
231             model.setNew(isNew());
232             model.setEscapedModel(true);
233 
234             model.setDeliveryId(getDeliveryId());
235             model.setCompanyId(getCompanyId());
236             model.setUserId(getUserId());
237             model.setType(HtmlUtil.escape(getType()));
238             model.setEmail(getEmail());
239             model.setSms(getSms());
240             model.setWebsite(getWebsite());
241 
242             model = (AnnouncementsDelivery)Proxy.newProxyInstance(AnnouncementsDelivery.class.getClassLoader(),
243                     new Class[] { AnnouncementsDelivery.class },
244                     new ReadOnlyBeanHandler(model));
245 
246             return model;
247         }
248     }
249 
250     public ExpandoBridge getExpandoBridge() {
251         if (_expandoBridge == null) {
252             _expandoBridge = new ExpandoBridgeImpl(AnnouncementsDelivery.class.getName(),
253                     getPrimaryKey());
254         }
255 
256         return _expandoBridge;
257     }
258 
259     public Object clone() {
260         AnnouncementsDeliveryImpl clone = new AnnouncementsDeliveryImpl();
261 
262         clone.setDeliveryId(getDeliveryId());
263         clone.setCompanyId(getCompanyId());
264         clone.setUserId(getUserId());
265         clone.setType(getType());
266         clone.setEmail(getEmail());
267         clone.setSms(getSms());
268         clone.setWebsite(getWebsite());
269 
270         return clone;
271     }
272 
273     public int compareTo(Object obj) {
274         if (obj == null) {
275             return -1;
276         }
277 
278         AnnouncementsDeliveryImpl announcementsDelivery = (AnnouncementsDeliveryImpl)obj;
279 
280         long pk = announcementsDelivery.getPrimaryKey();
281 
282         if (getPrimaryKey() < pk) {
283             return -1;
284         }
285         else if (getPrimaryKey() > pk) {
286             return 1;
287         }
288         else {
289             return 0;
290         }
291     }
292 
293     public boolean equals(Object obj) {
294         if (obj == null) {
295             return false;
296         }
297 
298         AnnouncementsDeliveryImpl announcementsDelivery = null;
299 
300         try {
301             announcementsDelivery = (AnnouncementsDeliveryImpl)obj;
302         }
303         catch (ClassCastException cce) {
304             return false;
305         }
306 
307         long pk = announcementsDelivery.getPrimaryKey();
308 
309         if (getPrimaryKey() == pk) {
310             return true;
311         }
312         else {
313             return false;
314         }
315     }
316 
317     public int hashCode() {
318         return (int)getPrimaryKey();
319     }
320 
321     private long _deliveryId;
322     private long _companyId;
323     private long _userId;
324     private String _type;
325     private boolean _email;
326     private boolean _sms;
327     private boolean _website;
328     private transient ExpandoBridge _expandoBridge;
329 }