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