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