1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.model.impl;
24  
25  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.GetterUtil;
27  import com.liferay.portal.kernel.util.HtmlUtil;
28  import com.liferay.portal.model.Image;
29  import com.liferay.portal.model.ImageSoap;
30  
31  import com.liferay.portlet.expando.model.ExpandoBridge;
32  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
33  
34  import java.io.Serializable;
35  
36  import java.lang.reflect.Proxy;
37  
38  import java.sql.Types;
39  
40  import java.util.ArrayList;
41  import java.util.Date;
42  import java.util.List;
43  
44  /**
45   * <a href="ImageModelImpl.java.html"><b><i>View Source</i></b></a>
46   *
47   * <p>
48   * ServiceBuilder generated this class. Modifications in this class will be
49   * overwritten the next time is generated.
50   * </p>
51   *
52   * <p>
53   * This class is a model that represents the <code>Image</code> table
54   * in the database.
55   * </p>
56   *
57   * @author Brian Wing Shun Chan
58   *
59   * @see com.liferay.portal.model.Image
60   * @see com.liferay.portal.model.ImageModel
61   * @see com.liferay.portal.model.impl.ImageImpl
62   *
63   */
64  public class ImageModelImpl extends BaseModelImpl<Image> {
65      public static final String TABLE_NAME = "Image";
66      public static final Object[][] TABLE_COLUMNS = {
67              { "imageId", new Integer(Types.BIGINT) },
68              
69  
70              { "modifiedDate", new Integer(Types.TIMESTAMP) },
71              
72  
73              { "text_", new Integer(Types.CLOB) },
74              
75  
76              { "type_", new Integer(Types.VARCHAR) },
77              
78  
79              { "height", new Integer(Types.INTEGER) },
80              
81  
82              { "width", new Integer(Types.INTEGER) },
83              
84  
85              { "size_", new Integer(Types.INTEGER) }
86          };
87      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)";
88      public static final String TABLE_SQL_DROP = "drop table Image";
89      public static final String DATA_SOURCE = "liferayDataSource";
90      public static final String SESSION_FACTORY = "liferaySessionFactory";
91      public static final String TX_MANAGER = "liferayTransactionManager";
92      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
93                  "value.object.entity.cache.enabled.com.liferay.portal.model.Image"),
94              true);
95      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
96                  "value.object.finder.cache.enabled.com.liferay.portal.model.Image"),
97              true);
98  
99      public static Image toModel(ImageSoap soapModel) {
100         Image model = new ImageImpl();
101 
102         model.setImageId(soapModel.getImageId());
103         model.setModifiedDate(soapModel.getModifiedDate());
104         model.setText(soapModel.getText());
105         model.setType(soapModel.getType());
106         model.setHeight(soapModel.getHeight());
107         model.setWidth(soapModel.getWidth());
108         model.setSize(soapModel.getSize());
109 
110         return model;
111     }
112 
113     public static List<Image> toModels(ImageSoap[] soapModels) {
114         List<Image> models = new ArrayList<Image>(soapModels.length);
115 
116         for (ImageSoap soapModel : soapModels) {
117             models.add(toModel(soapModel));
118         }
119 
120         return models;
121     }
122 
123     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
124                 "lock.expiration.time.com.liferay.portal.model.Image"));
125 
126     public ImageModelImpl() {
127     }
128 
129     public long getPrimaryKey() {
130         return _imageId;
131     }
132 
133     public void setPrimaryKey(long pk) {
134         setImageId(pk);
135     }
136 
137     public Serializable getPrimaryKeyObj() {
138         return new Long(_imageId);
139     }
140 
141     public long getImageId() {
142         return _imageId;
143     }
144 
145     public void setImageId(long imageId) {
146         _imageId = imageId;
147     }
148 
149     public Date getModifiedDate() {
150         return _modifiedDate;
151     }
152 
153     public void setModifiedDate(Date modifiedDate) {
154         _modifiedDate = modifiedDate;
155     }
156 
157     public String getText() {
158         return GetterUtil.getString(_text);
159     }
160 
161     public void setText(String text) {
162         _text = text;
163     }
164 
165     public String getType() {
166         return GetterUtil.getString(_type);
167     }
168 
169     public void setType(String type) {
170         _type = type;
171     }
172 
173     public int getHeight() {
174         return _height;
175     }
176 
177     public void setHeight(int height) {
178         _height = height;
179     }
180 
181     public int getWidth() {
182         return _width;
183     }
184 
185     public void setWidth(int width) {
186         _width = width;
187     }
188 
189     public int getSize() {
190         return _size;
191     }
192 
193     public void setSize(int size) {
194         _size = size;
195     }
196 
197     public Image toEscapedModel() {
198         if (isEscapedModel()) {
199             return (Image)this;
200         }
201         else {
202             Image model = new ImageImpl();
203 
204             model.setNew(isNew());
205             model.setEscapedModel(true);
206 
207             model.setImageId(getImageId());
208             model.setModifiedDate(getModifiedDate());
209             model.setText(HtmlUtil.escape(getText()));
210             model.setType(HtmlUtil.escape(getType()));
211             model.setHeight(getHeight());
212             model.setWidth(getWidth());
213             model.setSize(getSize());
214 
215             model = (Image)Proxy.newProxyInstance(Image.class.getClassLoader(),
216                     new Class[] { Image.class }, new ReadOnlyBeanHandler(model));
217 
218             return model;
219         }
220     }
221 
222     public ExpandoBridge getExpandoBridge() {
223         if (_expandoBridge == null) {
224             _expandoBridge = new ExpandoBridgeImpl(Image.class.getName(),
225                     getPrimaryKey());
226         }
227 
228         return _expandoBridge;
229     }
230 
231     public Object clone() {
232         ImageImpl clone = new ImageImpl();
233 
234         clone.setImageId(getImageId());
235         clone.setModifiedDate(getModifiedDate());
236         clone.setText(getText());
237         clone.setType(getType());
238         clone.setHeight(getHeight());
239         clone.setWidth(getWidth());
240         clone.setSize(getSize());
241 
242         return clone;
243     }
244 
245     public int compareTo(Image image) {
246         int value = 0;
247 
248         if (getImageId() < image.getImageId()) {
249             value = -1;
250         }
251         else if (getImageId() > image.getImageId()) {
252             value = 1;
253         }
254         else {
255             value = 0;
256         }
257 
258         if (value != 0) {
259             return value;
260         }
261 
262         return 0;
263     }
264 
265     public boolean equals(Object obj) {
266         if (obj == null) {
267             return false;
268         }
269 
270         Image image = null;
271 
272         try {
273             image = (Image)obj;
274         }
275         catch (ClassCastException cce) {
276             return false;
277         }
278 
279         long pk = image.getPrimaryKey();
280 
281         if (getPrimaryKey() == pk) {
282             return true;
283         }
284         else {
285             return false;
286         }
287     }
288 
289     public int hashCode() {
290         return (int)getPrimaryKey();
291     }
292 
293     public String toString() {
294         StringBuilder sb = new StringBuilder();
295 
296         sb.append("{imageId=");
297         sb.append(getImageId());
298         sb.append(", modifiedDate=");
299         sb.append(getModifiedDate());
300         sb.append(", text=");
301         sb.append(getText());
302         sb.append(", type=");
303         sb.append(getType());
304         sb.append(", height=");
305         sb.append(getHeight());
306         sb.append(", width=");
307         sb.append(getWidth());
308         sb.append(", size=");
309         sb.append(getSize());
310         sb.append("}");
311 
312         return sb.toString();
313     }
314 
315     public String toXmlString() {
316         StringBuilder sb = new StringBuilder();
317 
318         sb.append("<model><model-name>");
319         sb.append("com.liferay.portal.model.Image");
320         sb.append("</model-name>");
321 
322         sb.append(
323             "<column><column-name>imageId</column-name><column-value><![CDATA[");
324         sb.append(getImageId());
325         sb.append("]]></column-value></column>");
326         sb.append(
327             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
328         sb.append(getModifiedDate());
329         sb.append("]]></column-value></column>");
330         sb.append(
331             "<column><column-name>text</column-name><column-value><![CDATA[");
332         sb.append(getText());
333         sb.append("]]></column-value></column>");
334         sb.append(
335             "<column><column-name>type</column-name><column-value><![CDATA[");
336         sb.append(getType());
337         sb.append("]]></column-value></column>");
338         sb.append(
339             "<column><column-name>height</column-name><column-value><![CDATA[");
340         sb.append(getHeight());
341         sb.append("]]></column-value></column>");
342         sb.append(
343             "<column><column-name>width</column-name><column-value><![CDATA[");
344         sb.append(getWidth());
345         sb.append("]]></column-value></column>");
346         sb.append(
347             "<column><column-name>size</column-name><column-value><![CDATA[");
348         sb.append(getSize());
349         sb.append("]]></column-value></column>");
350 
351         sb.append("</model>");
352 
353         return sb.toString();
354     }
355 
356     private long _imageId;
357     private Date _modifiedDate;
358     private String _text;
359     private String _type;
360     private int _height;
361     private int _width;
362     private int _size;
363     private transient ExpandoBridge _expandoBridge;
364 }