1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions 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.DateUtil;
28  import com.liferay.portal.kernel.util.GetterUtil;
29  import com.liferay.portal.model.impl.BaseModelImpl;
30  import com.liferay.portal.util.PortalUtil;
31  
32  import com.liferay.portlet.announcements.model.AnnouncementsFlag;
33  import com.liferay.portlet.announcements.model.AnnouncementsFlagSoap;
34  import com.liferay.portlet.expando.model.ExpandoBridge;
35  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
36  
37  import java.io.Serializable;
38  
39  import java.lang.reflect.Proxy;
40  
41  import java.sql.Types;
42  
43  import java.util.ArrayList;
44  import java.util.Date;
45  import java.util.List;
46  
47  /**
48   * <a href="AnnouncementsFlagModelImpl.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 class is a model that represents the <code>AnnouncementsFlag</code> table
57   * in the database.
58   * </p>
59   *
60   * @author Brian Wing Shun Chan
61   *
62   * @see com.liferay.portlet.announcements.model.AnnouncementsFlag
63   * @see com.liferay.portlet.announcements.model.AnnouncementsFlagModel
64   * @see com.liferay.portlet.announcements.model.impl.AnnouncementsFlagImpl
65   *
66   */
67  public class AnnouncementsFlagModelImpl extends BaseModelImpl<AnnouncementsFlag> {
68      public static final String TABLE_NAME = "AnnouncementsFlag";
69      public static final Object[][] TABLE_COLUMNS = {
70              { "flagId", new Integer(Types.BIGINT) },
71              
72  
73              { "userId", new Integer(Types.BIGINT) },
74              
75  
76              { "createDate", new Integer(Types.TIMESTAMP) },
77              
78  
79              { "entryId", new Integer(Types.BIGINT) },
80              
81  
82              { "value", new Integer(Types.INTEGER) }
83          };
84      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)";
85      public static final String TABLE_SQL_DROP = "drop table AnnouncementsFlag";
86      public static final String DATA_SOURCE = "liferayDataSource";
87      public static final String SESSION_FACTORY = "liferaySessionFactory";
88      public static final String TX_MANAGER = "liferayTransactionManager";
89      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
90                  "value.object.entity.cache.enabled.com.liferay.portlet.announcements.model.AnnouncementsFlag"),
91              true);
92      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
93                  "value.object.finder.cache.enabled.com.liferay.portlet.announcements.model.AnnouncementsFlag"),
94              true);
95  
96      public static AnnouncementsFlag toModel(AnnouncementsFlagSoap soapModel) {
97          AnnouncementsFlag model = new AnnouncementsFlagImpl();
98  
99          model.setFlagId(soapModel.getFlagId());
100         model.setUserId(soapModel.getUserId());
101         model.setCreateDate(soapModel.getCreateDate());
102         model.setEntryId(soapModel.getEntryId());
103         model.setValue(soapModel.getValue());
104 
105         return model;
106     }
107 
108     public static List<AnnouncementsFlag> toModels(
109         AnnouncementsFlagSoap[] soapModels) {
110         List<AnnouncementsFlag> models = new ArrayList<AnnouncementsFlag>(soapModels.length);
111 
112         for (AnnouncementsFlagSoap soapModel : soapModels) {
113             models.add(toModel(soapModel));
114         }
115 
116         return models;
117     }
118 
119     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
120                 "lock.expiration.time.com.liferay.portlet.announcements.model.AnnouncementsFlag"));
121 
122     public AnnouncementsFlagModelImpl() {
123     }
124 
125     public long getPrimaryKey() {
126         return _flagId;
127     }
128 
129     public void setPrimaryKey(long pk) {
130         setFlagId(pk);
131     }
132 
133     public Serializable getPrimaryKeyObj() {
134         return new Long(_flagId);
135     }
136 
137     public long getFlagId() {
138         return _flagId;
139     }
140 
141     public void setFlagId(long flagId) {
142         _flagId = flagId;
143     }
144 
145     public long getUserId() {
146         return _userId;
147     }
148 
149     public void setUserId(long userId) {
150         _userId = userId;
151 
152         if (!_setOriginalUserId) {
153             _setOriginalUserId = true;
154 
155             _originalUserId = userId;
156         }
157     }
158 
159     public String getUserUuid() throws SystemException {
160         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
161     }
162 
163     public void setUserUuid(String userUuid) {
164         _userUuid = userUuid;
165     }
166 
167     public long getOriginalUserId() {
168         return _originalUserId;
169     }
170 
171     public Date getCreateDate() {
172         return _createDate;
173     }
174 
175     public void setCreateDate(Date createDate) {
176         _createDate = createDate;
177     }
178 
179     public long getEntryId() {
180         return _entryId;
181     }
182 
183     public void setEntryId(long entryId) {
184         _entryId = entryId;
185 
186         if (!_setOriginalEntryId) {
187             _setOriginalEntryId = true;
188 
189             _originalEntryId = entryId;
190         }
191     }
192 
193     public long getOriginalEntryId() {
194         return _originalEntryId;
195     }
196 
197     public int getValue() {
198         return _value;
199     }
200 
201     public void setValue(int value) {
202         _value = value;
203 
204         if (!_setOriginalValue) {
205             _setOriginalValue = true;
206 
207             _originalValue = value;
208         }
209     }
210 
211     public int getOriginalValue() {
212         return _originalValue;
213     }
214 
215     public AnnouncementsFlag toEscapedModel() {
216         if (isEscapedModel()) {
217             return (AnnouncementsFlag)this;
218         }
219         else {
220             AnnouncementsFlag model = new AnnouncementsFlagImpl();
221 
222             model.setNew(isNew());
223             model.setEscapedModel(true);
224 
225             model.setFlagId(getFlagId());
226             model.setUserId(getUserId());
227             model.setCreateDate(getCreateDate());
228             model.setEntryId(getEntryId());
229             model.setValue(getValue());
230 
231             model = (AnnouncementsFlag)Proxy.newProxyInstance(AnnouncementsFlag.class.getClassLoader(),
232                     new Class[] { AnnouncementsFlag.class },
233                     new ReadOnlyBeanHandler(model));
234 
235             return model;
236         }
237     }
238 
239     public ExpandoBridge getExpandoBridge() {
240         if (_expandoBridge == null) {
241             _expandoBridge = new ExpandoBridgeImpl(AnnouncementsFlag.class.getName(),
242                     getPrimaryKey());
243         }
244 
245         return _expandoBridge;
246     }
247 
248     public Object clone() {
249         AnnouncementsFlagImpl clone = new AnnouncementsFlagImpl();
250 
251         clone.setFlagId(getFlagId());
252         clone.setUserId(getUserId());
253         clone.setCreateDate(getCreateDate());
254         clone.setEntryId(getEntryId());
255         clone.setValue(getValue());
256 
257         return clone;
258     }
259 
260     public int compareTo(AnnouncementsFlag announcementsFlag) {
261         int value = 0;
262 
263         if (getUserId() < announcementsFlag.getUserId()) {
264             value = -1;
265         }
266         else if (getUserId() > announcementsFlag.getUserId()) {
267             value = 1;
268         }
269         else {
270             value = 0;
271         }
272 
273         if (value != 0) {
274             return value;
275         }
276 
277         value = DateUtil.compareTo(getCreateDate(),
278                 announcementsFlag.getCreateDate());
279 
280         if (value != 0) {
281             return value;
282         }
283 
284         return 0;
285     }
286 
287     public boolean equals(Object obj) {
288         if (obj == null) {
289             return false;
290         }
291 
292         AnnouncementsFlag announcementsFlag = null;
293 
294         try {
295             announcementsFlag = (AnnouncementsFlag)obj;
296         }
297         catch (ClassCastException cce) {
298             return false;
299         }
300 
301         long pk = announcementsFlag.getPrimaryKey();
302 
303         if (getPrimaryKey() == pk) {
304             return true;
305         }
306         else {
307             return false;
308         }
309     }
310 
311     public int hashCode() {
312         return (int)getPrimaryKey();
313     }
314 
315     public String toString() {
316         StringBuilder sb = new StringBuilder();
317 
318         sb.append("{flagId=");
319         sb.append(getFlagId());
320         sb.append(", userId=");
321         sb.append(getUserId());
322         sb.append(", createDate=");
323         sb.append(getCreateDate());
324         sb.append(", entryId=");
325         sb.append(getEntryId());
326         sb.append(", value=");
327         sb.append(getValue());
328         sb.append("}");
329 
330         return sb.toString();
331     }
332 
333     public String toXmlString() {
334         StringBuilder sb = new StringBuilder();
335 
336         sb.append("<model><model-name>");
337         sb.append("com.liferay.portlet.announcements.model.AnnouncementsFlag");
338         sb.append("</model-name>");
339 
340         sb.append(
341             "<column><column-name>flagId</column-name><column-value><![CDATA[");
342         sb.append(getFlagId());
343         sb.append("]]></column-value></column>");
344         sb.append(
345             "<column><column-name>userId</column-name><column-value><![CDATA[");
346         sb.append(getUserId());
347         sb.append("]]></column-value></column>");
348         sb.append(
349             "<column><column-name>createDate</column-name><column-value><![CDATA[");
350         sb.append(getCreateDate());
351         sb.append("]]></column-value></column>");
352         sb.append(
353             "<column><column-name>entryId</column-name><column-value><![CDATA[");
354         sb.append(getEntryId());
355         sb.append("]]></column-value></column>");
356         sb.append(
357             "<column><column-name>value</column-name><column-value><![CDATA[");
358         sb.append(getValue());
359         sb.append("]]></column-value></column>");
360 
361         sb.append("</model>");
362 
363         return sb.toString();
364     }
365 
366     private long _flagId;
367     private long _userId;
368     private String _userUuid;
369     private long _originalUserId;
370     private boolean _setOriginalUserId;
371     private Date _createDate;
372     private long _entryId;
373     private long _originalEntryId;
374     private boolean _setOriginalEntryId;
375     private int _value;
376     private int _originalValue;
377     private boolean _setOriginalValue;
378     private transient ExpandoBridge _expandoBridge;
379 }