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.portal.model.impl;
016    
017    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.util.GetterUtil;
019    import com.liferay.portal.kernel.util.StringBundler;
020    import com.liferay.portal.kernel.util.StringPool;
021    import com.liferay.portal.model.Image;
022    import com.liferay.portal.model.ImageModel;
023    import com.liferay.portal.model.ImageSoap;
024    import com.liferay.portal.service.ServiceContext;
025    
026    import com.liferay.portlet.expando.model.ExpandoBridge;
027    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
028    
029    import java.io.Serializable;
030    
031    import java.lang.reflect.Proxy;
032    
033    import java.sql.Types;
034    
035    import java.util.ArrayList;
036    import java.util.Date;
037    import java.util.List;
038    
039    /**
040     * 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.
041     *
042     * <p>
043     * 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}.
044     * </p>
045     *
046     * <p>
047     * 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.
048     * </p>
049     *
050     * @author Brian Wing Shun Chan
051     * @see ImageImpl
052     * @see com.liferay.portal.model.Image
053     * @see com.liferay.portal.model.ImageModel
054     * @generated
055     */
056    public class ImageModelImpl extends BaseModelImpl<Image> implements ImageModel {
057            public static final String TABLE_NAME = "Image";
058            public static final Object[][] TABLE_COLUMNS = {
059                            { "imageId", new Integer(Types.BIGINT) },
060                            { "modifiedDate", new Integer(Types.TIMESTAMP) },
061                            { "text_", new Integer(Types.CLOB) },
062                            { "type_", new Integer(Types.VARCHAR) },
063                            { "height", new Integer(Types.INTEGER) },
064                            { "width", new Integer(Types.INTEGER) },
065                            { "size_", new Integer(Types.INTEGER) }
066                    };
067            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)";
068            public static final String TABLE_SQL_DROP = "drop table Image";
069            public static final String ORDER_BY_JPQL = " ORDER BY image.imageId ASC";
070            public static final String ORDER_BY_SQL = " ORDER BY Image.imageId ASC";
071            public static final String DATA_SOURCE = "liferayDataSource";
072            public static final String SESSION_FACTORY = "liferaySessionFactory";
073            public static final String TX_MANAGER = "liferayTransactionManager";
074            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
075                                    "value.object.entity.cache.enabled.com.liferay.portal.model.Image"),
076                            true);
077            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
078                                    "value.object.finder.cache.enabled.com.liferay.portal.model.Image"),
079                            true);
080    
081            /**
082             * Converts the soap model instance into a normal model instance.
083             *
084             * @param soapModel the soap model instance to convert
085             * @return the normal model instance
086             */
087            public static Image toModel(ImageSoap soapModel) {
088                    Image model = new ImageImpl();
089    
090                    model.setImageId(soapModel.getImageId());
091                    model.setModifiedDate(soapModel.getModifiedDate());
092                    model.setText(soapModel.getText());
093                    model.setType(soapModel.getType());
094                    model.setHeight(soapModel.getHeight());
095                    model.setWidth(soapModel.getWidth());
096                    model.setSize(soapModel.getSize());
097    
098                    return model;
099            }
100    
101            /**
102             * Converts the soap model instances into normal model instances.
103             *
104             * @param soapModels the soap model instances to convert
105             * @return the normal model instances
106             */
107            public static List<Image> toModels(ImageSoap[] soapModels) {
108                    List<Image> models = new ArrayList<Image>(soapModels.length);
109    
110                    for (ImageSoap soapModel : soapModels) {
111                            models.add(toModel(soapModel));
112                    }
113    
114                    return models;
115            }
116    
117            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
118                                    "lock.expiration.time.com.liferay.portal.model.Image"));
119    
120            public ImageModelImpl() {
121            }
122    
123            public long getPrimaryKey() {
124                    return _imageId;
125            }
126    
127            public void setPrimaryKey(long pk) {
128                    setImageId(pk);
129            }
130    
131            public Serializable getPrimaryKeyObj() {
132                    return new Long(_imageId);
133            }
134    
135            public long getImageId() {
136                    return _imageId;
137            }
138    
139            public void setImageId(long imageId) {
140                    _imageId = imageId;
141            }
142    
143            public Date getModifiedDate() {
144                    return _modifiedDate;
145            }
146    
147            public void setModifiedDate(Date modifiedDate) {
148                    _modifiedDate = modifiedDate;
149            }
150    
151            public String getText() {
152                    if (_text == null) {
153                            return StringPool.BLANK;
154                    }
155                    else {
156                            return _text;
157                    }
158            }
159    
160            public void setText(String text) {
161                    _text = text;
162            }
163    
164            public String getType() {
165                    if (_type == null) {
166                            return StringPool.BLANK;
167                    }
168                    else {
169                            return _type;
170                    }
171            }
172    
173            public void setType(String type) {
174                    _type = type;
175            }
176    
177            public int getHeight() {
178                    return _height;
179            }
180    
181            public void setHeight(int height) {
182                    _height = height;
183            }
184    
185            public int getWidth() {
186                    return _width;
187            }
188    
189            public void setWidth(int width) {
190                    _width = width;
191            }
192    
193            public int getSize() {
194                    return _size;
195            }
196    
197            public void setSize(int size) {
198                    _size = size;
199            }
200    
201            public Image toEscapedModel() {
202                    if (isEscapedModel()) {
203                            return (Image)this;
204                    }
205                    else {
206                            return (Image)Proxy.newProxyInstance(Image.class.getClassLoader(),
207                                    new Class[] { Image.class }, new AutoEscapeBeanHandler(this));
208                    }
209            }
210    
211            public ExpandoBridge getExpandoBridge() {
212                    if (_expandoBridge == null) {
213                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
214                                            Image.class.getName(), getPrimaryKey());
215                    }
216    
217                    return _expandoBridge;
218            }
219    
220            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
221                    getExpandoBridge().setAttributes(serviceContext);
222            }
223    
224            public Object clone() {
225                    ImageImpl clone = new ImageImpl();
226    
227                    clone.setImageId(getImageId());
228                    clone.setModifiedDate(getModifiedDate());
229                    clone.setText(getText());
230                    clone.setType(getType());
231                    clone.setHeight(getHeight());
232                    clone.setWidth(getWidth());
233                    clone.setSize(getSize());
234    
235                    return clone;
236            }
237    
238            public int compareTo(Image image) {
239                    int value = 0;
240    
241                    if (getImageId() < image.getImageId()) {
242                            value = -1;
243                    }
244                    else if (getImageId() > image.getImageId()) {
245                            value = 1;
246                    }
247                    else {
248                            value = 0;
249                    }
250    
251                    if (value != 0) {
252                            return value;
253                    }
254    
255                    return 0;
256            }
257    
258            public boolean equals(Object obj) {
259                    if (obj == null) {
260                            return false;
261                    }
262    
263                    Image image = null;
264    
265                    try {
266                            image = (Image)obj;
267                    }
268                    catch (ClassCastException cce) {
269                            return false;
270                    }
271    
272                    long pk = image.getPrimaryKey();
273    
274                    if (getPrimaryKey() == pk) {
275                            return true;
276                    }
277                    else {
278                            return false;
279                    }
280            }
281    
282            public int hashCode() {
283                    return (int)getPrimaryKey();
284            }
285    
286            public String toString() {
287                    StringBundler sb = new StringBundler(15);
288    
289                    sb.append("{imageId=");
290                    sb.append(getImageId());
291                    sb.append(", modifiedDate=");
292                    sb.append(getModifiedDate());
293                    sb.append(", text=");
294                    sb.append(getText());
295                    sb.append(", type=");
296                    sb.append(getType());
297                    sb.append(", height=");
298                    sb.append(getHeight());
299                    sb.append(", width=");
300                    sb.append(getWidth());
301                    sb.append(", size=");
302                    sb.append(getSize());
303                    sb.append("}");
304    
305                    return sb.toString();
306            }
307    
308            public String toXmlString() {
309                    StringBundler sb = new StringBundler(25);
310    
311                    sb.append("<model><model-name>");
312                    sb.append("com.liferay.portal.model.Image");
313                    sb.append("</model-name>");
314    
315                    sb.append(
316                            "<column><column-name>imageId</column-name><column-value><![CDATA[");
317                    sb.append(getImageId());
318                    sb.append("]]></column-value></column>");
319                    sb.append(
320                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
321                    sb.append(getModifiedDate());
322                    sb.append("]]></column-value></column>");
323                    sb.append(
324                            "<column><column-name>text</column-name><column-value><![CDATA[");
325                    sb.append(getText());
326                    sb.append("]]></column-value></column>");
327                    sb.append(
328                            "<column><column-name>type</column-name><column-value><![CDATA[");
329                    sb.append(getType());
330                    sb.append("]]></column-value></column>");
331                    sb.append(
332                            "<column><column-name>height</column-name><column-value><![CDATA[");
333                    sb.append(getHeight());
334                    sb.append("]]></column-value></column>");
335                    sb.append(
336                            "<column><column-name>width</column-name><column-value><![CDATA[");
337                    sb.append(getWidth());
338                    sb.append("]]></column-value></column>");
339                    sb.append(
340                            "<column><column-name>size</column-name><column-value><![CDATA[");
341                    sb.append(getSize());
342                    sb.append("]]></column-value></column>");
343    
344                    sb.append("</model>");
345    
346                    return sb.toString();
347            }
348    
349            private long _imageId;
350            private Date _modifiedDate;
351            private String _text;
352            private String _type;
353            private int _height;
354            private int _width;
355            private int _size;
356            private transient ExpandoBridge _expandoBridge;
357    }