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.DateUtil;
020    import com.liferay.portal.kernel.util.GetterUtil;
021    import com.liferay.portal.kernel.util.StringBundler;
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.AnnouncementsFlag;
027    import com.liferay.portlet.announcements.model.AnnouncementsFlagModel;
028    import com.liferay.portlet.announcements.model.AnnouncementsFlagSoap;
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.Date;
040    import java.util.List;
041    
042    /**
043     * The base model implementation for the AnnouncementsFlag service. Represents a row in the "AnnouncementsFlag" database table, with each column mapped to a property of this class.
044     *
045     * <p>
046     * This implementation and its corresponding interface {@link com.liferay.portlet.announcements.model.AnnouncementsFlagModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link AnnouncementsFlagImpl}.
047     * </p>
048     *
049     * <p>
050     * Never modify or reference this class directly. All methods that expect a announcements flag model instance should use the {@link com.liferay.portlet.announcements.model.AnnouncementsFlag} interface instead.
051     * </p>
052     *
053     * @author Brian Wing Shun Chan
054     * @see AnnouncementsFlagImpl
055     * @see com.liferay.portlet.announcements.model.AnnouncementsFlag
056     * @see com.liferay.portlet.announcements.model.AnnouncementsFlagModel
057     * @generated
058     */
059    public class AnnouncementsFlagModelImpl extends BaseModelImpl<AnnouncementsFlag>
060            implements AnnouncementsFlagModel {
061            public static final String TABLE_NAME = "AnnouncementsFlag";
062            public static final Object[][] TABLE_COLUMNS = {
063                            { "flagId", new Integer(Types.BIGINT) },
064                            { "userId", new Integer(Types.BIGINT) },
065                            { "createDate", new Integer(Types.TIMESTAMP) },
066                            { "entryId", new Integer(Types.BIGINT) },
067                            { "value", new Integer(Types.INTEGER) }
068                    };
069            public static final String TABLE_SQL_CREATE = "create table AnnouncementsFlag (flagId LONG not null primary key,userId LONG,createDate DATE null,entryId LONG,value INTEGER)";
070            public static final String TABLE_SQL_DROP = "drop table AnnouncementsFlag";
071            public static final String ORDER_BY_JPQL = " ORDER BY announcementsFlag.userId ASC, announcementsFlag.createDate ASC";
072            public static final String ORDER_BY_SQL = " ORDER BY AnnouncementsFlag.userId ASC, AnnouncementsFlag.createDate ASC";
073            public static final String DATA_SOURCE = "liferayDataSource";
074            public static final String SESSION_FACTORY = "liferaySessionFactory";
075            public static final String TX_MANAGER = "liferayTransactionManager";
076            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
077                                    "value.object.entity.cache.enabled.com.liferay.portlet.announcements.model.AnnouncementsFlag"),
078                            true);
079            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
080                                    "value.object.finder.cache.enabled.com.liferay.portlet.announcements.model.AnnouncementsFlag"),
081                            true);
082    
083            /**
084             * Converts the soap model instance into a normal model instance.
085             *
086             * @param soapModel the soap model instance to convert
087             * @return the normal model instance
088             */
089            public static AnnouncementsFlag toModel(AnnouncementsFlagSoap soapModel) {
090                    AnnouncementsFlag model = new AnnouncementsFlagImpl();
091    
092                    model.setFlagId(soapModel.getFlagId());
093                    model.setUserId(soapModel.getUserId());
094                    model.setCreateDate(soapModel.getCreateDate());
095                    model.setEntryId(soapModel.getEntryId());
096                    model.setValue(soapModel.getValue());
097    
098                    return model;
099            }
100    
101            /**
102             * Converts the soap model instances into normal model instances.
103             *
104             * @param soapModels the soap model instances to convert
105             * @return the normal model instances
106             */
107            public static List<AnnouncementsFlag> toModels(
108                    AnnouncementsFlagSoap[] soapModels) {
109                    List<AnnouncementsFlag> models = new ArrayList<AnnouncementsFlag>(soapModels.length);
110    
111                    for (AnnouncementsFlagSoap soapModel : soapModels) {
112                            models.add(toModel(soapModel));
113                    }
114    
115                    return models;
116            }
117    
118            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
119                                    "lock.expiration.time.com.liferay.portlet.announcements.model.AnnouncementsFlag"));
120    
121            public AnnouncementsFlagModelImpl() {
122            }
123    
124            public long getPrimaryKey() {
125                    return _flagId;
126            }
127    
128            public void setPrimaryKey(long pk) {
129                    setFlagId(pk);
130            }
131    
132            public Serializable getPrimaryKeyObj() {
133                    return new Long(_flagId);
134            }
135    
136            public long getFlagId() {
137                    return _flagId;
138            }
139    
140            public void setFlagId(long flagId) {
141                    _flagId = flagId;
142            }
143    
144            public long getUserId() {
145                    return _userId;
146            }
147    
148            public void setUserId(long userId) {
149                    _userId = userId;
150    
151                    if (!_setOriginalUserId) {
152                            _setOriginalUserId = true;
153    
154                            _originalUserId = userId;
155                    }
156            }
157    
158            public String getUserUuid() throws SystemException {
159                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
160            }
161    
162            public void setUserUuid(String userUuid) {
163                    _userUuid = userUuid;
164            }
165    
166            public long getOriginalUserId() {
167                    return _originalUserId;
168            }
169    
170            public Date getCreateDate() {
171                    return _createDate;
172            }
173    
174            public void setCreateDate(Date createDate) {
175                    _createDate = createDate;
176            }
177    
178            public long getEntryId() {
179                    return _entryId;
180            }
181    
182            public void setEntryId(long entryId) {
183                    _entryId = entryId;
184    
185                    if (!_setOriginalEntryId) {
186                            _setOriginalEntryId = true;
187    
188                            _originalEntryId = entryId;
189                    }
190            }
191    
192            public long getOriginalEntryId() {
193                    return _originalEntryId;
194            }
195    
196            public int getValue() {
197                    return _value;
198            }
199    
200            public void setValue(int value) {
201                    _value = value;
202    
203                    if (!_setOriginalValue) {
204                            _setOriginalValue = true;
205    
206                            _originalValue = value;
207                    }
208            }
209    
210            public int getOriginalValue() {
211                    return _originalValue;
212            }
213    
214            public AnnouncementsFlag toEscapedModel() {
215                    if (isEscapedModel()) {
216                            return (AnnouncementsFlag)this;
217                    }
218                    else {
219                            return (AnnouncementsFlag)Proxy.newProxyInstance(AnnouncementsFlag.class.getClassLoader(),
220                                    new Class[] { AnnouncementsFlag.class },
221                                    new AutoEscapeBeanHandler(this));
222                    }
223            }
224    
225            public ExpandoBridge getExpandoBridge() {
226                    if (_expandoBridge == null) {
227                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
228                                            AnnouncementsFlag.class.getName(), getPrimaryKey());
229                    }
230    
231                    return _expandoBridge;
232            }
233    
234            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
235                    getExpandoBridge().setAttributes(serviceContext);
236            }
237    
238            public Object clone() {
239                    AnnouncementsFlagImpl clone = new AnnouncementsFlagImpl();
240    
241                    clone.setFlagId(getFlagId());
242                    clone.setUserId(getUserId());
243                    clone.setCreateDate(getCreateDate());
244                    clone.setEntryId(getEntryId());
245                    clone.setValue(getValue());
246    
247                    return clone;
248            }
249    
250            public int compareTo(AnnouncementsFlag announcementsFlag) {
251                    int value = 0;
252    
253                    if (getUserId() < announcementsFlag.getUserId()) {
254                            value = -1;
255                    }
256                    else if (getUserId() > announcementsFlag.getUserId()) {
257                            value = 1;
258                    }
259                    else {
260                            value = 0;
261                    }
262    
263                    if (value != 0) {
264                            return value;
265                    }
266    
267                    value = DateUtil.compareTo(getCreateDate(),
268                                    announcementsFlag.getCreateDate());
269    
270                    if (value != 0) {
271                            return value;
272                    }
273    
274                    return 0;
275            }
276    
277            public boolean equals(Object obj) {
278                    if (obj == null) {
279                            return false;
280                    }
281    
282                    AnnouncementsFlag announcementsFlag = null;
283    
284                    try {
285                            announcementsFlag = (AnnouncementsFlag)obj;
286                    }
287                    catch (ClassCastException cce) {
288                            return false;
289                    }
290    
291                    long pk = announcementsFlag.getPrimaryKey();
292    
293                    if (getPrimaryKey() == pk) {
294                            return true;
295                    }
296                    else {
297                            return false;
298                    }
299            }
300    
301            public int hashCode() {
302                    return (int)getPrimaryKey();
303            }
304    
305            public String toString() {
306                    StringBundler sb = new StringBundler(11);
307    
308                    sb.append("{flagId=");
309                    sb.append(getFlagId());
310                    sb.append(", userId=");
311                    sb.append(getUserId());
312                    sb.append(", createDate=");
313                    sb.append(getCreateDate());
314                    sb.append(", entryId=");
315                    sb.append(getEntryId());
316                    sb.append(", value=");
317                    sb.append(getValue());
318                    sb.append("}");
319    
320                    return sb.toString();
321            }
322    
323            public String toXmlString() {
324                    StringBundler sb = new StringBundler(19);
325    
326                    sb.append("<model><model-name>");
327                    sb.append("com.liferay.portlet.announcements.model.AnnouncementsFlag");
328                    sb.append("</model-name>");
329    
330                    sb.append(
331                            "<column><column-name>flagId</column-name><column-value><![CDATA[");
332                    sb.append(getFlagId());
333                    sb.append("]]></column-value></column>");
334                    sb.append(
335                            "<column><column-name>userId</column-name><column-value><![CDATA[");
336                    sb.append(getUserId());
337                    sb.append("]]></column-value></column>");
338                    sb.append(
339                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
340                    sb.append(getCreateDate());
341                    sb.append("]]></column-value></column>");
342                    sb.append(
343                            "<column><column-name>entryId</column-name><column-value><![CDATA[");
344                    sb.append(getEntryId());
345                    sb.append("]]></column-value></column>");
346                    sb.append(
347                            "<column><column-name>value</column-name><column-value><![CDATA[");
348                    sb.append(getValue());
349                    sb.append("]]></column-value></column>");
350    
351                    sb.append("</model>");
352    
353                    return sb.toString();
354            }
355    
356            private long _flagId;
357            private long _userId;
358            private String _userUuid;
359            private long _originalUserId;
360            private boolean _setOriginalUserId;
361            private Date _createDate;
362            private long _entryId;
363            private long _originalEntryId;
364            private boolean _setOriginalEntryId;
365            private int _value;
366            private int _originalValue;
367            private boolean _setOriginalValue;
368            private transient ExpandoBridge _expandoBridge;
369    }