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.kernel.util.HtmlUtil;
28  import com.liferay.portal.model.impl.BaseModelImpl;
29  import com.liferay.portal.util.PropsUtil;
30  
31  import com.liferay.portlet.imagegallery.model.IGImage;
32  import com.liferay.portlet.imagegallery.model.IGImageSoap;
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="IGImageModelImpl.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>IGImage</code> table
54   * in the database.
55   * </p>
56   *
57   * @author Brian Wing Shun Chan
58   *
59   * @see com.liferay.portlet.imagegallery.service.model.IGImage
60   * @see com.liferay.portlet.imagegallery.service.model.IGImageModel
61   * @see com.liferay.portlet.imagegallery.service.model.impl.IGImageImpl
62   *
63   */
64  public class IGImageModelImpl extends BaseModelImpl {
65      public static final String TABLE_NAME = "IGImage";
66      public static final Object[][] TABLE_COLUMNS = {
67              { "uuid_", new Integer(Types.VARCHAR) },
68              
69  
70              { "imageId", new Integer(Types.BIGINT) },
71              
72  
73              { "companyId", new Integer(Types.BIGINT) },
74              
75  
76              { "userId", new Integer(Types.BIGINT) },
77              
78  
79              { "createDate", new Integer(Types.TIMESTAMP) },
80              
81  
82              { "modifiedDate", new Integer(Types.TIMESTAMP) },
83              
84  
85              { "folderId", new Integer(Types.BIGINT) },
86              
87  
88              { "name", new Integer(Types.VARCHAR) },
89              
90  
91              { "description", new Integer(Types.VARCHAR) },
92              
93  
94              { "smallImageId", new Integer(Types.BIGINT) },
95              
96  
97              { "largeImageId", new Integer(Types.BIGINT) },
98              
99  
100             { "custom1ImageId", new Integer(Types.BIGINT) },
101             
102 
103             { "custom2ImageId", new Integer(Types.BIGINT) }
104         };
105     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,name VARCHAR(75) null,description STRING null,smallImageId LONG,largeImageId LONG,custom1ImageId LONG,custom2ImageId LONG)";
106     public static final String TABLE_SQL_DROP = "drop table IGImage";
107     public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
108                 "value.object.finder.cache.enabled.com.liferay.portlet.imagegallery.model.IGImage"),
109             true);
110 
111     public static IGImage toModel(IGImageSoap soapModel) {
112         IGImage model = new IGImageImpl();
113 
114         model.setUuid(soapModel.getUuid());
115         model.setImageId(soapModel.getImageId());
116         model.setCompanyId(soapModel.getCompanyId());
117         model.setUserId(soapModel.getUserId());
118         model.setCreateDate(soapModel.getCreateDate());
119         model.setModifiedDate(soapModel.getModifiedDate());
120         model.setFolderId(soapModel.getFolderId());
121         model.setName(soapModel.getName());
122         model.setDescription(soapModel.getDescription());
123         model.setSmallImageId(soapModel.getSmallImageId());
124         model.setLargeImageId(soapModel.getLargeImageId());
125         model.setCustom1ImageId(soapModel.getCustom1ImageId());
126         model.setCustom2ImageId(soapModel.getCustom2ImageId());
127 
128         return model;
129     }
130 
131     public static List<IGImage> toModels(IGImageSoap[] soapModels) {
132         List<IGImage> models = new ArrayList<IGImage>(soapModels.length);
133 
134         for (IGImageSoap soapModel : soapModels) {
135             models.add(toModel(soapModel));
136         }
137 
138         return models;
139     }
140 
141     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
142                 "lock.expiration.time.com.liferay.portlet.imagegallery.model.IGImage"));
143 
144     public IGImageModelImpl() {
145     }
146 
147     public long getPrimaryKey() {
148         return _imageId;
149     }
150 
151     public void setPrimaryKey(long pk) {
152         setImageId(pk);
153     }
154 
155     public Serializable getPrimaryKeyObj() {
156         return new Long(_imageId);
157     }
158 
159     public String getUuid() {
160         return GetterUtil.getString(_uuid);
161     }
162 
163     public void setUuid(String uuid) {
164         if ((uuid != null) && (uuid != _uuid)) {
165             _uuid = uuid;
166         }
167     }
168 
169     public long getImageId() {
170         return _imageId;
171     }
172 
173     public void setImageId(long imageId) {
174         if (imageId != _imageId) {
175             _imageId = imageId;
176         }
177     }
178 
179     public long getCompanyId() {
180         return _companyId;
181     }
182 
183     public void setCompanyId(long companyId) {
184         if (companyId != _companyId) {
185             _companyId = companyId;
186         }
187     }
188 
189     public long getUserId() {
190         return _userId;
191     }
192 
193     public void setUserId(long userId) {
194         if (userId != _userId) {
195             _userId = userId;
196         }
197     }
198 
199     public Date getCreateDate() {
200         return _createDate;
201     }
202 
203     public void setCreateDate(Date createDate) {
204         if (((createDate == null) && (_createDate != null)) ||
205                 ((createDate != null) && (_createDate == null)) ||
206                 ((createDate != null) && (_createDate != null) &&
207                 !createDate.equals(_createDate))) {
208             _createDate = createDate;
209         }
210     }
211 
212     public Date getModifiedDate() {
213         return _modifiedDate;
214     }
215 
216     public void setModifiedDate(Date modifiedDate) {
217         if (((modifiedDate == null) && (_modifiedDate != null)) ||
218                 ((modifiedDate != null) && (_modifiedDate == null)) ||
219                 ((modifiedDate != null) && (_modifiedDate != null) &&
220                 !modifiedDate.equals(_modifiedDate))) {
221             _modifiedDate = modifiedDate;
222         }
223     }
224 
225     public long getFolderId() {
226         return _folderId;
227     }
228 
229     public void setFolderId(long folderId) {
230         if (folderId != _folderId) {
231             _folderId = folderId;
232         }
233     }
234 
235     public String getName() {
236         return GetterUtil.getString(_name);
237     }
238 
239     public void setName(String name) {
240         if (((name == null) && (_name != null)) ||
241                 ((name != null) && (_name == null)) ||
242                 ((name != null) && (_name != null) && !name.equals(_name))) {
243             _name = name;
244         }
245     }
246 
247     public String getDescription() {
248         return GetterUtil.getString(_description);
249     }
250 
251     public void setDescription(String description) {
252         if (((description == null) && (_description != null)) ||
253                 ((description != null) && (_description == null)) ||
254                 ((description != null) && (_description != null) &&
255                 !description.equals(_description))) {
256             _description = description;
257         }
258     }
259 
260     public long getSmallImageId() {
261         return _smallImageId;
262     }
263 
264     public void setSmallImageId(long smallImageId) {
265         if (smallImageId != _smallImageId) {
266             _smallImageId = smallImageId;
267         }
268     }
269 
270     public long getLargeImageId() {
271         return _largeImageId;
272     }
273 
274     public void setLargeImageId(long largeImageId) {
275         if (largeImageId != _largeImageId) {
276             _largeImageId = largeImageId;
277         }
278     }
279 
280     public long getCustom1ImageId() {
281         return _custom1ImageId;
282     }
283 
284     public void setCustom1ImageId(long custom1ImageId) {
285         if (custom1ImageId != _custom1ImageId) {
286             _custom1ImageId = custom1ImageId;
287         }
288     }
289 
290     public long getCustom2ImageId() {
291         return _custom2ImageId;
292     }
293 
294     public void setCustom2ImageId(long custom2ImageId) {
295         if (custom2ImageId != _custom2ImageId) {
296             _custom2ImageId = custom2ImageId;
297         }
298     }
299 
300     public IGImage toEscapedModel() {
301         if (isEscapedModel()) {
302             return (IGImage)this;
303         }
304         else {
305             IGImage model = new IGImageImpl();
306 
307             model.setEscapedModel(true);
308 
309             model.setUuid(HtmlUtil.escape(getUuid()));
310             model.setImageId(getImageId());
311             model.setCompanyId(getCompanyId());
312             model.setUserId(getUserId());
313             model.setCreateDate(getCreateDate());
314             model.setModifiedDate(getModifiedDate());
315             model.setFolderId(getFolderId());
316             model.setName(HtmlUtil.escape(getName()));
317             model.setDescription(HtmlUtil.escape(getDescription()));
318             model.setSmallImageId(getSmallImageId());
319             model.setLargeImageId(getLargeImageId());
320             model.setCustom1ImageId(getCustom1ImageId());
321             model.setCustom2ImageId(getCustom2ImageId());
322 
323             model = (IGImage)Proxy.newProxyInstance(IGImage.class.getClassLoader(),
324                     new Class[] { IGImage.class },
325                     new ReadOnlyBeanHandler(model));
326 
327             return model;
328         }
329     }
330 
331     public Object clone() {
332         IGImageImpl clone = new IGImageImpl();
333 
334         clone.setUuid(getUuid());
335         clone.setImageId(getImageId());
336         clone.setCompanyId(getCompanyId());
337         clone.setUserId(getUserId());
338         clone.setCreateDate(getCreateDate());
339         clone.setModifiedDate(getModifiedDate());
340         clone.setFolderId(getFolderId());
341         clone.setName(getName());
342         clone.setDescription(getDescription());
343         clone.setSmallImageId(getSmallImageId());
344         clone.setLargeImageId(getLargeImageId());
345         clone.setCustom1ImageId(getCustom1ImageId());
346         clone.setCustom2ImageId(getCustom2ImageId());
347 
348         return clone;
349     }
350 
351     public int compareTo(Object obj) {
352         if (obj == null) {
353             return -1;
354         }
355 
356         IGImageImpl igImage = (IGImageImpl)obj;
357 
358         int value = 0;
359 
360         if (getImageId() < igImage.getImageId()) {
361             value = -1;
362         }
363         else if (getImageId() > igImage.getImageId()) {
364             value = 1;
365         }
366         else {
367             value = 0;
368         }
369 
370         if (value != 0) {
371             return value;
372         }
373 
374         return 0;
375     }
376 
377     public boolean equals(Object obj) {
378         if (obj == null) {
379             return false;
380         }
381 
382         IGImageImpl igImage = null;
383 
384         try {
385             igImage = (IGImageImpl)obj;
386         }
387         catch (ClassCastException cce) {
388             return false;
389         }
390 
391         long pk = igImage.getPrimaryKey();
392 
393         if (getPrimaryKey() == pk) {
394             return true;
395         }
396         else {
397             return false;
398         }
399     }
400 
401     public int hashCode() {
402         return (int)getPrimaryKey();
403     }
404 
405     private String _uuid;
406     private long _imageId;
407     private long _companyId;
408     private long _userId;
409     private Date _createDate;
410     private Date _modifiedDate;
411     private long _folderId;
412     private String _name;
413     private String _description;
414     private long _smallImageId;
415     private long _largeImageId;
416     private long _custom1ImageId;
417     private long _custom2ImageId;
418 }