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