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.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 imageImpl = new ImageImpl();
226    
227                    imageImpl.setImageId(getImageId());
228    
229                    imageImpl.setModifiedDate(getModifiedDate());
230    
231                    imageImpl.setText(getText());
232    
233                    imageImpl.setType(getType());
234    
235                    imageImpl.setHeight(getHeight());
236    
237                    imageImpl.setWidth(getWidth());
238    
239                    imageImpl.setSize(getSize());
240    
241                    return imageImpl;
242            }
243    
244            public int compareTo(Image image) {
245                    int value = 0;
246    
247                    if (getImageId() < image.getImageId()) {
248                            value = -1;
249                    }
250                    else if (getImageId() > image.getImageId()) {
251                            value = 1;
252                    }
253                    else {
254                            value = 0;
255                    }
256    
257                    if (value != 0) {
258                            return value;
259                    }
260    
261                    return 0;
262            }
263    
264            public boolean equals(Object obj) {
265                    if (obj == null) {
266                            return false;
267                    }
268    
269                    Image image = null;
270    
271                    try {
272                            image = (Image)obj;
273                    }
274                    catch (ClassCastException cce) {
275                            return false;
276                    }
277    
278                    long pk = image.getPrimaryKey();
279    
280                    if (getPrimaryKey() == pk) {
281                            return true;
282                    }
283                    else {
284                            return false;
285                    }
286            }
287    
288            public int hashCode() {
289                    return (int)getPrimaryKey();
290            }
291    
292            public String toString() {
293                    StringBundler sb = new StringBundler(15);
294    
295                    sb.append("{imageId=");
296                    sb.append(getImageId());
297                    sb.append(", modifiedDate=");
298                    sb.append(getModifiedDate());
299                    sb.append(", text=");
300                    sb.append(getText());
301                    sb.append(", type=");
302                    sb.append(getType());
303                    sb.append(", height=");
304                    sb.append(getHeight());
305                    sb.append(", width=");
306                    sb.append(getWidth());
307                    sb.append(", size=");
308                    sb.append(getSize());
309                    sb.append("}");
310    
311                    return sb.toString();
312            }
313    
314            public String toXmlString() {
315                    StringBundler sb = new StringBundler(25);
316    
317                    sb.append("<model><model-name>");
318                    sb.append("com.liferay.portal.model.Image");
319                    sb.append("</model-name>");
320    
321                    sb.append(
322                            "<column><column-name>imageId</column-name><column-value><![CDATA[");
323                    sb.append(getImageId());
324                    sb.append("]]></column-value></column>");
325                    sb.append(
326                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
327                    sb.append(getModifiedDate());
328                    sb.append("]]></column-value></column>");
329                    sb.append(
330                            "<column><column-name>text</column-name><column-value><![CDATA[");
331                    sb.append(getText());
332                    sb.append("]]></column-value></column>");
333                    sb.append(
334                            "<column><column-name>type</column-name><column-value><![CDATA[");
335                    sb.append(getType());
336                    sb.append("]]></column-value></column>");
337                    sb.append(
338                            "<column><column-name>height</column-name><column-value><![CDATA[");
339                    sb.append(getHeight());
340                    sb.append("]]></column-value></column>");
341                    sb.append(
342                            "<column><column-name>width</column-name><column-value><![CDATA[");
343                    sb.append(getWidth());
344                    sb.append("]]></column-value></column>");
345                    sb.append(
346                            "<column><column-name>size</column-name><column-value><![CDATA[");
347                    sb.append(getSize());
348                    sb.append("]]></column-value></column>");
349    
350                    sb.append("</model>");
351    
352                    return sb.toString();
353            }
354    
355            private long _imageId;
356            private Date _modifiedDate;
357            private String _text;
358            private String _type;
359            private int _height;
360            private int _width;
361            private int _size;
362            private transient ExpandoBridge _expandoBridge;
363    }