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.kernel.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.DateUtil;
27  import com.liferay.portal.kernel.util.GetterUtil;
28  import com.liferay.portal.model.impl.BaseModelImpl;
29  
30  import com.liferay.portlet.announcements.model.AnnouncementsFlag;
31  import com.liferay.portlet.announcements.model.AnnouncementsFlagSoap;
32  import com.liferay.portlet.expando.model.ExpandoBridge;
33  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
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 long getOriginalUserId() {
158         return _originalUserId;
159     }
160 
161     public Date getCreateDate() {
162         return _createDate;
163     }
164 
165     public void setCreateDate(Date createDate) {
166         _createDate = createDate;
167     }
168 
169     public long getEntryId() {
170         return _entryId;
171     }
172 
173     public void setEntryId(long entryId) {
174         _entryId = entryId;
175 
176         if (!_setOriginalEntryId) {
177             _setOriginalEntryId = true;
178 
179             _originalEntryId = entryId;
180         }
181     }
182 
183     public long getOriginalEntryId() {
184         return _originalEntryId;
185     }
186 
187     public int getValue() {
188         return _value;
189     }
190 
191     public void setValue(int value) {
192         _value = value;
193 
194         if (!_setOriginalValue) {
195             _setOriginalValue = true;
196 
197             _originalValue = value;
198         }
199     }
200 
201     public int getOriginalValue() {
202         return _originalValue;
203     }
204 
205     public AnnouncementsFlag toEscapedModel() {
206         if (isEscapedModel()) {
207             return (AnnouncementsFlag)this;
208         }
209         else {
210             AnnouncementsFlag model = new AnnouncementsFlagImpl();
211 
212             model.setNew(isNew());
213             model.setEscapedModel(true);
214 
215             model.setFlagId(getFlagId());
216             model.setUserId(getUserId());
217             model.setCreateDate(getCreateDate());
218             model.setEntryId(getEntryId());
219             model.setValue(getValue());
220 
221             model = (AnnouncementsFlag)Proxy.newProxyInstance(AnnouncementsFlag.class.getClassLoader(),
222                     new Class[] { AnnouncementsFlag.class },
223                     new ReadOnlyBeanHandler(model));
224 
225             return model;
226         }
227     }
228 
229     public ExpandoBridge getExpandoBridge() {
230         if (_expandoBridge == null) {
231             _expandoBridge = new ExpandoBridgeImpl(AnnouncementsFlag.class.getName(),
232                     getPrimaryKey());
233         }
234 
235         return _expandoBridge;
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         StringBuilder sb = new StringBuilder();
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         StringBuilder sb = new StringBuilder();
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 long _originalUserId;
359     private boolean _setOriginalUserId;
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     private transient ExpandoBridge _expandoBridge;
368 }