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.service.model.Image
57   * @see com.liferay.portal.service.model.ImageModel
58   * @see com.liferay.portal.service.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.setEscapedModel(true);
220 
221             model.setImageId(getImageId());
222             model.setModifiedDate(getModifiedDate());
223             model.setText(HtmlUtil.escape(getText()));
224             model.setType(HtmlUtil.escape(getType()));
225             model.setHeight(getHeight());
226             model.setWidth(getWidth());
227             model.setSize(getSize());
228 
229             model = (Image)Proxy.newProxyInstance(Image.class.getClassLoader(),
230                     new Class[] { Image.class }, new ReadOnlyBeanHandler(model));
231 
232             return model;
233         }
234     }
235 
236     public Object clone() {
237         ImageImpl clone = new ImageImpl();
238 
239         clone.setImageId(getImageId());
240         clone.setModifiedDate(getModifiedDate());
241         clone.setText(getText());
242         clone.setType(getType());
243         clone.setHeight(getHeight());
244         clone.setWidth(getWidth());
245         clone.setSize(getSize());
246 
247         return clone;
248     }
249 
250     public int compareTo(Object obj) {
251         if (obj == null) {
252             return -1;
253         }
254 
255         ImageImpl image = (ImageImpl)obj;
256 
257         int value = 0;
258 
259         if (getImageId() < image.getImageId()) {
260             value = -1;
261         }
262         else if (getImageId() > image.getImageId()) {
263             value = 1;
264         }
265         else {
266             value = 0;
267         }
268 
269         if (value != 0) {
270             return value;
271         }
272 
273         return 0;
274     }
275 
276     public boolean equals(Object obj) {
277         if (obj == null) {
278             return false;
279         }
280 
281         ImageImpl image = null;
282 
283         try {
284             image = (ImageImpl)obj;
285         }
286         catch (ClassCastException cce) {
287             return false;
288         }
289 
290         long pk = image.getPrimaryKey();
291 
292         if (getPrimaryKey() == pk) {
293             return true;
294         }
295         else {
296             return false;
297         }
298     }
299 
300     public int hashCode() {
301         return (int)getPrimaryKey();
302     }
303 
304     private long _imageId;
305     private Date _modifiedDate;
306     private String _text;
307     private String _type;
308     private int _height;
309     private int _width;
310     private int _size;
311 }