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