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