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