1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.model.impl;
16  
17  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
18  import com.liferay.portal.kernel.util.GetterUtil;
19  import com.liferay.portal.kernel.util.HtmlUtil;
20  import com.liferay.portal.kernel.util.StringBundler;
21  import com.liferay.portal.model.Image;
22  import com.liferay.portal.model.ImageSoap;
23  import com.liferay.portal.service.ServiceContext;
24  
25  import com.liferay.portlet.expando.model.ExpandoBridge;
26  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
27  
28  import java.io.Serializable;
29  
30  import java.lang.reflect.Proxy;
31  
32  import java.sql.Types;
33  
34  import java.util.ArrayList;
35  import java.util.Date;
36  import java.util.List;
37  
38  /**
39   * <a href="ImageModelImpl.java.html"><b><i>View Source</i></b></a>
40   *
41   * <p>
42   * ServiceBuilder generated this class. Modifications in this class will be
43   * overwritten the next time is generated.
44   * </p>
45   *
46   * <p>
47   * This interface is a model that represents the Image table in the
48   * database.
49   * </p>
50   *
51   * @author    Brian Wing Shun Chan
52   * @see       ImageImpl
53   * @see       com.liferay.portal.model.Image
54   * @see       com.liferay.portal.model.ImageModel
55   * @generated
56   */
57  public class ImageModelImpl extends BaseModelImpl<Image> {
58      public static final String TABLE_NAME = "Image";
59      public static final Object[][] TABLE_COLUMNS = {
60              { "imageId", new Integer(Types.BIGINT) },
61              { "modifiedDate", new Integer(Types.TIMESTAMP) },
62              { "text_", new Integer(Types.CLOB) },
63              { "type_", new Integer(Types.VARCHAR) },
64              { "height", new Integer(Types.INTEGER) },
65              { "width", new Integer(Types.INTEGER) },
66              { "size_", new Integer(Types.INTEGER) }
67          };
68      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)";
69      public static final String TABLE_SQL_DROP = "drop table Image";
70      public static final String ORDER_BY_JPQL = " ORDER BY image.imageId ASC";
71      public static final String ORDER_BY_SQL = " ORDER BY Image.imageId ASC";
72      public static final String DATA_SOURCE = "liferayDataSource";
73      public static final String SESSION_FACTORY = "liferaySessionFactory";
74      public static final String TX_MANAGER = "liferayTransactionManager";
75      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
76                  "value.object.entity.cache.enabled.com.liferay.portal.model.Image"),
77              true);
78      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
79                  "value.object.finder.cache.enabled.com.liferay.portal.model.Image"),
80              true);
81  
82      public static Image toModel(ImageSoap soapModel) {
83          Image model = new ImageImpl();
84  
85          model.setImageId(soapModel.getImageId());
86          model.setModifiedDate(soapModel.getModifiedDate());
87          model.setText(soapModel.getText());
88          model.setType(soapModel.getType());
89          model.setHeight(soapModel.getHeight());
90          model.setWidth(soapModel.getWidth());
91          model.setSize(soapModel.getSize());
92  
93          return model;
94      }
95  
96      public static List<Image> toModels(ImageSoap[] soapModels) {
97          List<Image> models = new ArrayList<Image>(soapModels.length);
98  
99          for (ImageSoap soapModel : soapModels) {
100             models.add(toModel(soapModel));
101         }
102 
103         return models;
104     }
105 
106     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
107                 "lock.expiration.time.com.liferay.portal.model.Image"));
108 
109     public ImageModelImpl() {
110     }
111 
112     public long getPrimaryKey() {
113         return _imageId;
114     }
115 
116     public void setPrimaryKey(long pk) {
117         setImageId(pk);
118     }
119 
120     public Serializable getPrimaryKeyObj() {
121         return new Long(_imageId);
122     }
123 
124     public long getImageId() {
125         return _imageId;
126     }
127 
128     public void setImageId(long imageId) {
129         _imageId = imageId;
130     }
131 
132     public Date getModifiedDate() {
133         return _modifiedDate;
134     }
135 
136     public void setModifiedDate(Date modifiedDate) {
137         _modifiedDate = modifiedDate;
138     }
139 
140     public String getText() {
141         return GetterUtil.getString(_text);
142     }
143 
144     public void setText(String text) {
145         _text = text;
146     }
147 
148     public String getType() {
149         return GetterUtil.getString(_type);
150     }
151 
152     public void setType(String type) {
153         _type = type;
154     }
155 
156     public int getHeight() {
157         return _height;
158     }
159 
160     public void setHeight(int height) {
161         _height = height;
162     }
163 
164     public int getWidth() {
165         return _width;
166     }
167 
168     public void setWidth(int width) {
169         _width = width;
170     }
171 
172     public int getSize() {
173         return _size;
174     }
175 
176     public void setSize(int size) {
177         _size = size;
178     }
179 
180     public Image toEscapedModel() {
181         if (isEscapedModel()) {
182             return (Image)this;
183         }
184         else {
185             Image model = new ImageImpl();
186 
187             model.setNew(isNew());
188             model.setEscapedModel(true);
189 
190             model.setImageId(getImageId());
191             model.setModifiedDate(getModifiedDate());
192             model.setText(HtmlUtil.escape(getText()));
193             model.setType(HtmlUtil.escape(getType()));
194             model.setHeight(getHeight());
195             model.setWidth(getWidth());
196             model.setSize(getSize());
197 
198             model = (Image)Proxy.newProxyInstance(Image.class.getClassLoader(),
199                     new Class[] { Image.class }, new ReadOnlyBeanHandler(model));
200 
201             return model;
202         }
203     }
204 
205     public ExpandoBridge getExpandoBridge() {
206         if (_expandoBridge == null) {
207             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
208                     Image.class.getName(), getPrimaryKey());
209         }
210 
211         return _expandoBridge;
212     }
213 
214     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
215         getExpandoBridge().setAttributes(serviceContext);
216     }
217 
218     public Object clone() {
219         ImageImpl clone = new ImageImpl();
220 
221         clone.setImageId(getImageId());
222         clone.setModifiedDate(getModifiedDate());
223         clone.setText(getText());
224         clone.setType(getType());
225         clone.setHeight(getHeight());
226         clone.setWidth(getWidth());
227         clone.setSize(getSize());
228 
229         return clone;
230     }
231 
232     public int compareTo(Image image) {
233         int value = 0;
234 
235         if (getImageId() < image.getImageId()) {
236             value = -1;
237         }
238         else if (getImageId() > image.getImageId()) {
239             value = 1;
240         }
241         else {
242             value = 0;
243         }
244 
245         if (value != 0) {
246             return value;
247         }
248 
249         return 0;
250     }
251 
252     public boolean equals(Object obj) {
253         if (obj == null) {
254             return false;
255         }
256 
257         Image image = null;
258 
259         try {
260             image = (Image)obj;
261         }
262         catch (ClassCastException cce) {
263             return false;
264         }
265 
266         long pk = image.getPrimaryKey();
267 
268         if (getPrimaryKey() == pk) {
269             return true;
270         }
271         else {
272             return false;
273         }
274     }
275 
276     public int hashCode() {
277         return (int)getPrimaryKey();
278     }
279 
280     public String toString() {
281         StringBundler sb = new StringBundler(15);
282 
283         sb.append("{imageId=");
284         sb.append(getImageId());
285         sb.append(", modifiedDate=");
286         sb.append(getModifiedDate());
287         sb.append(", text=");
288         sb.append(getText());
289         sb.append(", type=");
290         sb.append(getType());
291         sb.append(", height=");
292         sb.append(getHeight());
293         sb.append(", width=");
294         sb.append(getWidth());
295         sb.append(", size=");
296         sb.append(getSize());
297         sb.append("}");
298 
299         return sb.toString();
300     }
301 
302     public String toXmlString() {
303         StringBundler sb = new StringBundler(25);
304 
305         sb.append("<model><model-name>");
306         sb.append("com.liferay.portal.model.Image");
307         sb.append("</model-name>");
308 
309         sb.append(
310             "<column><column-name>imageId</column-name><column-value><![CDATA[");
311         sb.append(getImageId());
312         sb.append("]]></column-value></column>");
313         sb.append(
314             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
315         sb.append(getModifiedDate());
316         sb.append("]]></column-value></column>");
317         sb.append(
318             "<column><column-name>text</column-name><column-value><![CDATA[");
319         sb.append(getText());
320         sb.append("]]></column-value></column>");
321         sb.append(
322             "<column><column-name>type</column-name><column-value><![CDATA[");
323         sb.append(getType());
324         sb.append("]]></column-value></column>");
325         sb.append(
326             "<column><column-name>height</column-name><column-value><![CDATA[");
327         sb.append(getHeight());
328         sb.append("]]></column-value></column>");
329         sb.append(
330             "<column><column-name>width</column-name><column-value><![CDATA[");
331         sb.append(getWidth());
332         sb.append("]]></column-value></column>");
333         sb.append(
334             "<column><column-name>size</column-name><column-value><![CDATA[");
335         sb.append(getSize());
336         sb.append("]]></column-value></column>");
337 
338         sb.append("</model>");
339 
340         return sb.toString();
341     }
342 
343     private long _imageId;
344     private Date _modifiedDate;
345     private String _text;
346     private String _type;
347     private int _height;
348     private int _width;
349     private int _size;
350     private transient ExpandoBridge _expandoBridge;
351 }