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