001    /**
002     * Copyright (c) 2000-2010 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                    _uuid = uuid;
164    
165                    if (_originalUuid == null) {
166                            _originalUuid = uuid;
167                    }
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                    _groupId = groupId;
188    
189                    if (!_setOriginalGroupId) {
190                            _setOriginalGroupId = true;
191    
192                            _originalGroupId = groupId;
193                    }
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                    _smallImageId = smallImageId;
280    
281                    if (!_setOriginalSmallImageId) {
282                            _setOriginalSmallImageId = true;
283    
284                            _originalSmallImageId = smallImageId;
285                    }
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                    _largeImageId = largeImageId;
298    
299                    if (!_setOriginalLargeImageId) {
300                            _setOriginalLargeImageId = true;
301    
302                            _originalLargeImageId = largeImageId;
303                    }
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                    _custom1ImageId = custom1ImageId;
316    
317                    if (!_setOriginalCustom1ImageId) {
318                            _setOriginalCustom1ImageId = true;
319    
320                            _originalCustom1ImageId = custom1ImageId;
321                    }
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                    _custom2ImageId = custom2ImageId;
334    
335                    if (!_setOriginalCustom2ImageId) {
336                            _setOriginalCustom2ImageId = true;
337    
338                            _originalCustom2ImageId = custom2ImageId;
339                    }
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 clone = new IGImageImpl();
371    
372                    clone.setUuid(getUuid());
373                    clone.setImageId(getImageId());
374                    clone.setGroupId(getGroupId());
375                    clone.setCompanyId(getCompanyId());
376                    clone.setUserId(getUserId());
377                    clone.setCreateDate(getCreateDate());
378                    clone.setModifiedDate(getModifiedDate());
379                    clone.setFolderId(getFolderId());
380                    clone.setName(getName());
381                    clone.setDescription(getDescription());
382                    clone.setSmallImageId(getSmallImageId());
383                    clone.setLargeImageId(getLargeImageId());
384                    clone.setCustom1ImageId(getCustom1ImageId());
385                    clone.setCustom2ImageId(getCustom2ImageId());
386    
387                    return clone;
388            }
389    
390            public int compareTo(IGImage igImage) {
391                    int value = 0;
392    
393                    if (getImageId() < igImage.getImageId()) {
394                            value = -1;
395                    }
396                    else if (getImageId() > igImage.getImageId()) {
397                            value = 1;
398                    }
399                    else {
400                            value = 0;
401                    }
402    
403                    if (value != 0) {
404                            return value;
405                    }
406    
407                    return 0;
408            }
409    
410            public boolean equals(Object obj) {
411                    if (obj == null) {
412                            return false;
413                    }
414    
415                    IGImage igImage = null;
416    
417                    try {
418                            igImage = (IGImage)obj;
419                    }
420                    catch (ClassCastException cce) {
421                            return false;
422                    }
423    
424                    long pk = igImage.getPrimaryKey();
425    
426                    if (getPrimaryKey() == pk) {
427                            return true;
428                    }
429                    else {
430                            return false;
431                    }
432            }
433    
434            public int hashCode() {
435                    return (int)getPrimaryKey();
436            }
437    
438            public String toString() {
439                    StringBundler sb = new StringBundler(29);
440    
441                    sb.append("{uuid=");
442                    sb.append(getUuid());
443                    sb.append(", imageId=");
444                    sb.append(getImageId());
445                    sb.append(", groupId=");
446                    sb.append(getGroupId());
447                    sb.append(", companyId=");
448                    sb.append(getCompanyId());
449                    sb.append(", userId=");
450                    sb.append(getUserId());
451                    sb.append(", createDate=");
452                    sb.append(getCreateDate());
453                    sb.append(", modifiedDate=");
454                    sb.append(getModifiedDate());
455                    sb.append(", folderId=");
456                    sb.append(getFolderId());
457                    sb.append(", name=");
458                    sb.append(getName());
459                    sb.append(", description=");
460                    sb.append(getDescription());
461                    sb.append(", smallImageId=");
462                    sb.append(getSmallImageId());
463                    sb.append(", largeImageId=");
464                    sb.append(getLargeImageId());
465                    sb.append(", custom1ImageId=");
466                    sb.append(getCustom1ImageId());
467                    sb.append(", custom2ImageId=");
468                    sb.append(getCustom2ImageId());
469                    sb.append("}");
470    
471                    return sb.toString();
472            }
473    
474            public String toXmlString() {
475                    StringBundler sb = new StringBundler(46);
476    
477                    sb.append("<model><model-name>");
478                    sb.append("com.liferay.portlet.imagegallery.model.IGImage");
479                    sb.append("</model-name>");
480    
481                    sb.append(
482                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
483                    sb.append(getUuid());
484                    sb.append("]]></column-value></column>");
485                    sb.append(
486                            "<column><column-name>imageId</column-name><column-value><![CDATA[");
487                    sb.append(getImageId());
488                    sb.append("]]></column-value></column>");
489                    sb.append(
490                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
491                    sb.append(getGroupId());
492                    sb.append("]]></column-value></column>");
493                    sb.append(
494                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
495                    sb.append(getCompanyId());
496                    sb.append("]]></column-value></column>");
497                    sb.append(
498                            "<column><column-name>userId</column-name><column-value><![CDATA[");
499                    sb.append(getUserId());
500                    sb.append("]]></column-value></column>");
501                    sb.append(
502                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
503                    sb.append(getCreateDate());
504                    sb.append("]]></column-value></column>");
505                    sb.append(
506                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
507                    sb.append(getModifiedDate());
508                    sb.append("]]></column-value></column>");
509                    sb.append(
510                            "<column><column-name>folderId</column-name><column-value><![CDATA[");
511                    sb.append(getFolderId());
512                    sb.append("]]></column-value></column>");
513                    sb.append(
514                            "<column><column-name>name</column-name><column-value><![CDATA[");
515                    sb.append(getName());
516                    sb.append("]]></column-value></column>");
517                    sb.append(
518                            "<column><column-name>description</column-name><column-value><![CDATA[");
519                    sb.append(getDescription());
520                    sb.append("]]></column-value></column>");
521                    sb.append(
522                            "<column><column-name>smallImageId</column-name><column-value><![CDATA[");
523                    sb.append(getSmallImageId());
524                    sb.append("]]></column-value></column>");
525                    sb.append(
526                            "<column><column-name>largeImageId</column-name><column-value><![CDATA[");
527                    sb.append(getLargeImageId());
528                    sb.append("]]></column-value></column>");
529                    sb.append(
530                            "<column><column-name>custom1ImageId</column-name><column-value><![CDATA[");
531                    sb.append(getCustom1ImageId());
532                    sb.append("]]></column-value></column>");
533                    sb.append(
534                            "<column><column-name>custom2ImageId</column-name><column-value><![CDATA[");
535                    sb.append(getCustom2ImageId());
536                    sb.append("]]></column-value></column>");
537    
538                    sb.append("</model>");
539    
540                    return sb.toString();
541            }
542    
543            private String _uuid;
544            private String _originalUuid;
545            private long _imageId;
546            private long _groupId;
547            private long _originalGroupId;
548            private boolean _setOriginalGroupId;
549            private long _companyId;
550            private long _userId;
551            private String _userUuid;
552            private Date _createDate;
553            private Date _modifiedDate;
554            private long _folderId;
555            private String _name;
556            private String _description;
557            private long _smallImageId;
558            private long _originalSmallImageId;
559            private boolean _setOriginalSmallImageId;
560            private long _largeImageId;
561            private long _originalLargeImageId;
562            private boolean _setOriginalLargeImageId;
563            private long _custom1ImageId;
564            private long _originalCustom1ImageId;
565            private boolean _setOriginalCustom1ImageId;
566            private long _custom2ImageId;
567            private long _originalCustom2ImageId;
568            private boolean _setOriginalCustom2ImageId;
569            private transient ExpandoBridge _expandoBridge;
570    }