1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portlet.announcements.model.impl;
21  
22  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23  import com.liferay.portal.kernel.util.GetterUtil;
24  import com.liferay.portal.kernel.util.HtmlUtil;
25  import com.liferay.portal.model.impl.BaseModelImpl;
26  
27  import com.liferay.portlet.announcements.model.AnnouncementsDelivery;
28  import com.liferay.portlet.announcements.model.AnnouncementsDeliverySoap;
29  
30  import java.io.Serializable;
31  
32  import java.lang.reflect.Proxy;
33  
34  import java.sql.Types;
35  
36  import java.util.ArrayList;
37  import java.util.List;
38  
39  /**
40   * <a href="AnnouncementsDeliveryModelImpl.java.html"><b><i>View Source</i></b></a>
41   *
42   * <p>
43   * ServiceBuilder generated this class. Modifications in this class will be
44   * overwritten the next time is generated.
45   * </p>
46   *
47   * <p>
48   * This class is a model that represents the <code>AnnouncementsDelivery</code> table
49   * in the database.
50   * </p>
51   *
52   * @author Brian Wing Shun Chan
53   *
54   * @see com.liferay.portlet.announcements.model.AnnouncementsDelivery
55   * @see com.liferay.portlet.announcements.model.AnnouncementsDeliveryModel
56   * @see com.liferay.portlet.announcements.model.impl.AnnouncementsDeliveryImpl
57   *
58   */
59  public class AnnouncementsDeliveryModelImpl extends BaseModelImpl {
60      public static final String TABLE_NAME = "AnnouncementsDelivery";
61      public static final Object[][] TABLE_COLUMNS = {
62              { "deliveryId", new Integer(Types.BIGINT) },
63              
64  
65              { "companyId", new Integer(Types.BIGINT) },
66              
67  
68              { "userId", new Integer(Types.BIGINT) },
69              
70  
71              { "type_", new Integer(Types.VARCHAR) },
72              
73  
74              { "email", new Integer(Types.BOOLEAN) },
75              
76  
77              { "sms", new Integer(Types.BOOLEAN) },
78              
79  
80              { "website", new Integer(Types.BOOLEAN) }
81          };
82      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)";
83      public static final String TABLE_SQL_DROP = "drop table AnnouncementsDelivery";
84      public static final String DATA_SOURCE = "liferayDataSource";
85      public static final String SESSION_FACTORY = "liferaySessionFactory";
86      public static final String TX_MANAGER = "liferayTransactionManager";
87      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
88                  "value.object.finder.cache.enabled.com.liferay.portlet.announcements.model.AnnouncementsDelivery"),
89              true);
90  
91      public static AnnouncementsDelivery toModel(
92          AnnouncementsDeliverySoap soapModel) {
93          AnnouncementsDelivery model = new AnnouncementsDeliveryImpl();
94  
95          model.setDeliveryId(soapModel.getDeliveryId());
96          model.setCompanyId(soapModel.getCompanyId());
97          model.setUserId(soapModel.getUserId());
98          model.setType(soapModel.getType());
99          model.setEmail(soapModel.getEmail());
100         model.setSms(soapModel.getSms());
101         model.setWebsite(soapModel.getWebsite());
102 
103         return model;
104     }
105 
106     public static List<AnnouncementsDelivery> toModels(
107         AnnouncementsDeliverySoap[] soapModels) {
108         List<AnnouncementsDelivery> models = new ArrayList<AnnouncementsDelivery>(soapModels.length);
109 
110         for (AnnouncementsDeliverySoap soapModel : soapModels) {
111             models.add(toModel(soapModel));
112         }
113 
114         return models;
115     }
116 
117     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
118                 "lock.expiration.time.com.liferay.portlet.announcements.model.AnnouncementsDelivery"));
119 
120     public AnnouncementsDeliveryModelImpl() {
121     }
122 
123     public long getPrimaryKey() {
124         return _deliveryId;
125     }
126 
127     public void setPrimaryKey(long pk) {
128         setDeliveryId(pk);
129     }
130 
131     public Serializable getPrimaryKeyObj() {
132         return new Long(_deliveryId);
133     }
134 
135     public long getDeliveryId() {
136         return _deliveryId;
137     }
138 
139     public void setDeliveryId(long deliveryId) {
140         if (deliveryId != _deliveryId) {
141             _deliveryId = deliveryId;
142         }
143     }
144 
145     public long getCompanyId() {
146         return _companyId;
147     }
148 
149     public void setCompanyId(long companyId) {
150         if (companyId != _companyId) {
151             _companyId = companyId;
152         }
153     }
154 
155     public long getUserId() {
156         return _userId;
157     }
158 
159     public void setUserId(long userId) {
160         if (userId != _userId) {
161             _userId = userId;
162         }
163     }
164 
165     public String getType() {
166         return GetterUtil.getString(_type);
167     }
168 
169     public void setType(String type) {
170         if (((type == null) && (_type != null)) ||
171                 ((type != null) && (_type == null)) ||
172                 ((type != null) && (_type != null) && !type.equals(_type))) {
173             _type = type;
174         }
175     }
176 
177     public boolean getEmail() {
178         return _email;
179     }
180 
181     public boolean isEmail() {
182         return _email;
183     }
184 
185     public void setEmail(boolean email) {
186         if (email != _email) {
187             _email = email;
188         }
189     }
190 
191     public boolean getSms() {
192         return _sms;
193     }
194 
195     public boolean isSms() {
196         return _sms;
197     }
198 
199     public void setSms(boolean sms) {
200         if (sms != _sms) {
201             _sms = sms;
202         }
203     }
204 
205     public boolean getWebsite() {
206         return _website;
207     }
208 
209     public boolean isWebsite() {
210         return _website;
211     }
212 
213     public void setWebsite(boolean website) {
214         if (website != _website) {
215             _website = website;
216         }
217     }
218 
219     public AnnouncementsDelivery toEscapedModel() {
220         if (isEscapedModel()) {
221             return (AnnouncementsDelivery)this;
222         }
223         else {
224             AnnouncementsDelivery model = new AnnouncementsDeliveryImpl();
225 
226             model.setNew(isNew());
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 }