001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.model.impl;
016    
017    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.json.JSON;
019    import com.liferay.portal.kernel.util.GetterUtil;
020    import com.liferay.portal.kernel.util.ProxyUtil;
021    import com.liferay.portal.kernel.util.StringBundler;
022    import com.liferay.portal.kernel.util.StringPool;
023    import com.liferay.portal.model.CacheModel;
024    import com.liferay.portal.model.Image;
025    import com.liferay.portal.model.ImageModel;
026    import com.liferay.portal.model.ImageSoap;
027    import com.liferay.portal.service.ServiceContext;
028    
029    import com.liferay.portlet.expando.model.ExpandoBridge;
030    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
031    
032    import java.io.Serializable;
033    
034    import java.sql.Types;
035    
036    import java.util.ArrayList;
037    import java.util.Date;
038    import java.util.List;
039    
040    /**
041     * The base model implementation for the Image service. Represents a row in the "Image" database table, with each column mapped to a property of this class.
042     *
043     * <p>
044     * This implementation and its corresponding interface {@link com.liferay.portal.model.ImageModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link ImageImpl}.
045     * </p>
046     *
047     * @author Brian Wing Shun Chan
048     * @see ImageImpl
049     * @see com.liferay.portal.model.Image
050     * @see com.liferay.portal.model.ImageModel
051     * @generated
052     */
053    @JSON(strict = true)
054    public class ImageModelImpl extends BaseModelImpl<Image> implements ImageModel {
055            /*
056             * NOTE FOR DEVELOPERS:
057             *
058             * Never modify or reference this class directly. All methods that expect a image model instance should use the {@link com.liferay.portal.model.Image} interface instead.
059             */
060            public static final String TABLE_NAME = "Image";
061            public static final Object[][] TABLE_COLUMNS = {
062                            { "imageId", Types.BIGINT },
063                            { "modifiedDate", Types.TIMESTAMP },
064                            { "text_", Types.CLOB },
065                            { "type_", Types.VARCHAR },
066                            { "height", Types.INTEGER },
067                            { "width", Types.INTEGER },
068                            { "size_", Types.INTEGER }
069                    };
070            public static final String TABLE_SQL_CREATE = "create table Image (imageId LONG not null primary key,modifiedDate DATE null,text_ TEXT null,type_ VARCHAR(75) null,height INTEGER,width INTEGER,size_ INTEGER)";
071            public static final String TABLE_SQL_DROP = "drop table Image";
072            public static final String ORDER_BY_JPQL = " ORDER BY image.imageId ASC";
073            public static final String ORDER_BY_SQL = " ORDER BY Image.imageId ASC";
074            public static final String DATA_SOURCE = "liferayDataSource";
075            public static final String SESSION_FACTORY = "liferaySessionFactory";
076            public static final String TX_MANAGER = "liferayTransactionManager";
077            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
078                                    "value.object.entity.cache.enabled.com.liferay.portal.model.Image"),
079                            true);
080            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
081                                    "value.object.finder.cache.enabled.com.liferay.portal.model.Image"),
082                            true);
083            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
084                                    "value.object.column.bitmask.enabled.com.liferay.portal.model.Image"),
085                            true);
086            public static long SIZE_COLUMN_BITMASK = 1L;
087    
088            /**
089             * Converts the soap model instance into a normal model instance.
090             *
091             * @param soapModel the soap model instance to convert
092             * @return the normal model instance
093             */
094            public static Image toModel(ImageSoap soapModel) {
095                    Image model = new ImageImpl();
096    
097                    model.setImageId(soapModel.getImageId());
098                    model.setModifiedDate(soapModel.getModifiedDate());
099                    model.setText(soapModel.getText());
100                    model.setType(soapModel.getType());
101                    model.setHeight(soapModel.getHeight());
102                    model.setWidth(soapModel.getWidth());
103                    model.setSize(soapModel.getSize());
104    
105                    return model;
106            }
107    
108            /**
109             * Converts the soap model instances into normal model instances.
110             *
111             * @param soapModels the soap model instances to convert
112             * @return the normal model instances
113             */
114            public static List<Image> toModels(ImageSoap[] soapModels) {
115                    List<Image> models = new ArrayList<Image>(soapModels.length);
116    
117                    for (ImageSoap soapModel : soapModels) {
118                            models.add(toModel(soapModel));
119                    }
120    
121                    return models;
122            }
123    
124            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
125                                    "lock.expiration.time.com.liferay.portal.model.Image"));
126    
127            public ImageModelImpl() {
128            }
129    
130            public long getPrimaryKey() {
131                    return _imageId;
132            }
133    
134            public void setPrimaryKey(long primaryKey) {
135                    setImageId(primaryKey);
136            }
137    
138            public Serializable getPrimaryKeyObj() {
139                    return new Long(_imageId);
140            }
141    
142            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
143                    setPrimaryKey(((Long)primaryKeyObj).longValue());
144            }
145    
146            public Class<?> getModelClass() {
147                    return Image.class;
148            }
149    
150            public String getModelClassName() {
151                    return Image.class.getName();
152            }
153    
154            @JSON
155            public long getImageId() {
156                    return _imageId;
157            }
158    
159            public void setImageId(long imageId) {
160                    _imageId = imageId;
161            }
162    
163            @JSON
164            public Date getModifiedDate() {
165                    return _modifiedDate;
166            }
167    
168            public void setModifiedDate(Date modifiedDate) {
169                    _modifiedDate = modifiedDate;
170            }
171    
172            @JSON
173            public String getText() {
174                    if (_text == null) {
175                            return StringPool.BLANK;
176                    }
177                    else {
178                            return _text;
179                    }
180            }
181    
182            public void setText(String text) {
183                    _text = text;
184            }
185    
186            @JSON
187            public String getType() {
188                    if (_type == null) {
189                            return StringPool.BLANK;
190                    }
191                    else {
192                            return _type;
193                    }
194            }
195    
196            public void setType(String type) {
197                    _type = type;
198            }
199    
200            @JSON
201            public int getHeight() {
202                    return _height;
203            }
204    
205            public void setHeight(int height) {
206                    _height = height;
207            }
208    
209            @JSON
210            public int getWidth() {
211                    return _width;
212            }
213    
214            public void setWidth(int width) {
215                    _width = width;
216            }
217    
218            @JSON
219            public int getSize() {
220                    return _size;
221            }
222    
223            public void setSize(int size) {
224                    _columnBitmask |= SIZE_COLUMN_BITMASK;
225    
226                    if (!_setOriginalSize) {
227                            _setOriginalSize = true;
228    
229                            _originalSize = _size;
230                    }
231    
232                    _size = size;
233            }
234    
235            public int getOriginalSize() {
236                    return _originalSize;
237            }
238    
239            public long getColumnBitmask() {
240                    return _columnBitmask;
241            }
242    
243            @Override
244            public Image toEscapedModel() {
245                    if (_escapedModelProxy == null) {
246                            _escapedModelProxy = (Image)ProxyUtil.newProxyInstance(_classLoader,
247                                            _escapedModelProxyInterfaces,
248                                            new AutoEscapeBeanHandler(this));
249                    }
250    
251                    return _escapedModelProxy;
252            }
253    
254            @Override
255            public ExpandoBridge getExpandoBridge() {
256                    if (_expandoBridge == null) {
257                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
258                                            Image.class.getName(), getPrimaryKey());
259                    }
260    
261                    return _expandoBridge;
262            }
263    
264            @Override
265            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
266                    getExpandoBridge().setAttributes(serviceContext);
267            }
268    
269            @Override
270            public Object clone() {
271                    ImageImpl imageImpl = new ImageImpl();
272    
273                    imageImpl.setImageId(getImageId());
274                    imageImpl.setModifiedDate(getModifiedDate());
275                    imageImpl.setText(getText());
276                    imageImpl.setType(getType());
277                    imageImpl.setHeight(getHeight());
278                    imageImpl.setWidth(getWidth());
279                    imageImpl.setSize(getSize());
280    
281                    imageImpl.resetOriginalValues();
282    
283                    return imageImpl;
284            }
285    
286            public int compareTo(Image image) {
287                    int value = 0;
288    
289                    if (getImageId() < image.getImageId()) {
290                            value = -1;
291                    }
292                    else if (getImageId() > image.getImageId()) {
293                            value = 1;
294                    }
295                    else {
296                            value = 0;
297                    }
298    
299                    if (value != 0) {
300                            return value;
301                    }
302    
303                    return 0;
304            }
305    
306            @Override
307            public boolean equals(Object obj) {
308                    if (obj == null) {
309                            return false;
310                    }
311    
312                    Image image = null;
313    
314                    try {
315                            image = (Image)obj;
316                    }
317                    catch (ClassCastException cce) {
318                            return false;
319                    }
320    
321                    long primaryKey = image.getPrimaryKey();
322    
323                    if (getPrimaryKey() == primaryKey) {
324                            return true;
325                    }
326                    else {
327                            return false;
328                    }
329            }
330    
331            @Override
332            public int hashCode() {
333                    return (int)getPrimaryKey();
334            }
335    
336            @Override
337            public void resetOriginalValues() {
338                    ImageModelImpl imageModelImpl = this;
339    
340                    imageModelImpl._originalSize = imageModelImpl._size;
341    
342                    imageModelImpl._setOriginalSize = false;
343    
344                    imageModelImpl._columnBitmask = 0;
345            }
346    
347            @Override
348            public CacheModel<Image> toCacheModel() {
349                    ImageCacheModel imageCacheModel = new ImageCacheModel();
350    
351                    imageCacheModel.imageId = getImageId();
352    
353                    Date modifiedDate = getModifiedDate();
354    
355                    if (modifiedDate != null) {
356                            imageCacheModel.modifiedDate = modifiedDate.getTime();
357                    }
358                    else {
359                            imageCacheModel.modifiedDate = Long.MIN_VALUE;
360                    }
361    
362                    imageCacheModel.text = getText();
363    
364                    String text = imageCacheModel.text;
365    
366                    if ((text != null) && (text.length() == 0)) {
367                            imageCacheModel.text = null;
368                    }
369    
370                    imageCacheModel.type = getType();
371    
372                    String type = imageCacheModel.type;
373    
374                    if ((type != null) && (type.length() == 0)) {
375                            imageCacheModel.type = null;
376                    }
377    
378                    imageCacheModel.height = getHeight();
379    
380                    imageCacheModel.width = getWidth();
381    
382                    imageCacheModel.size = getSize();
383    
384                    return imageCacheModel;
385            }
386    
387            @Override
388            public String toString() {
389                    StringBundler sb = new StringBundler(15);
390    
391                    sb.append("{imageId=");
392                    sb.append(getImageId());
393                    sb.append(", modifiedDate=");
394                    sb.append(getModifiedDate());
395                    sb.append(", text=");
396                    sb.append(getText());
397                    sb.append(", type=");
398                    sb.append(getType());
399                    sb.append(", height=");
400                    sb.append(getHeight());
401                    sb.append(", width=");
402                    sb.append(getWidth());
403                    sb.append(", size=");
404                    sb.append(getSize());
405                    sb.append("}");
406    
407                    return sb.toString();
408            }
409    
410            public String toXmlString() {
411                    StringBundler sb = new StringBundler(25);
412    
413                    sb.append("<model><model-name>");
414                    sb.append("com.liferay.portal.model.Image");
415                    sb.append("</model-name>");
416    
417                    sb.append(
418                            "<column><column-name>imageId</column-name><column-value><![CDATA[");
419                    sb.append(getImageId());
420                    sb.append("]]></column-value></column>");
421                    sb.append(
422                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
423                    sb.append(getModifiedDate());
424                    sb.append("]]></column-value></column>");
425                    sb.append(
426                            "<column><column-name>text</column-name><column-value><![CDATA[");
427                    sb.append(getText());
428                    sb.append("]]></column-value></column>");
429                    sb.append(
430                            "<column><column-name>type</column-name><column-value><![CDATA[");
431                    sb.append(getType());
432                    sb.append("]]></column-value></column>");
433                    sb.append(
434                            "<column><column-name>height</column-name><column-value><![CDATA[");
435                    sb.append(getHeight());
436                    sb.append("]]></column-value></column>");
437                    sb.append(
438                            "<column><column-name>width</column-name><column-value><![CDATA[");
439                    sb.append(getWidth());
440                    sb.append("]]></column-value></column>");
441                    sb.append(
442                            "<column><column-name>size</column-name><column-value><![CDATA[");
443                    sb.append(getSize());
444                    sb.append("]]></column-value></column>");
445    
446                    sb.append("</model>");
447    
448                    return sb.toString();
449            }
450    
451            private static ClassLoader _classLoader = Image.class.getClassLoader();
452            private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
453                            Image.class
454                    };
455            private long _imageId;
456            private Date _modifiedDate;
457            private String _text;
458            private String _type;
459            private int _height;
460            private int _width;
461            private int _size;
462            private int _originalSize;
463            private boolean _setOriginalSize;
464            private transient ExpandoBridge _expandoBridge;
465            private long _columnBitmask;
466            private Image _escapedModelProxy;
467    }