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