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