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