001
014
015 package com.liferay.portal.model.impl;
016
017 import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018 import com.liferay.portal.kernel.json.JSON;
019 import com.liferay.portal.kernel.util.GetterUtil;
020 import com.liferay.portal.kernel.util.ProxyUtil;
021 import com.liferay.portal.kernel.util.StringBundler;
022 import com.liferay.portal.kernel.util.StringPool;
023 import com.liferay.portal.model.CacheModel;
024 import com.liferay.portal.model.Image;
025 import com.liferay.portal.model.ImageModel;
026 import com.liferay.portal.model.ImageSoap;
027 import com.liferay.portal.service.ServiceContext;
028
029 import com.liferay.portlet.expando.model.ExpandoBridge;
030 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
031
032 import java.io.Serializable;
033
034 import java.sql.Types;
035
036 import java.util.ArrayList;
037 import java.util.Date;
038 import java.util.HashMap;
039 import java.util.List;
040 import java.util.Map;
041
042
055 @JSON(strict = true)
056 public class ImageModelImpl extends BaseModelImpl<Image> implements ImageModel {
057
062 public static final String TABLE_NAME = "Image";
063 public static final Object[][] TABLE_COLUMNS = {
064 { "imageId", Types.BIGINT },
065 { "modifiedDate", Types.TIMESTAMP },
066 { "type_", Types.VARCHAR },
067 { "height", Types.INTEGER },
068 { "width", Types.INTEGER },
069 { "size_", Types.INTEGER }
070 };
071 public static final String TABLE_SQL_CREATE = "create table Image (imageId LONG not null primary key,modifiedDate DATE null,type_ VARCHAR(75) null,height INTEGER,width INTEGER,size_ INTEGER)";
072 public static final String TABLE_SQL_DROP = "drop table Image";
073 public static final String ORDER_BY_JPQL = " ORDER BY image.imageId ASC";
074 public static final String ORDER_BY_SQL = " ORDER BY Image.imageId ASC";
075 public static final String DATA_SOURCE = "liferayDataSource";
076 public static final String SESSION_FACTORY = "liferaySessionFactory";
077 public static final String TX_MANAGER = "liferayTransactionManager";
078 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
079 "value.object.entity.cache.enabled.com.liferay.portal.model.Image"),
080 true);
081 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
082 "value.object.finder.cache.enabled.com.liferay.portal.model.Image"),
083 true);
084 public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
085 "value.object.column.bitmask.enabled.com.liferay.portal.model.Image"),
086 true);
087 public static long SIZE_COLUMN_BITMASK = 1L;
088 public static long IMAGEID_COLUMN_BITMASK = 2L;
089
090
096 public static Image toModel(ImageSoap soapModel) {
097 if (soapModel == null) {
098 return null;
099 }
100
101 Image model = new ImageImpl();
102
103 model.setImageId(soapModel.getImageId());
104 model.setModifiedDate(soapModel.getModifiedDate());
105 model.setType(soapModel.getType());
106 model.setHeight(soapModel.getHeight());
107 model.setWidth(soapModel.getWidth());
108 model.setSize(soapModel.getSize());
109
110 return model;
111 }
112
113
119 public static List<Image> toModels(ImageSoap[] soapModels) {
120 if (soapModels == null) {
121 return null;
122 }
123
124 List<Image> models = new ArrayList<Image>(soapModels.length);
125
126 for (ImageSoap soapModel : soapModels) {
127 models.add(toModel(soapModel));
128 }
129
130 return models;
131 }
132
133 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
134 "lock.expiration.time.com.liferay.portal.model.Image"));
135
136 public ImageModelImpl() {
137 }
138
139 public long getPrimaryKey() {
140 return _imageId;
141 }
142
143 public void setPrimaryKey(long primaryKey) {
144 setImageId(primaryKey);
145 }
146
147 public Serializable getPrimaryKeyObj() {
148 return new Long(_imageId);
149 }
150
151 public void setPrimaryKeyObj(Serializable primaryKeyObj) {
152 setPrimaryKey(((Long)primaryKeyObj).longValue());
153 }
154
155 public Class<?> getModelClass() {
156 return Image.class;
157 }
158
159 public String getModelClassName() {
160 return Image.class.getName();
161 }
162
163 @Override
164 public Map<String, Object> getModelAttributes() {
165 Map<String, Object> attributes = new HashMap<String, Object>();
166
167 attributes.put("imageId", getImageId());
168 attributes.put("modifiedDate", getModifiedDate());
169 attributes.put("type", getType());
170 attributes.put("height", getHeight());
171 attributes.put("width", getWidth());
172 attributes.put("size", getSize());
173
174 return attributes;
175 }
176
177 @Override
178 public void setModelAttributes(Map<String, Object> attributes) {
179 Long imageId = (Long)attributes.get("imageId");
180
181 if (imageId != null) {
182 setImageId(imageId);
183 }
184
185 Date modifiedDate = (Date)attributes.get("modifiedDate");
186
187 if (modifiedDate != null) {
188 setModifiedDate(modifiedDate);
189 }
190
191 String type = (String)attributes.get("type");
192
193 if (type != null) {
194 setType(type);
195 }
196
197 Integer height = (Integer)attributes.get("height");
198
199 if (height != null) {
200 setHeight(height);
201 }
202
203 Integer width = (Integer)attributes.get("width");
204
205 if (width != null) {
206 setWidth(width);
207 }
208
209 Integer size = (Integer)attributes.get("size");
210
211 if (size != null) {
212 setSize(size);
213 }
214 }
215
216 @JSON
217 public long getImageId() {
218 return _imageId;
219 }
220
221 public void setImageId(long imageId) {
222 _columnBitmask = -1L;
223
224 _imageId = imageId;
225 }
226
227 @JSON
228 public Date getModifiedDate() {
229 return _modifiedDate;
230 }
231
232 public void setModifiedDate(Date modifiedDate) {
233 _modifiedDate = modifiedDate;
234 }
235
236 @JSON
237 public String getType() {
238 if (_type == null) {
239 return StringPool.BLANK;
240 }
241 else {
242 return _type;
243 }
244 }
245
246 public void setType(String type) {
247 _type = type;
248 }
249
250 @JSON
251 public int getHeight() {
252 return _height;
253 }
254
255 public void setHeight(int height) {
256 _height = height;
257 }
258
259 @JSON
260 public int getWidth() {
261 return _width;
262 }
263
264 public void setWidth(int width) {
265 _width = width;
266 }
267
268 @JSON
269 public int getSize() {
270 return _size;
271 }
272
273 public void setSize(int size) {
274 _columnBitmask |= SIZE_COLUMN_BITMASK;
275
276 if (!_setOriginalSize) {
277 _setOriginalSize = true;
278
279 _originalSize = _size;
280 }
281
282 _size = size;
283 }
284
285 public int getOriginalSize() {
286 return _originalSize;
287 }
288
289 public long getColumnBitmask() {
290 return _columnBitmask;
291 }
292
293 @Override
294 public ExpandoBridge getExpandoBridge() {
295 return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
296 Image.class.getName(), getPrimaryKey());
297 }
298
299 @Override
300 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
301 ExpandoBridge expandoBridge = getExpandoBridge();
302
303 expandoBridge.setAttributes(serviceContext);
304 }
305
306 @Override
307 public Image toEscapedModel() {
308 if (_escapedModel == null) {
309 _escapedModel = (Image)ProxyUtil.newProxyInstance(_classLoader,
310 _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
311 }
312
313 return _escapedModel;
314 }
315
316 @Override
317 public Object clone() {
318 ImageImpl imageImpl = new ImageImpl();
319
320 imageImpl.setImageId(getImageId());
321 imageImpl.setModifiedDate(getModifiedDate());
322 imageImpl.setType(getType());
323 imageImpl.setHeight(getHeight());
324 imageImpl.setWidth(getWidth());
325 imageImpl.setSize(getSize());
326
327 imageImpl.resetOriginalValues();
328
329 return imageImpl;
330 }
331
332 public int compareTo(Image image) {
333 int value = 0;
334
335 if (getImageId() < image.getImageId()) {
336 value = -1;
337 }
338 else if (getImageId() > image.getImageId()) {
339 value = 1;
340 }
341 else {
342 value = 0;
343 }
344
345 if (value != 0) {
346 return value;
347 }
348
349 return 0;
350 }
351
352 @Override
353 public boolean equals(Object obj) {
354 if (obj == null) {
355 return false;
356 }
357
358 Image image = null;
359
360 try {
361 image = (Image)obj;
362 }
363 catch (ClassCastException cce) {
364 return false;
365 }
366
367 long primaryKey = image.getPrimaryKey();
368
369 if (getPrimaryKey() == primaryKey) {
370 return true;
371 }
372 else {
373 return false;
374 }
375 }
376
377 @Override
378 public int hashCode() {
379 return (int)getPrimaryKey();
380 }
381
382 @Override
383 public void resetOriginalValues() {
384 ImageModelImpl imageModelImpl = this;
385
386 imageModelImpl._originalSize = imageModelImpl._size;
387
388 imageModelImpl._setOriginalSize = false;
389
390 imageModelImpl._columnBitmask = 0;
391 }
392
393 @Override
394 public CacheModel<Image> toCacheModel() {
395 ImageCacheModel imageCacheModel = new ImageCacheModel();
396
397 imageCacheModel.imageId = getImageId();
398
399 Date modifiedDate = getModifiedDate();
400
401 if (modifiedDate != null) {
402 imageCacheModel.modifiedDate = modifiedDate.getTime();
403 }
404 else {
405 imageCacheModel.modifiedDate = Long.MIN_VALUE;
406 }
407
408 imageCacheModel.type = getType();
409
410 String type = imageCacheModel.type;
411
412 if ((type != null) && (type.length() == 0)) {
413 imageCacheModel.type = null;
414 }
415
416 imageCacheModel.height = getHeight();
417
418 imageCacheModel.width = getWidth();
419
420 imageCacheModel.size = getSize();
421
422 return imageCacheModel;
423 }
424
425 @Override
426 public String toString() {
427 StringBundler sb = new StringBundler(13);
428
429 sb.append("{imageId=");
430 sb.append(getImageId());
431 sb.append(", modifiedDate=");
432 sb.append(getModifiedDate());
433 sb.append(", type=");
434 sb.append(getType());
435 sb.append(", height=");
436 sb.append(getHeight());
437 sb.append(", width=");
438 sb.append(getWidth());
439 sb.append(", size=");
440 sb.append(getSize());
441 sb.append("}");
442
443 return sb.toString();
444 }
445
446 public String toXmlString() {
447 StringBundler sb = new StringBundler(22);
448
449 sb.append("<model><model-name>");
450 sb.append("com.liferay.portal.model.Image");
451 sb.append("</model-name>");
452
453 sb.append(
454 "<column><column-name>imageId</column-name><column-value><![CDATA[");
455 sb.append(getImageId());
456 sb.append("]]></column-value></column>");
457 sb.append(
458 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
459 sb.append(getModifiedDate());
460 sb.append("]]></column-value></column>");
461 sb.append(
462 "<column><column-name>type</column-name><column-value><![CDATA[");
463 sb.append(getType());
464 sb.append("]]></column-value></column>");
465 sb.append(
466 "<column><column-name>height</column-name><column-value><![CDATA[");
467 sb.append(getHeight());
468 sb.append("]]></column-value></column>");
469 sb.append(
470 "<column><column-name>width</column-name><column-value><![CDATA[");
471 sb.append(getWidth());
472 sb.append("]]></column-value></column>");
473 sb.append(
474 "<column><column-name>size</column-name><column-value><![CDATA[");
475 sb.append(getSize());
476 sb.append("]]></column-value></column>");
477
478 sb.append("</model>");
479
480 return sb.toString();
481 }
482
483 private static ClassLoader _classLoader = Image.class.getClassLoader();
484 private static Class<?>[] _escapedModelInterfaces = new Class[] { Image.class };
485 private long _imageId;
486 private Date _modifiedDate;
487 private String _type;
488 private int _height;
489 private int _width;
490 private int _size;
491 private int _originalSize;
492 private boolean _setOriginalSize;
493 private long _columnBitmask;
494 private Image _escapedModel;
495 }