001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.imagegallery.model.impl;
016    
017    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.util.GetterUtil;
020    import com.liferay.portal.kernel.util.StringBundler;
021    import com.liferay.portal.kernel.util.StringPool;
022    import com.liferay.portal.model.impl.BaseModelImpl;
023    import com.liferay.portal.service.ServiceContext;
024    import com.liferay.portal.util.PortalUtil;
025    
026    import com.liferay.portlet.expando.model.ExpandoBridge;
027    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
028    import com.liferay.portlet.imagegallery.model.IGImage;
029    import com.liferay.portlet.imagegallery.model.IGImageModel;
030    import com.liferay.portlet.imagegallery.model.IGImageSoap;
031    
032    import java.io.Serializable;
033    
034    import java.lang.reflect.Proxy;
035    
036    import java.sql.Types;
037    
038    import java.util.ArrayList;
039    import java.util.Date;
040    import java.util.List;
041    
042    /**
043     * The base model implementation for the IGImage service. Represents a row in the "IGImage" database table, with each column mapped to a property of this class.
044     *
045     * <p>
046     * This implementation and its corresponding interface {@link com.liferay.portlet.imagegallery.model.IGImageModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link IGImageImpl}.
047     * </p>
048     *
049     * <p>
050     * Never modify or reference this class directly. All methods that expect a i g image model instance should use the {@link com.liferay.portlet.imagegallery.model.IGImage} interface instead.
051     * </p>
052     *
053     * @author Brian Wing Shun Chan
054     * @see IGImageImpl
055     * @see com.liferay.portlet.imagegallery.model.IGImage
056     * @see com.liferay.portlet.imagegallery.model.IGImageModel
057     * @generated
058     */
059    public class IGImageModelImpl extends BaseModelImpl<IGImage>
060            implements IGImageModel {
061            public static final String TABLE_NAME = "IGImage";
062            public static final Object[][] TABLE_COLUMNS = {
063                            { "uuid_", new Integer(Types.VARCHAR) },
064                            { "imageId", new Integer(Types.BIGINT) },
065                            { "groupId", new Integer(Types.BIGINT) },
066                            { "companyId", new Integer(Types.BIGINT) },
067                            { "userId", new Integer(Types.BIGINT) },
068                            { "createDate", new Integer(Types.TIMESTAMP) },
069                            { "modifiedDate", new Integer(Types.TIMESTAMP) },
070                            { "folderId", new Integer(Types.BIGINT) },
071                            { "name", new Integer(Types.VARCHAR) },
072                            { "description", new Integer(Types.VARCHAR) },
073                            { "smallImageId", new Integer(Types.BIGINT) },
074                            { "largeImageId", new Integer(Types.BIGINT) },
075                            { "custom1ImageId", new Integer(Types.BIGINT) },
076                            { "custom2ImageId", new Integer(Types.BIGINT) }
077                    };
078            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)";
079            public static final String TABLE_SQL_DROP = "drop table IGImage";
080            public static final String ORDER_BY_JPQL = " ORDER BY igImage.imageId ASC";
081            public static final String ORDER_BY_SQL = " ORDER BY IGImage.imageId ASC";
082            public static final String DATA_SOURCE = "liferayDataSource";
083            public static final String SESSION_FACTORY = "liferaySessionFactory";
084            public static final String TX_MANAGER = "liferayTransactionManager";
085            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
086                                    "value.object.entity.cache.enabled.com.liferay.portlet.imagegallery.model.IGImage"),
087                            true);
088            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
089                                    "value.object.finder.cache.enabled.com.liferay.portlet.imagegallery.model.IGImage"),
090                            true);
091    
092            /**
093             * Converts the soap model instance into a normal model instance.
094             *
095             * @param soapModel the soap model instance to convert
096             * @return the normal model instance
097             */
098            public static IGImage toModel(IGImageSoap soapModel) {
099                    IGImage model = new IGImageImpl();
100    
101                    model.setUuid(soapModel.getUuid());
102                    model.setImageId(soapModel.getImageId());
103                    model.setGroupId(soapModel.getGroupId());
104                    model.setCompanyId(soapModel.getCompanyId());
105                    model.setUserId(soapModel.getUserId());
106                    model.setCreateDate(soapModel.getCreateDate());
107                    model.setModifiedDate(soapModel.getModifiedDate());
108                    model.setFolderId(soapModel.getFolderId());
109                    model.setName(soapModel.getName());
110                    model.setDescription(soapModel.getDescription());
111                    model.setSmallImageId(soapModel.getSmallImageId());
112                    model.setLargeImageId(soapModel.getLargeImageId());
113                    model.setCustom1ImageId(soapModel.getCustom1ImageId());
114                    model.setCustom2ImageId(soapModel.getCustom2ImageId());
115    
116                    return model;
117            }
118    
119            /**
120             * Converts the soap model instances into normal model instances.
121             *
122             * @param soapModels the soap model instances to convert
123             * @return the normal model instances
124             */
125            public static List<IGImage> toModels(IGImageSoap[] soapModels) {
126                    List<IGImage> models = new ArrayList<IGImage>(soapModels.length);
127    
128                    for (IGImageSoap soapModel : soapModels) {
129                            models.add(toModel(soapModel));
130                    }
131    
132                    return models;
133            }
134    
135            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
136                                    "lock.expiration.time.com.liferay.portlet.imagegallery.model.IGImage"));
137    
138            public IGImageModelImpl() {
139            }
140    
141            public long getPrimaryKey() {
142                    return _imageId;
143            }
144    
145            public void setPrimaryKey(long pk) {
146                    setImageId(pk);
147            }
148    
149            public Serializable getPrimaryKeyObj() {
150                    return new Long(_imageId);
151            }
152    
153            public String getUuid() {
154                    if (_uuid == null) {
155                            return StringPool.BLANK;
156                    }
157                    else {
158                            return _uuid;
159                    }
160            }
161    
162            public void setUuid(String uuid) {
163                    if (_originalUuid == null) {
164                            _originalUuid = _uuid;
165                    }
166    
167                    _uuid = uuid;
168            }
169    
170            public String getOriginalUuid() {
171                    return GetterUtil.getString(_originalUuid);
172            }
173    
174            public long getImageId() {
175                    return _imageId;
176            }
177    
178            public void setImageId(long imageId) {
179                    _imageId = imageId;
180            }
181    
182            public long getGroupId() {
183                    return _groupId;
184            }
185    
186            public void setGroupId(long groupId) {
187                    if (!_setOriginalGroupId) {
188                            _setOriginalGroupId = true;
189    
190                            _originalGroupId = _groupId;
191                    }
192    
193                    _groupId = groupId;
194            }
195    
196            public long getOriginalGroupId() {
197                    return _originalGroupId;
198            }
199    
200            public long getCompanyId() {
201                    return _companyId;
202            }
203    
204            public void setCompanyId(long companyId) {
205                    _companyId = companyId;
206            }
207    
208            public long getUserId() {
209                    return _userId;
210            }
211    
212            public void setUserId(long userId) {
213                    _userId = userId;
214            }
215    
216            public String getUserUuid() throws SystemException {
217                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
218            }
219    
220            public void setUserUuid(String userUuid) {
221                    _userUuid = userUuid;
222            }
223    
224            public Date getCreateDate() {
225                    return _createDate;
226            }
227    
228            public void setCreateDate(Date createDate) {
229                    _createDate = createDate;
230            }
231    
232            public Date getModifiedDate() {
233                    return _modifiedDate;
234            }
235    
236            public void setModifiedDate(Date modifiedDate) {
237                    _modifiedDate = modifiedDate;
238            }
239    
240            public long getFolderId() {
241                    return _folderId;
242            }
243    
244            public void setFolderId(long folderId) {
245                    _folderId = folderId;
246            }
247    
248            public String getName() {
249                    if (_name == null) {
250                            return StringPool.BLANK;
251                    }
252                    else {
253                            return _name;
254                    }
255            }
256    
257            public void setName(String name) {
258                    _name = name;
259            }
260    
261            public String getDescription() {
262                    if (_description == null) {
263                            return StringPool.BLANK;
264                    }
265                    else {
266                            return _description;
267                    }
268            }
269    
270            public void setDescription(String description) {
271                    _description = description;
272            }
273    
274            public long getSmallImageId() {
275                    return _smallImageId;
276            }
277    
278            public void setSmallImageId(long smallImageId) {
279                    if (!_setOriginalSmallImageId) {
280                            _setOriginalSmallImageId = true;
281    
282                            _originalSmallImageId = _smallImageId;
283                    }
284    
285                    _smallImageId = smallImageId;
286            }
287    
288            public long getOriginalSmallImageId() {
289                    return _originalSmallImageId;
290            }
291    
292            public long getLargeImageId() {
293                    return _largeImageId;
294            }
295    
296            public void setLargeImageId(long largeImageId) {
297                    if (!_setOriginalLargeImageId) {
298                            _setOriginalLargeImageId = true;
299    
300                            _originalLargeImageId = _largeImageId;
301                    }
302    
303                    _largeImageId = largeImageId;
304            }
305    
306            public long getOriginalLargeImageId() {
307                    return _originalLargeImageId;
308            }
309    
310            public long getCustom1ImageId() {
311                    return _custom1ImageId;
312            }
313    
314            public void setCustom1ImageId(long custom1ImageId) {
315                    if (!_setOriginalCustom1ImageId) {
316                            _setOriginalCustom1ImageId = true;
317    
318                            _originalCustom1ImageId = _custom1ImageId;
319                    }
320    
321                    _custom1ImageId = custom1ImageId;
322            }
323    
324            public long getOriginalCustom1ImageId() {
325                    return _originalCustom1ImageId;
326            }
327    
328            public long getCustom2ImageId() {
329                    return _custom2ImageId;
330            }
331    
332            public void setCustom2ImageId(long custom2ImageId) {
333                    if (!_setOriginalCustom2ImageId) {
334                            _setOriginalCustom2ImageId = true;
335    
336                            _originalCustom2ImageId = _custom2ImageId;
337                    }
338    
339                    _custom2ImageId = custom2ImageId;
340            }
341    
342            public long getOriginalCustom2ImageId() {
343                    return _originalCustom2ImageId;
344            }
345    
346            public IGImage toEscapedModel() {
347                    if (isEscapedModel()) {
348                            return (IGImage)this;
349                    }
350                    else {
351                            return (IGImage)Proxy.newProxyInstance(IGImage.class.getClassLoader(),
352                                    new Class[] { IGImage.class }, new AutoEscapeBeanHandler(this));
353                    }
354            }
355    
356            public ExpandoBridge getExpandoBridge() {
357                    if (_expandoBridge == null) {
358                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
359                                            IGImage.class.getName(), getPrimaryKey());
360                    }
361    
362                    return _expandoBridge;
363            }
364    
365            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
366                    getExpandoBridge().setAttributes(serviceContext);
367            }
368    
369            public Object clone() {
370                    IGImageImpl igImageImpl = new IGImageImpl();
371    
372                    igImageImpl.setUuid(getUuid());
373    
374                    IGImageModelImpl igImageModelImpl = igImageImpl;
375    
376                    igImageModelImpl._originalUuid = igImageModelImpl._uuid;
377    
378                    igImageImpl.setImageId(getImageId());
379    
380                    igImageImpl.setGroupId(getGroupId());
381    
382                    igImageModelImpl._originalGroupId = igImageModelImpl._groupId;
383    
384                    igImageModelImpl._setOriginalGroupId = false;
385                    igImageImpl.setCompanyId(getCompanyId());
386    
387                    igImageImpl.setUserId(getUserId());
388    
389                    igImageImpl.setCreateDate(getCreateDate());
390    
391                    igImageImpl.setModifiedDate(getModifiedDate());
392    
393                    igImageImpl.setFolderId(getFolderId());
394    
395                    igImageImpl.setName(getName());
396    
397                    igImageImpl.setDescription(getDescription());
398    
399                    igImageImpl.setSmallImageId(getSmallImageId());
400    
401                    igImageModelImpl._originalSmallImageId = igImageModelImpl._smallImageId;
402    
403                    igImageModelImpl._setOriginalSmallImageId = false;
404                    igImageImpl.setLargeImageId(getLargeImageId());
405    
406                    igImageModelImpl._originalLargeImageId = igImageModelImpl._largeImageId;
407    
408                    igImageModelImpl._setOriginalLargeImageId = false;
409                    igImageImpl.setCustom1ImageId(getCustom1ImageId());
410    
411                    igImageModelImpl._originalCustom1ImageId = igImageModelImpl._custom1ImageId;
412    
413                    igImageModelImpl._setOriginalCustom1ImageId = false;
414                    igImageImpl.setCustom2ImageId(getCustom2ImageId());
415    
416                    igImageModelImpl._originalCustom2ImageId = igImageModelImpl._custom2ImageId;
417    
418                    igImageModelImpl._setOriginalCustom2ImageId = false;
419    
420                    return igImageImpl;
421            }
422    
423            public int compareTo(IGImage igImage) {
424                    int value = 0;
425    
426                    if (getImageId() < igImage.getImageId()) {
427                            value = -1;
428                    }
429                    else if (getImageId() > igImage.getImageId()) {
430                            value = 1;
431                    }
432                    else {
433                            value = 0;
434                    }
435    
436                    if (value != 0) {
437                            return value;
438                    }
439    
440                    return 0;
441            }
442    
443            public boolean equals(Object obj) {
444                    if (obj == null) {
445                            return false;
446                    }
447    
448                    IGImage igImage = null;
449    
450                    try {
451                            igImage = (IGImage)obj;
452                    }
453                    catch (ClassCastException cce) {
454                            return false;
455                    }
456    
457                    long pk = igImage.getPrimaryKey();
458    
459                    if (getPrimaryKey() == pk) {
460                            return true;
461                    }
462                    else {
463                            return false;
464                    }
465            }
466    
467            public int hashCode() {
468                    return (int)getPrimaryKey();
469            }
470    
471            public String toString() {
472                    StringBundler sb = new StringBundler(29);
473    
474                    sb.append("{uuid=");
475                    sb.append(getUuid());
476                    sb.append(", imageId=");
477                    sb.append(getImageId());
478                    sb.append(", groupId=");
479                    sb.append(getGroupId());
480                    sb.append(", companyId=");
481                    sb.append(getCompanyId());
482                    sb.append(", userId=");
483                    sb.append(getUserId());
484                    sb.append(", createDate=");
485                    sb.append(getCreateDate());
486                    sb.append(", modifiedDate=");
487                    sb.append(getModifiedDate());
488                    sb.append(", folderId=");
489                    sb.append(getFolderId());
490                    sb.append(", name=");
491                    sb.append(getName());
492                    sb.append(", description=");
493                    sb.append(getDescription());
494                    sb.append(", smallImageId=");
495                    sb.append(getSmallImageId());
496                    sb.append(", largeImageId=");
497                    sb.append(getLargeImageId());
498                    sb.append(", custom1ImageId=");
499                    sb.append(getCustom1ImageId());
500                    sb.append(", custom2ImageId=");
501                    sb.append(getCustom2ImageId());
502                    sb.append("}");
503    
504                    return sb.toString();
505            }
506    
507            public String toXmlString() {
508                    StringBundler sb = new StringBundler(46);
509    
510                    sb.append("<model><model-name>");
511                    sb.append("com.liferay.portlet.imagegallery.model.IGImage");
512                    sb.append("</model-name>");
513    
514                    sb.append(
515                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
516                    sb.append(getUuid());
517                    sb.append("]]></column-value></column>");
518                    sb.append(
519                            "<column><column-name>imageId</column-name><column-value><![CDATA[");
520                    sb.append(getImageId());
521                    sb.append("]]></column-value></column>");
522                    sb.append(
523                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
524                    sb.append(getGroupId());
525                    sb.append("]]></column-value></column>");
526                    sb.append(
527                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
528                    sb.append(getCompanyId());
529                    sb.append("]]></column-value></column>");
530                    sb.append(
531                            "<column><column-name>userId</column-name><column-value><![CDATA[");
532                    sb.append(getUserId());
533                    sb.append("]]></column-value></column>");
534                    sb.append(
535                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
536                    sb.append(getCreateDate());
537                    sb.append("]]></column-value></column>");
538                    sb.append(
539                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
540                    sb.append(getModifiedDate());
541                    sb.append("]]></column-value></column>");
542                    sb.append(
543                            "<column><column-name>folderId</column-name><column-value><![CDATA[");
544                    sb.append(getFolderId());
545                    sb.append("]]></column-value></column>");
546                    sb.append(
547                            "<column><column-name>name</column-name><column-value><![CDATA[");
548                    sb.append(getName());
549                    sb.append("]]></column-value></column>");
550                    sb.append(
551                            "<column><column-name>description</column-name><column-value><![CDATA[");
552                    sb.append(getDescription());
553                    sb.append("]]></column-value></column>");
554                    sb.append(
555                            "<column><column-name>smallImageId</column-name><column-value><![CDATA[");
556                    sb.append(getSmallImageId());
557                    sb.append("]]></column-value></column>");
558                    sb.append(
559                            "<column><column-name>largeImageId</column-name><column-value><![CDATA[");
560                    sb.append(getLargeImageId());
561                    sb.append("]]></column-value></column>");
562                    sb.append(
563                            "<column><column-name>custom1ImageId</column-name><column-value><![CDATA[");
564                    sb.append(getCustom1ImageId());
565                    sb.append("]]></column-value></column>");
566                    sb.append(
567                            "<column><column-name>custom2ImageId</column-name><column-value><![CDATA[");
568                    sb.append(getCustom2ImageId());
569                    sb.append("]]></column-value></column>");
570    
571                    sb.append("</model>");
572    
573                    return sb.toString();
574            }
575    
576            private String _uuid;
577            private String _originalUuid;
578            private long _imageId;
579            private long _groupId;
580            private long _originalGroupId;
581            private boolean _setOriginalGroupId;
582            private long _companyId;
583            private long _userId;
584            private String _userUuid;
585            private Date _createDate;
586            private Date _modifiedDate;
587            private long _folderId;
588            private String _name;
589            private String _description;
590            private long _smallImageId;
591            private long _originalSmallImageId;
592            private boolean _setOriginalSmallImageId;
593            private long _largeImageId;
594            private long _originalLargeImageId;
595            private boolean _setOriginalLargeImageId;
596            private long _custom1ImageId;
597            private long _originalCustom1ImageId;
598            private boolean _setOriginalCustom1ImageId;
599            private long _custom2ImageId;
600            private long _originalCustom2ImageId;
601            private boolean _setOriginalCustom2ImageId;
602            private transient ExpandoBridge _expandoBridge;
603    }