1   /**
2    * Copyright (c) 2000-2008 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  
33  import java.io.Serializable;
34  
35  import java.lang.reflect.Proxy;
36  
37  import java.sql.Types;
38  
39  import java.util.ArrayList;
40  import java.util.Date;
41  import java.util.List;
42  
43  /**
44   * <a href="AnnouncementsFlagModelImpl.java.html"><b><i>View Source</i></b></a>
45   *
46   * <p>
47   * ServiceBuilder generated this class. Modifications in this class will be
48   * overwritten the next time is generated.
49   * </p>
50   *
51   * <p>
52   * This class is a model that represents the <code>AnnouncementsFlag</code> table
53   * in the database.
54   * </p>
55   *
56   * @author Brian Wing Shun Chan
57   *
58   * @see com.liferay.portlet.announcements.model.AnnouncementsFlag
59   * @see com.liferay.portlet.announcements.model.AnnouncementsFlagModel
60   * @see com.liferay.portlet.announcements.model.impl.AnnouncementsFlagImpl
61   *
62   */
63  public class AnnouncementsFlagModelImpl extends BaseModelImpl {
64      public static final String TABLE_NAME = "AnnouncementsFlag";
65      public static final Object[][] TABLE_COLUMNS = {
66              { "flagId", new Integer(Types.BIGINT) },
67              
68  
69              { "userId", new Integer(Types.BIGINT) },
70              
71  
72              { "createDate", new Integer(Types.TIMESTAMP) },
73              
74  
75              { "entryId", new Integer(Types.BIGINT) },
76              
77  
78              { "value", new Integer(Types.INTEGER) }
79          };
80      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)";
81      public static final String TABLE_SQL_DROP = "drop table AnnouncementsFlag";
82      public static final String DATA_SOURCE = "liferayDataSource";
83      public static final String SESSION_FACTORY = "liferaySessionFactory";
84      public static final String TX_MANAGER = "liferayTransactionManager";
85      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
86                  "value.object.finder.cache.enabled.com.liferay.portlet.announcements.model.AnnouncementsFlag"),
87              true);
88  
89      public static AnnouncementsFlag toModel(AnnouncementsFlagSoap soapModel) {
90          AnnouncementsFlag model = new AnnouncementsFlagImpl();
91  
92          model.setFlagId(soapModel.getFlagId());
93          model.setUserId(soapModel.getUserId());
94          model.setCreateDate(soapModel.getCreateDate());
95          model.setEntryId(soapModel.getEntryId());
96          model.setValue(soapModel.getValue());
97  
98          return model;
99      }
100 
101     public static List<AnnouncementsFlag> toModels(
102         AnnouncementsFlagSoap[] soapModels) {
103         List<AnnouncementsFlag> models = new ArrayList<AnnouncementsFlag>(soapModels.length);
104 
105         for (AnnouncementsFlagSoap soapModel : soapModels) {
106             models.add(toModel(soapModel));
107         }
108 
109         return models;
110     }
111 
112     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
113                 "lock.expiration.time.com.liferay.portlet.announcements.model.AnnouncementsFlag"));
114 
115     public AnnouncementsFlagModelImpl() {
116     }
117 
118     public long getPrimaryKey() {
119         return _flagId;
120     }
121 
122     public void setPrimaryKey(long pk) {
123         setFlagId(pk);
124     }
125 
126     public Serializable getPrimaryKeyObj() {
127         return new Long(_flagId);
128     }
129 
130     public long getFlagId() {
131         return _flagId;
132     }
133 
134     public void setFlagId(long flagId) {
135         if (flagId != _flagId) {
136             _flagId = flagId;
137         }
138     }
139 
140     public long getUserId() {
141         return _userId;
142     }
143 
144     public void setUserId(long userId) {
145         if (userId != _userId) {
146             _userId = userId;
147         }
148     }
149 
150     public Date getCreateDate() {
151         return _createDate;
152     }
153 
154     public void setCreateDate(Date createDate) {
155         if (((createDate == null) && (_createDate != null)) ||
156                 ((createDate != null) && (_createDate == null)) ||
157                 ((createDate != null) && (_createDate != null) &&
158                 !createDate.equals(_createDate))) {
159             _createDate = createDate;
160         }
161     }
162 
163     public long getEntryId() {
164         return _entryId;
165     }
166 
167     public void setEntryId(long entryId) {
168         if (entryId != _entryId) {
169             _entryId = entryId;
170         }
171     }
172 
173     public int getValue() {
174         return _value;
175     }
176 
177     public void setValue(int value) {
178         if (value != _value) {
179             _value = value;
180         }
181     }
182 
183     public AnnouncementsFlag toEscapedModel() {
184         if (isEscapedModel()) {
185             return (AnnouncementsFlag)this;
186         }
187         else {
188             AnnouncementsFlag model = new AnnouncementsFlagImpl();
189 
190             model.setNew(isNew());
191             model.setEscapedModel(true);
192 
193             model.setFlagId(getFlagId());
194             model.setUserId(getUserId());
195             model.setCreateDate(getCreateDate());
196             model.setEntryId(getEntryId());
197             model.setValue(getValue());
198 
199             model = (AnnouncementsFlag)Proxy.newProxyInstance(AnnouncementsFlag.class.getClassLoader(),
200                     new Class[] { AnnouncementsFlag.class },
201                     new ReadOnlyBeanHandler(model));
202 
203             return model;
204         }
205     }
206 
207     public Object clone() {
208         AnnouncementsFlagImpl clone = new AnnouncementsFlagImpl();
209 
210         clone.setFlagId(getFlagId());
211         clone.setUserId(getUserId());
212         clone.setCreateDate(getCreateDate());
213         clone.setEntryId(getEntryId());
214         clone.setValue(getValue());
215 
216         return clone;
217     }
218 
219     public int compareTo(Object obj) {
220         if (obj == null) {
221             return -1;
222         }
223 
224         AnnouncementsFlagImpl announcementsFlag = (AnnouncementsFlagImpl)obj;
225 
226         int value = 0;
227 
228         if (getUserId() < announcementsFlag.getUserId()) {
229             value = -1;
230         }
231         else if (getUserId() > announcementsFlag.getUserId()) {
232             value = 1;
233         }
234         else {
235             value = 0;
236         }
237 
238         if (value != 0) {
239             return value;
240         }
241 
242         value = DateUtil.compareTo(getCreateDate(),
243                 announcementsFlag.getCreateDate());
244 
245         if (value != 0) {
246             return value;
247         }
248 
249         return 0;
250     }
251 
252     public boolean equals(Object obj) {
253         if (obj == null) {
254             return false;
255         }
256 
257         AnnouncementsFlagImpl announcementsFlag = null;
258 
259         try {
260             announcementsFlag = (AnnouncementsFlagImpl)obj;
261         }
262         catch (ClassCastException cce) {
263             return false;
264         }
265 
266         long pk = announcementsFlag.getPrimaryKey();
267 
268         if (getPrimaryKey() == pk) {
269             return true;
270         }
271         else {
272             return false;
273         }
274     }
275 
276     public int hashCode() {
277         return (int)getPrimaryKey();
278     }
279 
280     private long _flagId;
281     private long _userId;
282     private Date _createDate;
283     private long _entryId;
284     private int _value;
285 }