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.portlet.journal.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.impl.BaseModelImpl;
29  
30  import com.liferay.portlet.expando.model.ExpandoBridge;
31  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
32  import com.liferay.portlet.journal.model.JournalArticleImage;
33  import com.liferay.portlet.journal.model.JournalArticleImageSoap;
34  
35  import java.io.Serializable;
36  
37  import java.lang.reflect.Proxy;
38  
39  import java.sql.Types;
40  
41  import java.util.ArrayList;
42  import java.util.List;
43  
44  /**
45   * <a href="JournalArticleImageModelImpl.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>JournalArticleImage</code> table
54   * in the database.
55   * </p>
56   *
57   * @author Brian Wing Shun Chan
58   *
59   * @see com.liferay.portlet.journal.model.JournalArticleImage
60   * @see com.liferay.portlet.journal.model.JournalArticleImageModel
61   * @see com.liferay.portlet.journal.model.impl.JournalArticleImageImpl
62   *
63   */
64  public class JournalArticleImageModelImpl extends BaseModelImpl {
65      public static final String TABLE_NAME = "JournalArticleImage";
66      public static final Object[][] TABLE_COLUMNS = {
67              { "articleImageId", new Integer(Types.BIGINT) },
68              
69  
70              { "groupId", new Integer(Types.BIGINT) },
71              
72  
73              { "articleId", new Integer(Types.VARCHAR) },
74              
75  
76              { "version", new Integer(Types.DOUBLE) },
77              
78  
79              { "elInstanceId", new Integer(Types.VARCHAR) },
80              
81  
82              { "elName", new Integer(Types.VARCHAR) },
83              
84  
85              { "languageId", new Integer(Types.VARCHAR) },
86              
87  
88              { "tempImage", new Integer(Types.BOOLEAN) }
89          };
90      public static final String TABLE_SQL_CREATE = "create table JournalArticleImage (articleImageId LONG not null primary key,groupId LONG,articleId VARCHAR(75) null,version DOUBLE,elInstanceId VARCHAR(75) null,elName VARCHAR(75) null,languageId VARCHAR(75) null,tempImage BOOLEAN)";
91      public static final String TABLE_SQL_DROP = "drop table JournalArticleImage";
92      public static final String DATA_SOURCE = "liferayDataSource";
93      public static final String SESSION_FACTORY = "liferaySessionFactory";
94      public static final String TX_MANAGER = "liferayTransactionManager";
95      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
96                  "value.object.finder.cache.enabled.com.liferay.portlet.journal.model.JournalArticleImage"),
97              true);
98  
99      public static JournalArticleImage toModel(JournalArticleImageSoap soapModel) {
100         JournalArticleImage model = new JournalArticleImageImpl();
101 
102         model.setArticleImageId(soapModel.getArticleImageId());
103         model.setGroupId(soapModel.getGroupId());
104         model.setArticleId(soapModel.getArticleId());
105         model.setVersion(soapModel.getVersion());
106         model.setElInstanceId(soapModel.getElInstanceId());
107         model.setElName(soapModel.getElName());
108         model.setLanguageId(soapModel.getLanguageId());
109         model.setTempImage(soapModel.getTempImage());
110 
111         return model;
112     }
113 
114     public static List<JournalArticleImage> toModels(
115         JournalArticleImageSoap[] soapModels) {
116         List<JournalArticleImage> models = new ArrayList<JournalArticleImage>(soapModels.length);
117 
118         for (JournalArticleImageSoap soapModel : soapModels) {
119             models.add(toModel(soapModel));
120         }
121 
122         return models;
123     }
124 
125     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
126                 "lock.expiration.time.com.liferay.portlet.journal.model.JournalArticleImage"));
127 
128     public JournalArticleImageModelImpl() {
129     }
130 
131     public long getPrimaryKey() {
132         return _articleImageId;
133     }
134 
135     public void setPrimaryKey(long pk) {
136         setArticleImageId(pk);
137     }
138 
139     public Serializable getPrimaryKeyObj() {
140         return new Long(_articleImageId);
141     }
142 
143     public long getArticleImageId() {
144         return _articleImageId;
145     }
146 
147     public void setArticleImageId(long articleImageId) {
148         if (articleImageId != _articleImageId) {
149             _articleImageId = articleImageId;
150         }
151     }
152 
153     public long getGroupId() {
154         return _groupId;
155     }
156 
157     public void setGroupId(long groupId) {
158         if (groupId != _groupId) {
159             _groupId = groupId;
160         }
161     }
162 
163     public String getArticleId() {
164         return GetterUtil.getString(_articleId);
165     }
166 
167     public void setArticleId(String articleId) {
168         if (((articleId == null) && (_articleId != null)) ||
169                 ((articleId != null) && (_articleId == null)) ||
170                 ((articleId != null) && (_articleId != null) &&
171                 !articleId.equals(_articleId))) {
172             _articleId = articleId;
173         }
174     }
175 
176     public double getVersion() {
177         return _version;
178     }
179 
180     public void setVersion(double version) {
181         if (version != _version) {
182             _version = version;
183         }
184     }
185 
186     public String getElInstanceId() {
187         return GetterUtil.getString(_elInstanceId);
188     }
189 
190     public void setElInstanceId(String elInstanceId) {
191         if (((elInstanceId == null) && (_elInstanceId != null)) ||
192                 ((elInstanceId != null) && (_elInstanceId == null)) ||
193                 ((elInstanceId != null) && (_elInstanceId != null) &&
194                 !elInstanceId.equals(_elInstanceId))) {
195             _elInstanceId = elInstanceId;
196         }
197     }
198 
199     public String getElName() {
200         return GetterUtil.getString(_elName);
201     }
202 
203     public void setElName(String elName) {
204         if (((elName == null) && (_elName != null)) ||
205                 ((elName != null) && (_elName == null)) ||
206                 ((elName != null) && (_elName != null) &&
207                 !elName.equals(_elName))) {
208             _elName = elName;
209         }
210     }
211 
212     public String getLanguageId() {
213         return GetterUtil.getString(_languageId);
214     }
215 
216     public void setLanguageId(String languageId) {
217         if (((languageId == null) && (_languageId != null)) ||
218                 ((languageId != null) && (_languageId == null)) ||
219                 ((languageId != null) && (_languageId != null) &&
220                 !languageId.equals(_languageId))) {
221             _languageId = languageId;
222         }
223     }
224 
225     public boolean getTempImage() {
226         return _tempImage;
227     }
228 
229     public boolean isTempImage() {
230         return _tempImage;
231     }
232 
233     public void setTempImage(boolean tempImage) {
234         if (tempImage != _tempImage) {
235             _tempImage = tempImage;
236         }
237     }
238 
239     public JournalArticleImage toEscapedModel() {
240         if (isEscapedModel()) {
241             return (JournalArticleImage)this;
242         }
243         else {
244             JournalArticleImage model = new JournalArticleImageImpl();
245 
246             model.setNew(isNew());
247             model.setEscapedModel(true);
248 
249             model.setArticleImageId(getArticleImageId());
250             model.setGroupId(getGroupId());
251             model.setArticleId(HtmlUtil.escape(getArticleId()));
252             model.setVersion(getVersion());
253             model.setElInstanceId(HtmlUtil.escape(getElInstanceId()));
254             model.setElName(HtmlUtil.escape(getElName()));
255             model.setLanguageId(HtmlUtil.escape(getLanguageId()));
256             model.setTempImage(getTempImage());
257 
258             model = (JournalArticleImage)Proxy.newProxyInstance(JournalArticleImage.class.getClassLoader(),
259                     new Class[] { JournalArticleImage.class },
260                     new ReadOnlyBeanHandler(model));
261 
262             return model;
263         }
264     }
265 
266     public ExpandoBridge getExpandoBridge() {
267         if (_expandoBridge == null) {
268             _expandoBridge = new ExpandoBridgeImpl(JournalArticleImage.class.getName(),
269                     getPrimaryKey());
270         }
271 
272         return _expandoBridge;
273     }
274 
275     public Object clone() {
276         JournalArticleImageImpl clone = new JournalArticleImageImpl();
277 
278         clone.setArticleImageId(getArticleImageId());
279         clone.setGroupId(getGroupId());
280         clone.setArticleId(getArticleId());
281         clone.setVersion(getVersion());
282         clone.setElInstanceId(getElInstanceId());
283         clone.setElName(getElName());
284         clone.setLanguageId(getLanguageId());
285         clone.setTempImage(getTempImage());
286 
287         return clone;
288     }
289 
290     public int compareTo(Object obj) {
291         if (obj == null) {
292             return -1;
293         }
294 
295         JournalArticleImageImpl journalArticleImage = (JournalArticleImageImpl)obj;
296 
297         long pk = journalArticleImage.getPrimaryKey();
298 
299         if (getPrimaryKey() < pk) {
300             return -1;
301         }
302         else if (getPrimaryKey() > pk) {
303             return 1;
304         }
305         else {
306             return 0;
307         }
308     }
309 
310     public boolean equals(Object obj) {
311         if (obj == null) {
312             return false;
313         }
314 
315         JournalArticleImageImpl journalArticleImage = null;
316 
317         try {
318             journalArticleImage = (JournalArticleImageImpl)obj;
319         }
320         catch (ClassCastException cce) {
321             return false;
322         }
323 
324         long pk = journalArticleImage.getPrimaryKey();
325 
326         if (getPrimaryKey() == pk) {
327             return true;
328         }
329         else {
330             return false;
331         }
332     }
333 
334     public int hashCode() {
335         return (int)getPrimaryKey();
336     }
337 
338     private long _articleImageId;
339     private long _groupId;
340     private String _articleId;
341     private double _version;
342     private String _elInstanceId;
343     private String _elName;
344     private String _languageId;
345     private boolean _tempImage;
346     private transient ExpandoBridge _expandoBridge;
347 }