1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.model.impl;
16  
17  import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
18  import com.liferay.portal.kernel.util.GetterUtil;
19  import com.liferay.portal.kernel.util.StringBundler;
20  import com.liferay.portal.kernel.util.StringPool;
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         if (_text == null) {
142             return StringPool.BLANK;
143         }
144         else {
145             return _text;
146         }
147     }
148 
149     public void setText(String text) {
150         _text = text;
151     }
152 
153     public String getType() {
154         if (_type == null) {
155             return StringPool.BLANK;
156         }
157         else {
158             return _type;
159         }
160     }
161 
162     public void setType(String type) {
163         _type = type;
164     }
165 
166     public int getHeight() {
167         return _height;
168     }
169 
170     public void setHeight(int height) {
171         _height = height;
172     }
173 
174     public int getWidth() {
175         return _width;
176     }
177 
178     public void setWidth(int width) {
179         _width = width;
180     }
181 
182     public int getSize() {
183         return _size;
184     }
185 
186     public void setSize(int size) {
187         _size = size;
188     }
189 
190     public Image toEscapedModel() {
191         if (isEscapedModel()) {
192             return (Image)this;
193         }
194         else {
195             return (Image)Proxy.newProxyInstance(Image.class.getClassLoader(),
196                 new Class[] { Image.class }, new AutoEscapeBeanHandler(this));
197         }
198     }
199 
200     public ExpandoBridge getExpandoBridge() {
201         if (_expandoBridge == null) {
202             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(Image.class.getName(),
203                     getPrimaryKey());
204         }
205 
206         return _expandoBridge;
207     }
208 
209     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
210         getExpandoBridge().setAttributes(serviceContext);
211     }
212 
213     public Object clone() {
214         ImageImpl clone = new ImageImpl();
215 
216         clone.setImageId(getImageId());
217         clone.setModifiedDate(getModifiedDate());
218         clone.setText(getText());
219         clone.setType(getType());
220         clone.setHeight(getHeight());
221         clone.setWidth(getWidth());
222         clone.setSize(getSize());
223 
224         return clone;
225     }
226 
227     public int compareTo(Image image) {
228         int value = 0;
229 
230         if (getImageId() < image.getImageId()) {
231             value = -1;
232         }
233         else if (getImageId() > image.getImageId()) {
234             value = 1;
235         }
236         else {
237             value = 0;
238         }
239 
240         if (value != 0) {
241             return value;
242         }
243 
244         return 0;
245     }
246 
247     public boolean equals(Object obj) {
248         if (obj == null) {
249             return false;
250         }
251 
252         Image image = null;
253 
254         try {
255             image = (Image)obj;
256         }
257         catch (ClassCastException cce) {
258             return false;
259         }
260 
261         long pk = image.getPrimaryKey();
262 
263         if (getPrimaryKey() == pk) {
264             return true;
265         }
266         else {
267             return false;
268         }
269     }
270 
271     public int hashCode() {
272         return (int)getPrimaryKey();
273     }
274 
275     public String toString() {
276         StringBundler sb = new StringBundler(15);
277 
278         sb.append("{imageId=");
279         sb.append(getImageId());
280         sb.append(", modifiedDate=");
281         sb.append(getModifiedDate());
282         sb.append(", text=");
283         sb.append(getText());
284         sb.append(", type=");
285         sb.append(getType());
286         sb.append(", height=");
287         sb.append(getHeight());
288         sb.append(", width=");
289         sb.append(getWidth());
290         sb.append(", size=");
291         sb.append(getSize());
292         sb.append("}");
293 
294         return sb.toString();
295     }
296 
297     public String toXmlString() {
298         StringBundler sb = new StringBundler(25);
299 
300         sb.append("<model><model-name>");
301         sb.append("com.liferay.portal.model.Image");
302         sb.append("</model-name>");
303 
304         sb.append(
305             "<column><column-name>imageId</column-name><column-value><![CDATA[");
306         sb.append(getImageId());
307         sb.append("]]></column-value></column>");
308         sb.append(
309             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
310         sb.append(getModifiedDate());
311         sb.append("]]></column-value></column>");
312         sb.append(
313             "<column><column-name>text</column-name><column-value><![CDATA[");
314         sb.append(getText());
315         sb.append("]]></column-value></column>");
316         sb.append(
317             "<column><column-name>type</column-name><column-value><![CDATA[");
318         sb.append(getType());
319         sb.append("]]></column-value></column>");
320         sb.append(
321             "<column><column-name>height</column-name><column-value><![CDATA[");
322         sb.append(getHeight());
323         sb.append("]]></column-value></column>");
324         sb.append(
325             "<column><column-name>width</column-name><column-value><![CDATA[");
326         sb.append(getWidth());
327         sb.append("]]></column-value></column>");
328         sb.append(
329             "<column><column-name>size</column-name><column-value><![CDATA[");
330         sb.append(getSize());
331         sb.append("]]></column-value></column>");
332 
333         sb.append("</model>");
334 
335         return sb.toString();
336     }
337 
338     private long _imageId;
339     private Date _modifiedDate;
340     private String _text;
341     private String _type;
342     private int _height;
343     private int _width;
344     private int _size;
345     private transient ExpandoBridge _expandoBridge;
346 }