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<IGImage> {
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              { "groupId", new Integer(Types.BIGINT) },
75              
76  
77              { "companyId", new Integer(Types.BIGINT) },
78              
79  
80              { "userId", new Integer(Types.BIGINT) },
81              
82  
83              { "createDate", new Integer(Types.TIMESTAMP) },
84              
85  
86              { "modifiedDate", new Integer(Types.TIMESTAMP) },
87              
88  
89              { "folderId", new Integer(Types.BIGINT) },
90              
91  
92              { "name", new Integer(Types.VARCHAR) },
93              
94  
95              { "description", new Integer(Types.VARCHAR) },
96              
97  
98              { "smallImageId", new Integer(Types.BIGINT) },
99              
100 
101             { "largeImageId", new Integer(Types.BIGINT) },
102             
103 
104             { "custom1ImageId", new Integer(Types.BIGINT) },
105             
106 
107             { "custom2ImageId", new Integer(Types.BIGINT) }
108         };
109     public static final String TABLE_SQL_CREATE = "create table IGImage (uuid_ VARCHAR(75) null,imageId LONG not null primary key,groupId LONG,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)";
110     public static final String TABLE_SQL_DROP = "drop table IGImage";
111     public static final String DATA_SOURCE = "liferayDataSource";
112     public static final String SESSION_FACTORY = "liferaySessionFactory";
113     public static final String TX_MANAGER = "liferayTransactionManager";
114     public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
115                 "value.object.entity.cache.enabled.com.liferay.portlet.imagegallery.model.IGImage"),
116             true);
117     public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
118                 "value.object.finder.cache.enabled.com.liferay.portlet.imagegallery.model.IGImage"),
119             true);
120 
121     public static IGImage toModel(IGImageSoap soapModel) {
122         IGImage model = new IGImageImpl();
123 
124         model.setUuid(soapModel.getUuid());
125         model.setImageId(soapModel.getImageId());
126         model.setGroupId(soapModel.getGroupId());
127         model.setCompanyId(soapModel.getCompanyId());
128         model.setUserId(soapModel.getUserId());
129         model.setCreateDate(soapModel.getCreateDate());
130         model.setModifiedDate(soapModel.getModifiedDate());
131         model.setFolderId(soapModel.getFolderId());
132         model.setName(soapModel.getName());
133         model.setDescription(soapModel.getDescription());
134         model.setSmallImageId(soapModel.getSmallImageId());
135         model.setLargeImageId(soapModel.getLargeImageId());
136         model.setCustom1ImageId(soapModel.getCustom1ImageId());
137         model.setCustom2ImageId(soapModel.getCustom2ImageId());
138 
139         return model;
140     }
141 
142     public static List<IGImage> toModels(IGImageSoap[] soapModels) {
143         List<IGImage> models = new ArrayList<IGImage>(soapModels.length);
144 
145         for (IGImageSoap soapModel : soapModels) {
146             models.add(toModel(soapModel));
147         }
148 
149         return models;
150     }
151 
152     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
153                 "lock.expiration.time.com.liferay.portlet.imagegallery.model.IGImage"));
154 
155     public IGImageModelImpl() {
156     }
157 
158     public long getPrimaryKey() {
159         return _imageId;
160     }
161 
162     public void setPrimaryKey(long pk) {
163         setImageId(pk);
164     }
165 
166     public Serializable getPrimaryKeyObj() {
167         return new Long(_imageId);
168     }
169 
170     public String getUuid() {
171         return GetterUtil.getString(_uuid);
172     }
173 
174     public void setUuid(String uuid) {
175         _uuid = uuid;
176 
177         if (_originalUuid == null) {
178             _originalUuid = uuid;
179         }
180     }
181 
182     public String getOriginalUuid() {
183         return GetterUtil.getString(_originalUuid);
184     }
185 
186     public long getImageId() {
187         return _imageId;
188     }
189 
190     public void setImageId(long imageId) {
191         _imageId = imageId;
192     }
193 
194     public long getGroupId() {
195         return _groupId;
196     }
197 
198     public void setGroupId(long groupId) {
199         _groupId = groupId;
200 
201         if (!_setOriginalGroupId) {
202             _setOriginalGroupId = true;
203 
204             _originalGroupId = groupId;
205         }
206     }
207 
208     public long getOriginalGroupId() {
209         return _originalGroupId;
210     }
211 
212     public long getCompanyId() {
213         return _companyId;
214     }
215 
216     public void setCompanyId(long companyId) {
217         _companyId = companyId;
218     }
219 
220     public long getUserId() {
221         return _userId;
222     }
223 
224     public void setUserId(long userId) {
225         _userId = userId;
226     }
227 
228     public Date getCreateDate() {
229         return _createDate;
230     }
231 
232     public void setCreateDate(Date createDate) {
233         _createDate = createDate;
234     }
235 
236     public Date getModifiedDate() {
237         return _modifiedDate;
238     }
239 
240     public void setModifiedDate(Date modifiedDate) {
241         _modifiedDate = modifiedDate;
242     }
243 
244     public long getFolderId() {
245         return _folderId;
246     }
247 
248     public void setFolderId(long folderId) {
249         _folderId = folderId;
250     }
251 
252     public String getName() {
253         return GetterUtil.getString(_name);
254     }
255 
256     public void setName(String name) {
257         _name = name;
258     }
259 
260     public String getDescription() {
261         return GetterUtil.getString(_description);
262     }
263 
264     public void setDescription(String description) {
265         _description = description;
266     }
267 
268     public long getSmallImageId() {
269         return _smallImageId;
270     }
271 
272     public void setSmallImageId(long smallImageId) {
273         _smallImageId = smallImageId;
274 
275         if (!_setOriginalSmallImageId) {
276             _setOriginalSmallImageId = true;
277 
278             _originalSmallImageId = smallImageId;
279         }
280     }
281 
282     public long getOriginalSmallImageId() {
283         return _originalSmallImageId;
284     }
285 
286     public long getLargeImageId() {
287         return _largeImageId;
288     }
289 
290     public void setLargeImageId(long largeImageId) {
291         _largeImageId = largeImageId;
292 
293         if (!_setOriginalLargeImageId) {
294             _setOriginalLargeImageId = true;
295 
296             _originalLargeImageId = largeImageId;
297         }
298     }
299 
300     public long getOriginalLargeImageId() {
301         return _originalLargeImageId;
302     }
303 
304     public long getCustom1ImageId() {
305         return _custom1ImageId;
306     }
307 
308     public void setCustom1ImageId(long custom1ImageId) {
309         _custom1ImageId = custom1ImageId;
310 
311         if (!_setOriginalCustom1ImageId) {
312             _setOriginalCustom1ImageId = true;
313 
314             _originalCustom1ImageId = custom1ImageId;
315         }
316     }
317 
318     public long getOriginalCustom1ImageId() {
319         return _originalCustom1ImageId;
320     }
321 
322     public long getCustom2ImageId() {
323         return _custom2ImageId;
324     }
325 
326     public void setCustom2ImageId(long custom2ImageId) {
327         _custom2ImageId = custom2ImageId;
328 
329         if (!_setOriginalCustom2ImageId) {
330             _setOriginalCustom2ImageId = true;
331 
332             _originalCustom2ImageId = custom2ImageId;
333         }
334     }
335 
336     public long getOriginalCustom2ImageId() {
337         return _originalCustom2ImageId;
338     }
339 
340     public IGImage toEscapedModel() {
341         if (isEscapedModel()) {
342             return (IGImage)this;
343         }
344         else {
345             IGImage model = new IGImageImpl();
346 
347             model.setNew(isNew());
348             model.setEscapedModel(true);
349 
350             model.setUuid(HtmlUtil.escape(getUuid()));
351             model.setImageId(getImageId());
352             model.setGroupId(getGroupId());
353             model.setCompanyId(getCompanyId());
354             model.setUserId(getUserId());
355             model.setCreateDate(getCreateDate());
356             model.setModifiedDate(getModifiedDate());
357             model.setFolderId(getFolderId());
358             model.setName(HtmlUtil.escape(getName()));
359             model.setDescription(HtmlUtil.escape(getDescription()));
360             model.setSmallImageId(getSmallImageId());
361             model.setLargeImageId(getLargeImageId());
362             model.setCustom1ImageId(getCustom1ImageId());
363             model.setCustom2ImageId(getCustom2ImageId());
364 
365             model = (IGImage)Proxy.newProxyInstance(IGImage.class.getClassLoader(),
366                     new Class[] { IGImage.class },
367                     new ReadOnlyBeanHandler(model));
368 
369             return model;
370         }
371     }
372 
373     public ExpandoBridge getExpandoBridge() {
374         if (_expandoBridge == null) {
375             _expandoBridge = new ExpandoBridgeImpl(IGImage.class.getName(),
376                     getPrimaryKey());
377         }
378 
379         return _expandoBridge;
380     }
381 
382     public Object clone() {
383         IGImageImpl clone = new IGImageImpl();
384 
385         clone.setUuid(getUuid());
386         clone.setImageId(getImageId());
387         clone.setGroupId(getGroupId());
388         clone.setCompanyId(getCompanyId());
389         clone.setUserId(getUserId());
390         clone.setCreateDate(getCreateDate());
391         clone.setModifiedDate(getModifiedDate());
392         clone.setFolderId(getFolderId());
393         clone.setName(getName());
394         clone.setDescription(getDescription());
395         clone.setSmallImageId(getSmallImageId());
396         clone.setLargeImageId(getLargeImageId());
397         clone.setCustom1ImageId(getCustom1ImageId());
398         clone.setCustom2ImageId(getCustom2ImageId());
399 
400         return clone;
401     }
402 
403     public int compareTo(IGImage igImage) {
404         int value = 0;
405 
406         if (getImageId() < igImage.getImageId()) {
407             value = -1;
408         }
409         else if (getImageId() > igImage.getImageId()) {
410             value = 1;
411         }
412         else {
413             value = 0;
414         }
415 
416         if (value != 0) {
417             return value;
418         }
419 
420         return 0;
421     }
422 
423     public boolean equals(Object obj) {
424         if (obj == null) {
425             return false;
426         }
427 
428         IGImage igImage = null;
429 
430         try {
431             igImage = (IGImage)obj;
432         }
433         catch (ClassCastException cce) {
434             return false;
435         }
436 
437         long pk = igImage.getPrimaryKey();
438 
439         if (getPrimaryKey() == pk) {
440             return true;
441         }
442         else {
443             return false;
444         }
445     }
446 
447     public int hashCode() {
448         return (int)getPrimaryKey();
449     }
450 
451     public String toString() {
452         StringBuilder sb = new StringBuilder();
453 
454         sb.append("{uuid=");
455         sb.append(getUuid());
456         sb.append(", imageId=");
457         sb.append(getImageId());
458         sb.append(", groupId=");
459         sb.append(getGroupId());
460         sb.append(", companyId=");
461         sb.append(getCompanyId());
462         sb.append(", userId=");
463         sb.append(getUserId());
464         sb.append(", createDate=");
465         sb.append(getCreateDate());
466         sb.append(", modifiedDate=");
467         sb.append(getModifiedDate());
468         sb.append(", folderId=");
469         sb.append(getFolderId());
470         sb.append(", name=");
471         sb.append(getName());
472         sb.append(", description=");
473         sb.append(getDescription());
474         sb.append(", smallImageId=");
475         sb.append(getSmallImageId());
476         sb.append(", largeImageId=");
477         sb.append(getLargeImageId());
478         sb.append(", custom1ImageId=");
479         sb.append(getCustom1ImageId());
480         sb.append(", custom2ImageId=");
481         sb.append(getCustom2ImageId());
482         sb.append("}");
483 
484         return sb.toString();
485     }
486 
487     public String toXmlString() {
488         StringBuilder sb = new StringBuilder();
489 
490         sb.append("<model><model-name>");
491         sb.append("com.liferay.portlet.imagegallery.model.IGImage");
492         sb.append("</model-name>");
493 
494         sb.append(
495             "<column><column-name>uuid</column-name><column-value><![CDATA[");
496         sb.append(getUuid());
497         sb.append("]]></column-value></column>");
498         sb.append(
499             "<column><column-name>imageId</column-name><column-value><![CDATA[");
500         sb.append(getImageId());
501         sb.append("]]></column-value></column>");
502         sb.append(
503             "<column><column-name>groupId</column-name><column-value><![CDATA[");
504         sb.append(getGroupId());
505         sb.append("]]></column-value></column>");
506         sb.append(
507             "<column><column-name>companyId</column-name><column-value><![CDATA[");
508         sb.append(getCompanyId());
509         sb.append("]]></column-value></column>");
510         sb.append(
511             "<column><column-name>userId</column-name><column-value><![CDATA[");
512         sb.append(getUserId());
513         sb.append("]]></column-value></column>");
514         sb.append(
515             "<column><column-name>createDate</column-name><column-value><![CDATA[");
516         sb.append(getCreateDate());
517         sb.append("]]></column-value></column>");
518         sb.append(
519             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
520         sb.append(getModifiedDate());
521         sb.append("]]></column-value></column>");
522         sb.append(
523             "<column><column-name>folderId</column-name><column-value><![CDATA[");
524         sb.append(getFolderId());
525         sb.append("]]></column-value></column>");
526         sb.append(
527             "<column><column-name>name</column-name><column-value><![CDATA[");
528         sb.append(getName());
529         sb.append("]]></column-value></column>");
530         sb.append(
531             "<column><column-name>description</column-name><column-value><![CDATA[");
532         sb.append(getDescription());
533         sb.append("]]></column-value></column>");
534         sb.append(
535             "<column><column-name>smallImageId</column-name><column-value><![CDATA[");
536         sb.append(getSmallImageId());
537         sb.append("]]></column-value></column>");
538         sb.append(
539             "<column><column-name>largeImageId</column-name><column-value><![CDATA[");
540         sb.append(getLargeImageId());
541         sb.append("]]></column-value></column>");
542         sb.append(
543             "<column><column-name>custom1ImageId</column-name><column-value><![CDATA[");
544         sb.append(getCustom1ImageId());
545         sb.append("]]></column-value></column>");
546         sb.append(
547             "<column><column-name>custom2ImageId</column-name><column-value><![CDATA[");
548         sb.append(getCustom2ImageId());
549         sb.append("]]></column-value></column>");
550 
551         sb.append("</model>");
552 
553         return sb.toString();
554     }
555 
556     private String _uuid;
557     private String _originalUuid;
558     private long _imageId;
559     private long _groupId;
560     private long _originalGroupId;
561     private boolean _setOriginalGroupId;
562     private long _companyId;
563     private long _userId;
564     private Date _createDate;
565     private Date _modifiedDate;
566     private long _folderId;
567     private String _name;
568     private String _description;
569     private long _smallImageId;
570     private long _originalSmallImageId;
571     private boolean _setOriginalSmallImageId;
572     private long _largeImageId;
573     private long _originalLargeImageId;
574     private boolean _setOriginalLargeImageId;
575     private long _custom1ImageId;
576     private long _originalCustom1ImageId;
577     private boolean _setOriginalCustom1ImageId;
578     private long _custom2ImageId;
579     private long _originalCustom2ImageId;
580     private boolean _setOriginalCustom2ImageId;
581     private transient ExpandoBridge _expandoBridge;
582 }