1   /**
2    * Copyright (c) 2000-2008 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  import com.liferay.portal.util.PropsUtil;
30  
31  import com.liferay.portlet.announcements.model.AnnouncementsDelivery;
32  import com.liferay.portlet.announcements.model.AnnouncementsDeliverySoap;
33  
34  import java.io.Serializable;
35  
36  import java.lang.reflect.Proxy;
37  
38  import java.sql.Types;
39  
40  import java.util.ArrayList;
41  import java.util.List;
42  
43  /**
44   * <a href="AnnouncementsDeliveryModelImpl.java.html"><b><i>View Source</i></b></a>
45   *
46   * <p>
47   * ServiceBuilder generated this class. Modifications in this class will be
48   * overwritten the next time is generated.
49   * </p>
50   *
51   * <p>
52   * This class is a model that represents the <code>AnnouncementsDelivery</code> table
53   * in the database.
54   * </p>
55   *
56   * @author Brian Wing Shun Chan
57   *
58   * @see com.liferay.portlet.announcements.service.model.AnnouncementsDelivery
59   * @see com.liferay.portlet.announcements.service.model.AnnouncementsDeliveryModel
60   * @see com.liferay.portlet.announcements.service.model.impl.AnnouncementsDeliveryImpl
61   *
62   */
63  public class AnnouncementsDeliveryModelImpl extends BaseModelImpl {
64      public static final String TABLE_NAME = "AnnouncementsDelivery";
65      public static final Object[][] TABLE_COLUMNS = {
66              { "deliveryId", new Integer(Types.BIGINT) },
67              
68  
69              { "companyId", new Integer(Types.BIGINT) },
70              
71  
72              { "userId", new Integer(Types.BIGINT) },
73              
74  
75              { "type_", new Integer(Types.VARCHAR) },
76              
77  
78              { "email", new Integer(Types.BOOLEAN) },
79              
80  
81              { "sms", new Integer(Types.BOOLEAN) },
82              
83  
84              { "website", new Integer(Types.BOOLEAN) }
85          };
86      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)";
87      public static final String TABLE_SQL_DROP = "drop table AnnouncementsDelivery";
88      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
89                  "value.object.finder.cache.enabled.com.liferay.portlet.announcements.model.AnnouncementsDelivery"),
90              true);
91  
92      public static AnnouncementsDelivery toModel(
93          AnnouncementsDeliverySoap soapModel) {
94          AnnouncementsDelivery model = new AnnouncementsDeliveryImpl();
95  
96          model.setDeliveryId(soapModel.getDeliveryId());
97          model.setCompanyId(soapModel.getCompanyId());
98          model.setUserId(soapModel.getUserId());
99          model.setType(soapModel.getType());
100         model.setEmail(soapModel.getEmail());
101         model.setSms(soapModel.getSms());
102         model.setWebsite(soapModel.getWebsite());
103 
104         return model;
105     }
106 
107     public static List<AnnouncementsDelivery> toModels(
108         AnnouncementsDeliverySoap[] soapModels) {
109         List<AnnouncementsDelivery> models = new ArrayList<AnnouncementsDelivery>(soapModels.length);
110 
111         for (AnnouncementsDeliverySoap soapModel : soapModels) {
112             models.add(toModel(soapModel));
113         }
114 
115         return models;
116     }
117 
118     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
119                 "lock.expiration.time.com.liferay.portlet.announcements.model.AnnouncementsDelivery"));
120 
121     public AnnouncementsDeliveryModelImpl() {
122     }
123 
124     public long getPrimaryKey() {
125         return _deliveryId;
126     }
127 
128     public void setPrimaryKey(long pk) {
129         setDeliveryId(pk);
130     }
131 
132     public Serializable getPrimaryKeyObj() {
133         return new Long(_deliveryId);
134     }
135 
136     public long getDeliveryId() {
137         return _deliveryId;
138     }
139 
140     public void setDeliveryId(long deliveryId) {
141         if (deliveryId != _deliveryId) {
142             _deliveryId = deliveryId;
143         }
144     }
145 
146     public long getCompanyId() {
147         return _companyId;
148     }
149 
150     public void setCompanyId(long companyId) {
151         if (companyId != _companyId) {
152             _companyId = companyId;
153         }
154     }
155 
156     public long getUserId() {
157         return _userId;
158     }
159 
160     public void setUserId(long userId) {
161         if (userId != _userId) {
162             _userId = userId;
163         }
164     }
165 
166     public String getType() {
167         return GetterUtil.getString(_type);
168     }
169 
170     public void setType(String type) {
171         if (((type == null) && (_type != null)) ||
172                 ((type != null) && (_type == null)) ||
173                 ((type != null) && (_type != null) && !type.equals(_type))) {
174             _type = type;
175         }
176     }
177 
178     public boolean getEmail() {
179         return _email;
180     }
181 
182     public boolean isEmail() {
183         return _email;
184     }
185 
186     public void setEmail(boolean email) {
187         if (email != _email) {
188             _email = email;
189         }
190     }
191 
192     public boolean getSms() {
193         return _sms;
194     }
195 
196     public boolean isSms() {
197         return _sms;
198     }
199 
200     public void setSms(boolean sms) {
201         if (sms != _sms) {
202             _sms = sms;
203         }
204     }
205 
206     public boolean getWebsite() {
207         return _website;
208     }
209 
210     public boolean isWebsite() {
211         return _website;
212     }
213 
214     public void setWebsite(boolean website) {
215         if (website != _website) {
216             _website = website;
217         }
218     }
219 
220     public AnnouncementsDelivery toEscapedModel() {
221         if (isEscapedModel()) {
222             return (AnnouncementsDelivery)this;
223         }
224         else {
225             AnnouncementsDelivery model = new AnnouncementsDeliveryImpl();
226 
227             model.setEscapedModel(true);
228 
229             model.setDeliveryId(getDeliveryId());
230             model.setCompanyId(getCompanyId());
231             model.setUserId(getUserId());
232             model.setType(HtmlUtil.escape(getType()));
233             model.setEmail(getEmail());
234             model.setSms(getSms());
235             model.setWebsite(getWebsite());
236 
237             model = (AnnouncementsDelivery)Proxy.newProxyInstance(AnnouncementsDelivery.class.getClassLoader(),
238                     new Class[] { AnnouncementsDelivery.class },
239                     new ReadOnlyBeanHandler(model));
240 
241             return model;
242         }
243     }
244 
245     public Object clone() {
246         AnnouncementsDeliveryImpl clone = new AnnouncementsDeliveryImpl();
247 
248         clone.setDeliveryId(getDeliveryId());
249         clone.setCompanyId(getCompanyId());
250         clone.setUserId(getUserId());
251         clone.setType(getType());
252         clone.setEmail(getEmail());
253         clone.setSms(getSms());
254         clone.setWebsite(getWebsite());
255 
256         return clone;
257     }
258 
259     public int compareTo(Object obj) {
260         if (obj == null) {
261             return -1;
262         }
263 
264         AnnouncementsDeliveryImpl announcementsDelivery = (AnnouncementsDeliveryImpl)obj;
265 
266         long pk = announcementsDelivery.getPrimaryKey();
267 
268         if (getPrimaryKey() < pk) {
269             return -1;
270         }
271         else if (getPrimaryKey() > pk) {
272             return 1;
273         }
274         else {
275             return 0;
276         }
277     }
278 
279     public boolean equals(Object obj) {
280         if (obj == null) {
281             return false;
282         }
283 
284         AnnouncementsDeliveryImpl announcementsDelivery = null;
285 
286         try {
287             announcementsDelivery = (AnnouncementsDeliveryImpl)obj;
288         }
289         catch (ClassCastException cce) {
290             return false;
291         }
292 
293         long pk = announcementsDelivery.getPrimaryKey();
294 
295         if (getPrimaryKey() == pk) {
296             return true;
297         }
298         else {
299             return false;
300         }
301     }
302 
303     public int hashCode() {
304         return (int)getPrimaryKey();
305     }
306 
307     private long _deliveryId;
308     private long _companyId;
309     private long _userId;
310     private String _type;
311     private boolean _email;
312     private boolean _sms;
313     private boolean _website;
314 }