1   /**
2    * Copyright (c) 2000-2008 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 {
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 CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
90                  "value.object.finder.cache.enabled.com.liferay.portal.model.Image"),
91              true);
92  
93      public static Image toModel(ImageSoap soapModel) {
94          Image model = new ImageImpl();
95  
96          model.setImageId(soapModel.getImageId());
97          model.setModifiedDate(soapModel.getModifiedDate());
98          model.setText(soapModel.getText());
99          model.setType(soapModel.getType());
100         model.setHeight(soapModel.getHeight());
101         model.setWidth(soapModel.getWidth());
102         model.setSize(soapModel.getSize());
103 
104         return model;
105     }
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         if (imageId != _imageId) {
141             _imageId = imageId;
142         }
143     }
144 
145     public Date getModifiedDate() {
146         return _modifiedDate;
147     }
148 
149     public void setModifiedDate(Date modifiedDate) {
150         if (((modifiedDate == null) && (_modifiedDate != null)) ||
151                 ((modifiedDate != null) && (_modifiedDate == null)) ||
152                 ((modifiedDate != null) && (_modifiedDate != null) &&
153                 !modifiedDate.equals(_modifiedDate))) {
154             _modifiedDate = modifiedDate;
155         }
156     }
157 
158     public String getText() {
159         return GetterUtil.getString(_text);
160     }
161 
162     public void setText(String text) {
163         if (((text == null) && (_text != null)) ||
164                 ((text != null) && (_text == null)) ||
165                 ((text != null) && (_text != null) && !text.equals(_text))) {
166             _text = text;
167         }
168     }
169 
170     public String getType() {
171         return GetterUtil.getString(_type);
172     }
173 
174     public void setType(String type) {
175         if (((type == null) && (_type != null)) ||
176                 ((type != null) && (_type == null)) ||
177                 ((type != null) && (_type != null) && !type.equals(_type))) {
178             _type = type;
179         }
180     }
181 
182     public int getHeight() {
183         return _height;
184     }
185 
186     public void setHeight(int height) {
187         if (height != _height) {
188             _height = height;
189         }
190     }
191 
192     public int getWidth() {
193         return _width;
194     }
195 
196     public void setWidth(int width) {
197         if (width != _width) {
198             _width = width;
199         }
200     }
201 
202     public int getSize() {
203         return _size;
204     }
205 
206     public void setSize(int size) {
207         if (size != _size) {
208             _size = size;
209         }
210     }
211 
212     public Image toEscapedModel() {
213         if (isEscapedModel()) {
214             return (Image)this;
215         }
216         else {
217             Image model = new ImageImpl();
218 
219             model.setNew(isNew());
220             model.setEscapedModel(true);
221 
222             model.setImageId(getImageId());
223             model.setModifiedDate(getModifiedDate());
224             model.setText(HtmlUtil.escape(getText()));
225             model.setType(HtmlUtil.escape(getType()));
226             model.setHeight(getHeight());
227             model.setWidth(getWidth());
228             model.setSize(getSize());
229 
230             model = (Image)Proxy.newProxyInstance(Image.class.getClassLoader(),
231                     new Class[] { Image.class }, new ReadOnlyBeanHandler(model));
232 
233             return model;
234         }
235     }
236 
237     public Object clone() {
238         ImageImpl clone = new ImageImpl();
239 
240         clone.setImageId(getImageId());
241         clone.setModifiedDate(getModifiedDate());
242         clone.setText(getText());
243         clone.setType(getType());
244         clone.setHeight(getHeight());
245         clone.setWidth(getWidth());
246         clone.setSize(getSize());
247 
248         return clone;
249     }
250 
251     public int compareTo(Object obj) {
252         if (obj == null) {
253             return -1;
254         }
255 
256         ImageImpl image = (ImageImpl)obj;
257 
258         int value = 0;
259 
260         if (getImageId() < image.getImageId()) {
261             value = -1;
262         }
263         else if (getImageId() > image.getImageId()) {
264             value = 1;
265         }
266         else {
267             value = 0;
268         }
269 
270         if (value != 0) {
271             return value;
272         }
273 
274         return 0;
275     }
276 
277     public boolean equals(Object obj) {
278         if (obj == null) {
279             return false;
280         }
281 
282         ImageImpl image = null;
283 
284         try {
285             image = (ImageImpl)obj;
286         }
287         catch (ClassCastException cce) {
288             return false;
289         }
290 
291         long pk = image.getPrimaryKey();
292 
293         if (getPrimaryKey() == pk) {
294             return true;
295         }
296         else {
297             return false;
298         }
299     }
300 
301     public int hashCode() {
302         return (int)getPrimaryKey();
303     }
304 
305     private long _imageId;
306     private Date _modifiedDate;
307     private String _text;
308     private String _type;
309     private int _height;
310     private int _width;
311     private int _size;
312 }