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.imagegallery.model.impl;
24  
25  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.GetterUtil;
27  import com.liferay.portal.model.impl.BaseModelImpl;
28  import com.liferay.portal.util.PropsUtil;
29  
30  import com.liferay.portlet.imagegallery.model.IGImage;
31  
32  import com.liferay.util.Html;
33  
34  import java.io.Serializable;
35  
36  import java.lang.reflect.Proxy;
37  
38  import java.sql.Types;
39  
40  import java.util.Date;
41  
42  /**
43   * <a href="IGImageModelImpl.java.html"><b><i>View Source</i></b></a>
44   *
45   * <p>
46   * ServiceBuilder generated this class. Modifications in this class will be
47   * overwritten the next time is generated.
48   * </p>
49   *
50   * <p>
51   * This class is a model that represents the <code>IGImage</code> table
52   * in the database.
53   * </p>
54   *
55   * @author Brian Wing Shun Chan
56   *
57   * @see com.liferay.portlet.imagegallery.service.model.IGImage
58   * @see com.liferay.portlet.imagegallery.service.model.IGImageModel
59   * @see com.liferay.portlet.imagegallery.service.model.impl.IGImageImpl
60   *
61   */
62  public class IGImageModelImpl extends BaseModelImpl {
63      public static final String TABLE_NAME = "IGImage";
64      public static final Object[][] TABLE_COLUMNS = {
65              { "uuid_", new Integer(Types.VARCHAR) },
66              
67  
68              { "imageId", new Integer(Types.BIGINT) },
69              
70  
71              { "companyId", new Integer(Types.BIGINT) },
72              
73  
74              { "userId", new Integer(Types.BIGINT) },
75              
76  
77              { "createDate", new Integer(Types.TIMESTAMP) },
78              
79  
80              { "modifiedDate", new Integer(Types.TIMESTAMP) },
81              
82  
83              { "folderId", new Integer(Types.BIGINT) },
84              
85  
86              { "description", new Integer(Types.VARCHAR) },
87              
88  
89              { "smallImageId", new Integer(Types.BIGINT) },
90              
91  
92              { "largeImageId", new Integer(Types.BIGINT) }
93          };
94      public static final String TABLE_SQL_CREATE = "create table IGImage (uuid_ VARCHAR(75) null,imageId LONG not null primary key,companyId LONG,userId LONG,createDate DATE null,modifiedDate DATE null,folderId LONG,description STRING null,smallImageId LONG,largeImageId LONG)";
95      public static final String TABLE_SQL_DROP = "drop table IGImage";
96      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
97                  "value.object.finder.cache.enabled.com.liferay.portlet.imagegallery.model.IGImage"),
98              true);
99      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
100                 "lock.expiration.time.com.liferay.portlet.imagegallery.model.IGImage"));
101 
102     public IGImageModelImpl() {
103     }
104 
105     public long getPrimaryKey() {
106         return _imageId;
107     }
108 
109     public void setPrimaryKey(long pk) {
110         setImageId(pk);
111     }
112 
113     public Serializable getPrimaryKeyObj() {
114         return new Long(_imageId);
115     }
116 
117     public String getUuid() {
118         return GetterUtil.getString(_uuid);
119     }
120 
121     public void setUuid(String uuid) {
122         if ((uuid != null) && (uuid != _uuid)) {
123             _uuid = uuid;
124         }
125     }
126 
127     public long getImageId() {
128         return _imageId;
129     }
130 
131     public void setImageId(long imageId) {
132         if (imageId != _imageId) {
133             _imageId = imageId;
134         }
135     }
136 
137     public long getCompanyId() {
138         return _companyId;
139     }
140 
141     public void setCompanyId(long companyId) {
142         if (companyId != _companyId) {
143             _companyId = companyId;
144         }
145     }
146 
147     public long getUserId() {
148         return _userId;
149     }
150 
151     public void setUserId(long userId) {
152         if (userId != _userId) {
153             _userId = userId;
154         }
155     }
156 
157     public Date getCreateDate() {
158         return _createDate;
159     }
160 
161     public void setCreateDate(Date createDate) {
162         if (((createDate == null) && (_createDate != null)) ||
163                 ((createDate != null) && (_createDate == null)) ||
164                 ((createDate != null) && (_createDate != null) &&
165                 !createDate.equals(_createDate))) {
166             _createDate = createDate;
167         }
168     }
169 
170     public Date getModifiedDate() {
171         return _modifiedDate;
172     }
173 
174     public void setModifiedDate(Date modifiedDate) {
175         if (((modifiedDate == null) && (_modifiedDate != null)) ||
176                 ((modifiedDate != null) && (_modifiedDate == null)) ||
177                 ((modifiedDate != null) && (_modifiedDate != null) &&
178                 !modifiedDate.equals(_modifiedDate))) {
179             _modifiedDate = modifiedDate;
180         }
181     }
182 
183     public long getFolderId() {
184         return _folderId;
185     }
186 
187     public void setFolderId(long folderId) {
188         if (folderId != _folderId) {
189             _folderId = folderId;
190         }
191     }
192 
193     public String getDescription() {
194         return GetterUtil.getString(_description);
195     }
196 
197     public void setDescription(String description) {
198         if (((description == null) && (_description != null)) ||
199                 ((description != null) && (_description == null)) ||
200                 ((description != null) && (_description != null) &&
201                 !description.equals(_description))) {
202             _description = description;
203         }
204     }
205 
206     public long getSmallImageId() {
207         return _smallImageId;
208     }
209 
210     public void setSmallImageId(long smallImageId) {
211         if (smallImageId != _smallImageId) {
212             _smallImageId = smallImageId;
213         }
214     }
215 
216     public long getLargeImageId() {
217         return _largeImageId;
218     }
219 
220     public void setLargeImageId(long largeImageId) {
221         if (largeImageId != _largeImageId) {
222             _largeImageId = largeImageId;
223         }
224     }
225 
226     public IGImage toEscapedModel() {
227         if (isEscapedModel()) {
228             return (IGImage)this;
229         }
230         else {
231             IGImage model = new IGImageImpl();
232 
233             model.setEscapedModel(true);
234 
235             model.setUuid(Html.escape(getUuid()));
236             model.setImageId(getImageId());
237             model.setCompanyId(getCompanyId());
238             model.setUserId(getUserId());
239             model.setCreateDate(getCreateDate());
240             model.setModifiedDate(getModifiedDate());
241             model.setFolderId(getFolderId());
242             model.setDescription(Html.escape(getDescription()));
243             model.setSmallImageId(getSmallImageId());
244             model.setLargeImageId(getLargeImageId());
245 
246             model = (IGImage)Proxy.newProxyInstance(IGImage.class.getClassLoader(),
247                     new Class[] { IGImage.class },
248                     new ReadOnlyBeanHandler(model));
249 
250             return model;
251         }
252     }
253 
254     public Object clone() {
255         IGImageImpl clone = new IGImageImpl();
256 
257         clone.setUuid(getUuid());
258         clone.setImageId(getImageId());
259         clone.setCompanyId(getCompanyId());
260         clone.setUserId(getUserId());
261         clone.setCreateDate(getCreateDate());
262         clone.setModifiedDate(getModifiedDate());
263         clone.setFolderId(getFolderId());
264         clone.setDescription(getDescription());
265         clone.setSmallImageId(getSmallImageId());
266         clone.setLargeImageId(getLargeImageId());
267 
268         return clone;
269     }
270 
271     public int compareTo(Object obj) {
272         if (obj == null) {
273             return -1;
274         }
275 
276         IGImageImpl igImage = (IGImageImpl)obj;
277 
278         int value = 0;
279 
280         if (getImageId() < igImage.getImageId()) {
281             value = -1;
282         }
283         else if (getImageId() > igImage.getImageId()) {
284             value = 1;
285         }
286         else {
287             value = 0;
288         }
289 
290         if (value != 0) {
291             return value;
292         }
293 
294         return 0;
295     }
296 
297     public boolean equals(Object obj) {
298         if (obj == null) {
299             return false;
300         }
301 
302         IGImageImpl igImage = null;
303 
304         try {
305             igImage = (IGImageImpl)obj;
306         }
307         catch (ClassCastException cce) {
308             return false;
309         }
310 
311         long pk = igImage.getPrimaryKey();
312 
313         if (getPrimaryKey() == pk) {
314             return true;
315         }
316         else {
317             return false;
318         }
319     }
320 
321     public int hashCode() {
322         return (int)getPrimaryKey();
323     }
324 
325     private String _uuid;
326     private long _imageId;
327     private long _companyId;
328     private long _userId;
329     private Date _createDate;
330     private Date _modifiedDate;
331     private long _folderId;
332     private String _description;
333     private long _smallImageId;
334     private long _largeImageId;
335 }