001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.announcements.model.impl;
016    
017    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.util.GetterUtil;
020    import com.liferay.portal.kernel.util.StringBundler;
021    import com.liferay.portal.kernel.util.StringPool;
022    import com.liferay.portal.model.impl.BaseModelImpl;
023    import com.liferay.portal.service.ServiceContext;
024    import com.liferay.portal.util.PortalUtil;
025    
026    import com.liferay.portlet.announcements.model.AnnouncementsDelivery;
027    import com.liferay.portlet.announcements.model.AnnouncementsDeliveryModel;
028    import com.liferay.portlet.announcements.model.AnnouncementsDeliverySoap;
029    import com.liferay.portlet.expando.model.ExpandoBridge;
030    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
031    
032    import java.io.Serializable;
033    
034    import java.lang.reflect.Proxy;
035    
036    import java.sql.Types;
037    
038    import java.util.ArrayList;
039    import java.util.List;
040    
041    /**
042     * The base model implementation for the AnnouncementsDelivery service. Represents a row in the "AnnouncementsDelivery" database table, with each column mapped to a property of this class.
043     *
044     * <p>
045     * This implementation and its corresponding interface {@link com.liferay.portlet.announcements.model.AnnouncementsDeliveryModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link AnnouncementsDeliveryImpl}.
046     * </p>
047     *
048     * <p>
049     * Never modify or reference this class directly. All methods that expect a announcements delivery model instance should use the {@link com.liferay.portlet.announcements.model.AnnouncementsDelivery} interface instead.
050     * </p>
051     *
052     * @author Brian Wing Shun Chan
053     * @see AnnouncementsDeliveryImpl
054     * @see com.liferay.portlet.announcements.model.AnnouncementsDelivery
055     * @see com.liferay.portlet.announcements.model.AnnouncementsDeliveryModel
056     * @generated
057     */
058    public class AnnouncementsDeliveryModelImpl extends BaseModelImpl<AnnouncementsDelivery>
059            implements AnnouncementsDeliveryModel {
060            public static final String TABLE_NAME = "AnnouncementsDelivery";
061            public static final Object[][] TABLE_COLUMNS = {
062                            { "deliveryId", new Integer(Types.BIGINT) },
063                            { "companyId", new Integer(Types.BIGINT) },
064                            { "userId", new Integer(Types.BIGINT) },
065                            { "type_", new Integer(Types.VARCHAR) },
066                            { "email", new Integer(Types.BOOLEAN) },
067                            { "sms", new Integer(Types.BOOLEAN) },
068                            { "website", new Integer(Types.BOOLEAN) }
069                    };
070            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)";
071            public static final String TABLE_SQL_DROP = "drop table AnnouncementsDelivery";
072            public static final String DATA_SOURCE = "liferayDataSource";
073            public static final String SESSION_FACTORY = "liferaySessionFactory";
074            public static final String TX_MANAGER = "liferayTransactionManager";
075            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
076                                    "value.object.entity.cache.enabled.com.liferay.portlet.announcements.model.AnnouncementsDelivery"),
077                            true);
078            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
079                                    "value.object.finder.cache.enabled.com.liferay.portlet.announcements.model.AnnouncementsDelivery"),
080                            true);
081    
082            /**
083             * Converts the soap model instance into a normal model instance.
084             *
085             * @param soapModel the soap model instance to convert
086             * @return the normal model instance
087             */
088            public static AnnouncementsDelivery toModel(
089                    AnnouncementsDeliverySoap soapModel) {
090                    AnnouncementsDelivery model = new AnnouncementsDeliveryImpl();
091    
092                    model.setDeliveryId(soapModel.getDeliveryId());
093                    model.setCompanyId(soapModel.getCompanyId());
094                    model.setUserId(soapModel.getUserId());
095                    model.setType(soapModel.getType());
096                    model.setEmail(soapModel.getEmail());
097                    model.setSms(soapModel.getSms());
098                    model.setWebsite(soapModel.getWebsite());
099    
100                    return model;
101            }
102    
103            /**
104             * Converts the soap model instances into normal model instances.
105             *
106             * @param soapModels the soap model instances to convert
107             * @return the normal model instances
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                    _deliveryId = deliveryId;
144            }
145    
146            public long getCompanyId() {
147                    return _companyId;
148            }
149    
150            public void setCompanyId(long companyId) {
151                    _companyId = companyId;
152            }
153    
154            public long getUserId() {
155                    return _userId;
156            }
157    
158            public void setUserId(long userId) {
159                    _userId = userId;
160    
161                    if (!_setOriginalUserId) {
162                            _setOriginalUserId = true;
163    
164                            _originalUserId = userId;
165                    }
166            }
167    
168            public String getUserUuid() throws SystemException {
169                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
170            }
171    
172            public void setUserUuid(String userUuid) {
173                    _userUuid = userUuid;
174            }
175    
176            public long getOriginalUserId() {
177                    return _originalUserId;
178            }
179    
180            public String getType() {
181                    if (_type == null) {
182                            return StringPool.BLANK;
183                    }
184                    else {
185                            return _type;
186                    }
187            }
188    
189            public void setType(String type) {
190                    _type = type;
191    
192                    if (_originalType == null) {
193                            _originalType = type;
194                    }
195            }
196    
197            public String getOriginalType() {
198                    return GetterUtil.getString(_originalType);
199            }
200    
201            public boolean getEmail() {
202                    return _email;
203            }
204    
205            public boolean isEmail() {
206                    return _email;
207            }
208    
209            public void setEmail(boolean email) {
210                    _email = email;
211            }
212    
213            public boolean getSms() {
214                    return _sms;
215            }
216    
217            public boolean isSms() {
218                    return _sms;
219            }
220    
221            public void setSms(boolean sms) {
222                    _sms = sms;
223            }
224    
225            public boolean getWebsite() {
226                    return _website;
227            }
228    
229            public boolean isWebsite() {
230                    return _website;
231            }
232    
233            public void setWebsite(boolean website) {
234                    _website = website;
235            }
236    
237            public AnnouncementsDelivery toEscapedModel() {
238                    if (isEscapedModel()) {
239                            return (AnnouncementsDelivery)this;
240                    }
241                    else {
242                            return (AnnouncementsDelivery)Proxy.newProxyInstance(AnnouncementsDelivery.class.getClassLoader(),
243                                    new Class[] { AnnouncementsDelivery.class },
244                                    new AutoEscapeBeanHandler(this));
245                    }
246            }
247    
248            public ExpandoBridge getExpandoBridge() {
249                    if (_expandoBridge == null) {
250                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
251                                            AnnouncementsDelivery.class.getName(), getPrimaryKey());
252                    }
253    
254                    return _expandoBridge;
255            }
256    
257            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
258                    getExpandoBridge().setAttributes(serviceContext);
259            }
260    
261            public Object clone() {
262                    AnnouncementsDeliveryImpl clone = new AnnouncementsDeliveryImpl();
263    
264                    clone.setDeliveryId(getDeliveryId());
265                    clone.setCompanyId(getCompanyId());
266                    clone.setUserId(getUserId());
267                    clone.setType(getType());
268                    clone.setEmail(getEmail());
269                    clone.setSms(getSms());
270                    clone.setWebsite(getWebsite());
271    
272                    return clone;
273            }
274    
275            public int compareTo(AnnouncementsDelivery announcementsDelivery) {
276                    long pk = announcementsDelivery.getPrimaryKey();
277    
278                    if (getPrimaryKey() < pk) {
279                            return -1;
280                    }
281                    else if (getPrimaryKey() > pk) {
282                            return 1;
283                    }
284                    else {
285                            return 0;
286                    }
287            }
288    
289            public boolean equals(Object obj) {
290                    if (obj == null) {
291                            return false;
292                    }
293    
294                    AnnouncementsDelivery announcementsDelivery = null;
295    
296                    try {
297                            announcementsDelivery = (AnnouncementsDelivery)obj;
298                    }
299                    catch (ClassCastException cce) {
300                            return false;
301                    }
302    
303                    long pk = announcementsDelivery.getPrimaryKey();
304    
305                    if (getPrimaryKey() == pk) {
306                            return true;
307                    }
308                    else {
309                            return false;
310                    }
311            }
312    
313            public int hashCode() {
314                    return (int)getPrimaryKey();
315            }
316    
317            public String toString() {
318                    StringBundler sb = new StringBundler(15);
319    
320                    sb.append("{deliveryId=");
321                    sb.append(getDeliveryId());
322                    sb.append(", companyId=");
323                    sb.append(getCompanyId());
324                    sb.append(", userId=");
325                    sb.append(getUserId());
326                    sb.append(", type=");
327                    sb.append(getType());
328                    sb.append(", email=");
329                    sb.append(getEmail());
330                    sb.append(", sms=");
331                    sb.append(getSms());
332                    sb.append(", website=");
333                    sb.append(getWebsite());
334                    sb.append("}");
335    
336                    return sb.toString();
337            }
338    
339            public String toXmlString() {
340                    StringBundler sb = new StringBundler(25);
341    
342                    sb.append("<model><model-name>");
343                    sb.append(
344                            "com.liferay.portlet.announcements.model.AnnouncementsDelivery");
345                    sb.append("</model-name>");
346    
347                    sb.append(
348                            "<column><column-name>deliveryId</column-name><column-value><![CDATA[");
349                    sb.append(getDeliveryId());
350                    sb.append("]]></column-value></column>");
351                    sb.append(
352                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
353                    sb.append(getCompanyId());
354                    sb.append("]]></column-value></column>");
355                    sb.append(
356                            "<column><column-name>userId</column-name><column-value><![CDATA[");
357                    sb.append(getUserId());
358                    sb.append("]]></column-value></column>");
359                    sb.append(
360                            "<column><column-name>type</column-name><column-value><![CDATA[");
361                    sb.append(getType());
362                    sb.append("]]></column-value></column>");
363                    sb.append(
364                            "<column><column-name>email</column-name><column-value><![CDATA[");
365                    sb.append(getEmail());
366                    sb.append("]]></column-value></column>");
367                    sb.append(
368                            "<column><column-name>sms</column-name><column-value><![CDATA[");
369                    sb.append(getSms());
370                    sb.append("]]></column-value></column>");
371                    sb.append(
372                            "<column><column-name>website</column-name><column-value><![CDATA[");
373                    sb.append(getWebsite());
374                    sb.append("]]></column-value></column>");
375    
376                    sb.append("</model>");
377    
378                    return sb.toString();
379            }
380    
381            private long _deliveryId;
382            private long _companyId;
383            private long _userId;
384            private String _userUuid;
385            private long _originalUserId;
386            private boolean _setOriginalUserId;
387            private String _type;
388            private String _originalType;
389            private boolean _email;
390            private boolean _sms;
391            private boolean _website;
392            private transient ExpandoBridge _expandoBridge;
393    }