1   /**
2    * Copyright (c) 2000-2009 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   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portal.model.impl;
21  
22  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23  import com.liferay.portal.kernel.util.GetterUtil;
24  import com.liferay.portal.kernel.util.HtmlUtil;
25  import com.liferay.portal.model.Image;
26  import com.liferay.portal.model.ImageSoap;
27  
28  import com.liferay.portlet.expando.model.ExpandoBridge;
29  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
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 ExpandoBridge getExpandoBridge() {
220         if (_expandoBridge == null) {
221             _expandoBridge = new ExpandoBridgeImpl(Image.class.getName(),
222                     getPrimaryKey());
223         }
224 
225         return _expandoBridge;
226     }
227 
228     public Object clone() {
229         ImageImpl clone = new ImageImpl();
230 
231         clone.setImageId(getImageId());
232         clone.setModifiedDate(getModifiedDate());
233         clone.setText(getText());
234         clone.setType(getType());
235         clone.setHeight(getHeight());
236         clone.setWidth(getWidth());
237         clone.setSize(getSize());
238 
239         return clone;
240     }
241 
242     public int compareTo(Image image) {
243         int value = 0;
244 
245         if (getImageId() < image.getImageId()) {
246             value = -1;
247         }
248         else if (getImageId() > image.getImageId()) {
249             value = 1;
250         }
251         else {
252             value = 0;
253         }
254 
255         if (value != 0) {
256             return value;
257         }
258 
259         return 0;
260     }
261 
262     public boolean equals(Object obj) {
263         if (obj == null) {
264             return false;
265         }
266 
267         Image image = null;
268 
269         try {
270             image = (Image)obj;
271         }
272         catch (ClassCastException cce) {
273             return false;
274         }
275 
276         long pk = image.getPrimaryKey();
277 
278         if (getPrimaryKey() == pk) {
279             return true;
280         }
281         else {
282             return false;
283         }
284     }
285 
286     public int hashCode() {
287         return (int)getPrimaryKey();
288     }
289 
290     public String toString() {
291         StringBuilder sb = new StringBuilder();
292 
293         sb.append("{imageId=");
294         sb.append(getImageId());
295         sb.append(", modifiedDate=");
296         sb.append(getModifiedDate());
297         sb.append(", text=");
298         sb.append(getText());
299         sb.append(", type=");
300         sb.append(getType());
301         sb.append(", height=");
302         sb.append(getHeight());
303         sb.append(", width=");
304         sb.append(getWidth());
305         sb.append(", size=");
306         sb.append(getSize());
307         sb.append("}");
308 
309         return sb.toString();
310     }
311 
312     public String toXmlString() {
313         StringBuilder sb = new StringBuilder();
314 
315         sb.append("<model><model-name>");
316         sb.append("com.liferay.portal.model.Image");
317         sb.append("</model-name>");
318 
319         sb.append(
320             "<column><column-name>imageId</column-name><column-value><![CDATA[");
321         sb.append(getImageId());
322         sb.append("]]></column-value></column>");
323         sb.append(
324             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
325         sb.append(getModifiedDate());
326         sb.append("]]></column-value></column>");
327         sb.append(
328             "<column><column-name>text</column-name><column-value><![CDATA[");
329         sb.append(getText());
330         sb.append("]]></column-value></column>");
331         sb.append(
332             "<column><column-name>type</column-name><column-value><![CDATA[");
333         sb.append(getType());
334         sb.append("]]></column-value></column>");
335         sb.append(
336             "<column><column-name>height</column-name><column-value><![CDATA[");
337         sb.append(getHeight());
338         sb.append("]]></column-value></column>");
339         sb.append(
340             "<column><column-name>width</column-name><column-value><![CDATA[");
341         sb.append(getWidth());
342         sb.append("]]></column-value></column>");
343         sb.append(
344             "<column><column-name>size</column-name><column-value><![CDATA[");
345         sb.append(getSize());
346         sb.append("]]></column-value></column>");
347 
348         sb.append("</model>");
349 
350         return sb.toString();
351     }
352 
353     private long _imageId;
354     private Date _modifiedDate;
355     private String _text;
356     private String _type;
357     private int _height;
358     private int _width;
359     private int _size;
360     private transient ExpandoBridge _expandoBridge;
361 }