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