001
014
015 package com.liferay.portal.model.impl;
016
017 import com.liferay.portal.LocaleException;
018 import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
019 import com.liferay.portal.kernel.exception.SystemException;
020 import com.liferay.portal.kernel.json.JSON;
021 import com.liferay.portal.kernel.util.GetterUtil;
022 import com.liferay.portal.kernel.util.LocaleUtil;
023 import com.liferay.portal.kernel.util.LocalizationUtil;
024 import com.liferay.portal.kernel.util.ProxyUtil;
025 import com.liferay.portal.kernel.util.StringBundler;
026 import com.liferay.portal.kernel.util.StringPool;
027 import com.liferay.portal.kernel.util.Validator;
028 import com.liferay.portal.model.CacheModel;
029 import com.liferay.portal.model.LayoutPrototype;
030 import com.liferay.portal.model.LayoutPrototypeModel;
031 import com.liferay.portal.model.LayoutPrototypeSoap;
032 import com.liferay.portal.service.ServiceContext;
033 import com.liferay.portal.util.PortalUtil;
034
035 import com.liferay.portlet.expando.model.ExpandoBridge;
036 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
037
038 import java.io.Serializable;
039
040 import java.sql.Types;
041
042 import java.util.ArrayList;
043 import java.util.Date;
044 import java.util.HashMap;
045 import java.util.List;
046 import java.util.Locale;
047 import java.util.Map;
048
049
062 @JSON(strict = true)
063 public class LayoutPrototypeModelImpl extends BaseModelImpl<LayoutPrototype>
064 implements LayoutPrototypeModel {
065
070 public static final String TABLE_NAME = "LayoutPrototype";
071 public static final Object[][] TABLE_COLUMNS = {
072 { "uuid_", Types.VARCHAR },
073 { "layoutPrototypeId", Types.BIGINT },
074 { "companyId", Types.BIGINT },
075 { "userId", Types.BIGINT },
076 { "userName", Types.VARCHAR },
077 { "createDate", Types.TIMESTAMP },
078 { "modifiedDate", Types.TIMESTAMP },
079 { "name", Types.VARCHAR },
080 { "description", Types.VARCHAR },
081 { "settings_", Types.VARCHAR },
082 { "active_", Types.BOOLEAN }
083 };
084 public static final String TABLE_SQL_CREATE = "create table LayoutPrototype (uuid_ VARCHAR(75) null,layoutPrototypeId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,name STRING null,description STRING null,settings_ STRING null,active_ BOOLEAN)";
085 public static final String TABLE_SQL_DROP = "drop table LayoutPrototype";
086 public static final String ORDER_BY_JPQL = " ORDER BY layoutPrototype.layoutPrototypeId ASC";
087 public static final String ORDER_BY_SQL = " ORDER BY LayoutPrototype.layoutPrototypeId ASC";
088 public static final String DATA_SOURCE = "liferayDataSource";
089 public static final String SESSION_FACTORY = "liferaySessionFactory";
090 public static final String TX_MANAGER = "liferayTransactionManager";
091 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
092 "value.object.entity.cache.enabled.com.liferay.portal.model.LayoutPrototype"),
093 true);
094 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
095 "value.object.finder.cache.enabled.com.liferay.portal.model.LayoutPrototype"),
096 true);
097 public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
098 "value.object.column.bitmask.enabled.com.liferay.portal.model.LayoutPrototype"),
099 true);
100 public static long ACTIVE_COLUMN_BITMASK = 1L;
101 public static long COMPANYID_COLUMN_BITMASK = 2L;
102 public static long UUID_COLUMN_BITMASK = 4L;
103 public static long LAYOUTPROTOTYPEID_COLUMN_BITMASK = 8L;
104
105
111 public static LayoutPrototype toModel(LayoutPrototypeSoap soapModel) {
112 if (soapModel == null) {
113 return null;
114 }
115
116 LayoutPrototype model = new LayoutPrototypeImpl();
117
118 model.setUuid(soapModel.getUuid());
119 model.setLayoutPrototypeId(soapModel.getLayoutPrototypeId());
120 model.setCompanyId(soapModel.getCompanyId());
121 model.setUserId(soapModel.getUserId());
122 model.setUserName(soapModel.getUserName());
123 model.setCreateDate(soapModel.getCreateDate());
124 model.setModifiedDate(soapModel.getModifiedDate());
125 model.setName(soapModel.getName());
126 model.setDescription(soapModel.getDescription());
127 model.setSettings(soapModel.getSettings());
128 model.setActive(soapModel.getActive());
129
130 return model;
131 }
132
133
139 public static List<LayoutPrototype> toModels(
140 LayoutPrototypeSoap[] soapModels) {
141 if (soapModels == null) {
142 return null;
143 }
144
145 List<LayoutPrototype> models = new ArrayList<LayoutPrototype>(soapModels.length);
146
147 for (LayoutPrototypeSoap soapModel : soapModels) {
148 models.add(toModel(soapModel));
149 }
150
151 return models;
152 }
153
154 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
155 "lock.expiration.time.com.liferay.portal.model.LayoutPrototype"));
156
157 public LayoutPrototypeModelImpl() {
158 }
159
160 public long getPrimaryKey() {
161 return _layoutPrototypeId;
162 }
163
164 public void setPrimaryKey(long primaryKey) {
165 setLayoutPrototypeId(primaryKey);
166 }
167
168 public Serializable getPrimaryKeyObj() {
169 return _layoutPrototypeId;
170 }
171
172 public void setPrimaryKeyObj(Serializable primaryKeyObj) {
173 setPrimaryKey(((Long)primaryKeyObj).longValue());
174 }
175
176 public Class<?> getModelClass() {
177 return LayoutPrototype.class;
178 }
179
180 public String getModelClassName() {
181 return LayoutPrototype.class.getName();
182 }
183
184 @Override
185 public Map<String, Object> getModelAttributes() {
186 Map<String, Object> attributes = new HashMap<String, Object>();
187
188 attributes.put("uuid", getUuid());
189 attributes.put("layoutPrototypeId", getLayoutPrototypeId());
190 attributes.put("companyId", getCompanyId());
191 attributes.put("userId", getUserId());
192 attributes.put("userName", getUserName());
193 attributes.put("createDate", getCreateDate());
194 attributes.put("modifiedDate", getModifiedDate());
195 attributes.put("name", getName());
196 attributes.put("description", getDescription());
197 attributes.put("settings", getSettings());
198 attributes.put("active", getActive());
199
200 return attributes;
201 }
202
203 @Override
204 public void setModelAttributes(Map<String, Object> attributes) {
205 String uuid = (String)attributes.get("uuid");
206
207 if (uuid != null) {
208 setUuid(uuid);
209 }
210
211 Long layoutPrototypeId = (Long)attributes.get("layoutPrototypeId");
212
213 if (layoutPrototypeId != null) {
214 setLayoutPrototypeId(layoutPrototypeId);
215 }
216
217 Long companyId = (Long)attributes.get("companyId");
218
219 if (companyId != null) {
220 setCompanyId(companyId);
221 }
222
223 Long userId = (Long)attributes.get("userId");
224
225 if (userId != null) {
226 setUserId(userId);
227 }
228
229 String userName = (String)attributes.get("userName");
230
231 if (userName != null) {
232 setUserName(userName);
233 }
234
235 Date createDate = (Date)attributes.get("createDate");
236
237 if (createDate != null) {
238 setCreateDate(createDate);
239 }
240
241 Date modifiedDate = (Date)attributes.get("modifiedDate");
242
243 if (modifiedDate != null) {
244 setModifiedDate(modifiedDate);
245 }
246
247 String name = (String)attributes.get("name");
248
249 if (name != null) {
250 setName(name);
251 }
252
253 String description = (String)attributes.get("description");
254
255 if (description != null) {
256 setDescription(description);
257 }
258
259 String settings = (String)attributes.get("settings");
260
261 if (settings != null) {
262 setSettings(settings);
263 }
264
265 Boolean active = (Boolean)attributes.get("active");
266
267 if (active != null) {
268 setActive(active);
269 }
270 }
271
272 @JSON
273 public String getUuid() {
274 if (_uuid == null) {
275 return StringPool.BLANK;
276 }
277 else {
278 return _uuid;
279 }
280 }
281
282 public void setUuid(String uuid) {
283 if (_originalUuid == null) {
284 _originalUuid = _uuid;
285 }
286
287 _uuid = uuid;
288 }
289
290 public String getOriginalUuid() {
291 return GetterUtil.getString(_originalUuid);
292 }
293
294 @JSON
295 public long getLayoutPrototypeId() {
296 return _layoutPrototypeId;
297 }
298
299 public void setLayoutPrototypeId(long layoutPrototypeId) {
300 _layoutPrototypeId = layoutPrototypeId;
301 }
302
303 @JSON
304 public long getCompanyId() {
305 return _companyId;
306 }
307
308 public void setCompanyId(long companyId) {
309 _columnBitmask |= COMPANYID_COLUMN_BITMASK;
310
311 if (!_setOriginalCompanyId) {
312 _setOriginalCompanyId = true;
313
314 _originalCompanyId = _companyId;
315 }
316
317 _companyId = companyId;
318 }
319
320 public long getOriginalCompanyId() {
321 return _originalCompanyId;
322 }
323
324 @JSON
325 public long getUserId() {
326 return _userId;
327 }
328
329 public void setUserId(long userId) {
330 _userId = userId;
331 }
332
333 public String getUserUuid() throws SystemException {
334 return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
335 }
336
337 public void setUserUuid(String userUuid) {
338 _userUuid = userUuid;
339 }
340
341 @JSON
342 public String getUserName() {
343 if (_userName == null) {
344 return StringPool.BLANK;
345 }
346 else {
347 return _userName;
348 }
349 }
350
351 public void setUserName(String userName) {
352 _userName = userName;
353 }
354
355 @JSON
356 public Date getCreateDate() {
357 return _createDate;
358 }
359
360 public void setCreateDate(Date createDate) {
361 _createDate = createDate;
362 }
363
364 @JSON
365 public Date getModifiedDate() {
366 return _modifiedDate;
367 }
368
369 public void setModifiedDate(Date modifiedDate) {
370 _modifiedDate = modifiedDate;
371 }
372
373 @JSON
374 public String getName() {
375 if (_name == null) {
376 return StringPool.BLANK;
377 }
378 else {
379 return _name;
380 }
381 }
382
383 public String getName(Locale locale) {
384 String languageId = LocaleUtil.toLanguageId(locale);
385
386 return getName(languageId);
387 }
388
389 public String getName(Locale locale, boolean useDefault) {
390 String languageId = LocaleUtil.toLanguageId(locale);
391
392 return getName(languageId, useDefault);
393 }
394
395 public String getName(String languageId) {
396 return LocalizationUtil.getLocalization(getName(), languageId);
397 }
398
399 public String getName(String languageId, boolean useDefault) {
400 return LocalizationUtil.getLocalization(getName(), languageId,
401 useDefault);
402 }
403
404 public String getNameCurrentLanguageId() {
405 return _nameCurrentLanguageId;
406 }
407
408 @JSON
409 public String getNameCurrentValue() {
410 Locale locale = getLocale(_nameCurrentLanguageId);
411
412 return getName(locale);
413 }
414
415 public Map<Locale, String> getNameMap() {
416 return LocalizationUtil.getLocalizationMap(getName());
417 }
418
419 public void setName(String name) {
420 _name = name;
421 }
422
423 public void setName(String name, Locale locale) {
424 setName(name, locale, LocaleUtil.getDefault());
425 }
426
427 public void setName(String name, Locale locale, Locale defaultLocale) {
428 String languageId = LocaleUtil.toLanguageId(locale);
429 String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);
430
431 if (Validator.isNotNull(name)) {
432 setName(LocalizationUtil.updateLocalization(getName(), "Name",
433 name, languageId, defaultLanguageId));
434 }
435 else {
436 setName(LocalizationUtil.removeLocalization(getName(), "Name",
437 languageId));
438 }
439 }
440
441 public void setNameCurrentLanguageId(String languageId) {
442 _nameCurrentLanguageId = languageId;
443 }
444
445 public void setNameMap(Map<Locale, String> nameMap) {
446 setNameMap(nameMap, LocaleUtil.getDefault());
447 }
448
449 public void setNameMap(Map<Locale, String> nameMap, Locale defaultLocale) {
450 if (nameMap == null) {
451 return;
452 }
453
454 setName(LocalizationUtil.updateLocalization(nameMap, getName(), "Name",
455 LocaleUtil.toLanguageId(defaultLocale)));
456 }
457
458 @JSON
459 public String getDescription() {
460 if (_description == null) {
461 return StringPool.BLANK;
462 }
463 else {
464 return _description;
465 }
466 }
467
468 public void setDescription(String description) {
469 _description = description;
470 }
471
472 @JSON
473 public String getSettings() {
474 if (_settings == null) {
475 return StringPool.BLANK;
476 }
477 else {
478 return _settings;
479 }
480 }
481
482 public void setSettings(String settings) {
483 _settings = settings;
484 }
485
486 @JSON
487 public boolean getActive() {
488 return _active;
489 }
490
491 public boolean isActive() {
492 return _active;
493 }
494
495 public void setActive(boolean active) {
496 _columnBitmask |= ACTIVE_COLUMN_BITMASK;
497
498 if (!_setOriginalActive) {
499 _setOriginalActive = true;
500
501 _originalActive = _active;
502 }
503
504 _active = active;
505 }
506
507 public boolean getOriginalActive() {
508 return _originalActive;
509 }
510
511 public long getColumnBitmask() {
512 return _columnBitmask;
513 }
514
515 @Override
516 public ExpandoBridge getExpandoBridge() {
517 return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
518 LayoutPrototype.class.getName(), getPrimaryKey());
519 }
520
521 @Override
522 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
523 ExpandoBridge expandoBridge = getExpandoBridge();
524
525 expandoBridge.setAttributes(serviceContext);
526 }
527
528 @SuppressWarnings("unused")
529 public void prepareLocalizedFieldsForImport(Locale defaultImportLocale)
530 throws LocaleException {
531 setName(getName(defaultImportLocale), defaultImportLocale,
532 defaultImportLocale);
533 }
534
535 @Override
536 public LayoutPrototype toEscapedModel() {
537 if (_escapedModel == null) {
538 _escapedModel = (LayoutPrototype)ProxyUtil.newProxyInstance(_classLoader,
539 _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
540 }
541
542 return _escapedModel;
543 }
544
545 @Override
546 public Object clone() {
547 LayoutPrototypeImpl layoutPrototypeImpl = new LayoutPrototypeImpl();
548
549 layoutPrototypeImpl.setUuid(getUuid());
550 layoutPrototypeImpl.setLayoutPrototypeId(getLayoutPrototypeId());
551 layoutPrototypeImpl.setCompanyId(getCompanyId());
552 layoutPrototypeImpl.setUserId(getUserId());
553 layoutPrototypeImpl.setUserName(getUserName());
554 layoutPrototypeImpl.setCreateDate(getCreateDate());
555 layoutPrototypeImpl.setModifiedDate(getModifiedDate());
556 layoutPrototypeImpl.setName(getName());
557 layoutPrototypeImpl.setDescription(getDescription());
558 layoutPrototypeImpl.setSettings(getSettings());
559 layoutPrototypeImpl.setActive(getActive());
560
561 layoutPrototypeImpl.resetOriginalValues();
562
563 return layoutPrototypeImpl;
564 }
565
566 public int compareTo(LayoutPrototype layoutPrototype) {
567 long primaryKey = layoutPrototype.getPrimaryKey();
568
569 if (getPrimaryKey() < primaryKey) {
570 return -1;
571 }
572 else if (getPrimaryKey() > primaryKey) {
573 return 1;
574 }
575 else {
576 return 0;
577 }
578 }
579
580 @Override
581 public boolean equals(Object obj) {
582 if (obj == null) {
583 return false;
584 }
585
586 LayoutPrototype layoutPrototype = null;
587
588 try {
589 layoutPrototype = (LayoutPrototype)obj;
590 }
591 catch (ClassCastException cce) {
592 return false;
593 }
594
595 long primaryKey = layoutPrototype.getPrimaryKey();
596
597 if (getPrimaryKey() == primaryKey) {
598 return true;
599 }
600 else {
601 return false;
602 }
603 }
604
605 @Override
606 public int hashCode() {
607 return (int)getPrimaryKey();
608 }
609
610 @Override
611 public void resetOriginalValues() {
612 LayoutPrototypeModelImpl layoutPrototypeModelImpl = this;
613
614 layoutPrototypeModelImpl._originalUuid = layoutPrototypeModelImpl._uuid;
615
616 layoutPrototypeModelImpl._originalCompanyId = layoutPrototypeModelImpl._companyId;
617
618 layoutPrototypeModelImpl._setOriginalCompanyId = false;
619
620 layoutPrototypeModelImpl._originalActive = layoutPrototypeModelImpl._active;
621
622 layoutPrototypeModelImpl._setOriginalActive = false;
623
624 layoutPrototypeModelImpl._columnBitmask = 0;
625 }
626
627 @Override
628 public CacheModel<LayoutPrototype> toCacheModel() {
629 LayoutPrototypeCacheModel layoutPrototypeCacheModel = new LayoutPrototypeCacheModel();
630
631 layoutPrototypeCacheModel.uuid = getUuid();
632
633 String uuid = layoutPrototypeCacheModel.uuid;
634
635 if ((uuid != null) && (uuid.length() == 0)) {
636 layoutPrototypeCacheModel.uuid = null;
637 }
638
639 layoutPrototypeCacheModel.layoutPrototypeId = getLayoutPrototypeId();
640
641 layoutPrototypeCacheModel.companyId = getCompanyId();
642
643 layoutPrototypeCacheModel.userId = getUserId();
644
645 layoutPrototypeCacheModel.userName = getUserName();
646
647 String userName = layoutPrototypeCacheModel.userName;
648
649 if ((userName != null) && (userName.length() == 0)) {
650 layoutPrototypeCacheModel.userName = null;
651 }
652
653 Date createDate = getCreateDate();
654
655 if (createDate != null) {
656 layoutPrototypeCacheModel.createDate = createDate.getTime();
657 }
658 else {
659 layoutPrototypeCacheModel.createDate = Long.MIN_VALUE;
660 }
661
662 Date modifiedDate = getModifiedDate();
663
664 if (modifiedDate != null) {
665 layoutPrototypeCacheModel.modifiedDate = modifiedDate.getTime();
666 }
667 else {
668 layoutPrototypeCacheModel.modifiedDate = Long.MIN_VALUE;
669 }
670
671 layoutPrototypeCacheModel.name = getName();
672
673 String name = layoutPrototypeCacheModel.name;
674
675 if ((name != null) && (name.length() == 0)) {
676 layoutPrototypeCacheModel.name = null;
677 }
678
679 layoutPrototypeCacheModel.description = getDescription();
680
681 String description = layoutPrototypeCacheModel.description;
682
683 if ((description != null) && (description.length() == 0)) {
684 layoutPrototypeCacheModel.description = null;
685 }
686
687 layoutPrototypeCacheModel.settings = getSettings();
688
689 String settings = layoutPrototypeCacheModel.settings;
690
691 if ((settings != null) && (settings.length() == 0)) {
692 layoutPrototypeCacheModel.settings = null;
693 }
694
695 layoutPrototypeCacheModel.active = getActive();
696
697 return layoutPrototypeCacheModel;
698 }
699
700 @Override
701 public String toString() {
702 StringBundler sb = new StringBundler(23);
703
704 sb.append("{uuid=");
705 sb.append(getUuid());
706 sb.append(", layoutPrototypeId=");
707 sb.append(getLayoutPrototypeId());
708 sb.append(", companyId=");
709 sb.append(getCompanyId());
710 sb.append(", userId=");
711 sb.append(getUserId());
712 sb.append(", userName=");
713 sb.append(getUserName());
714 sb.append(", createDate=");
715 sb.append(getCreateDate());
716 sb.append(", modifiedDate=");
717 sb.append(getModifiedDate());
718 sb.append(", name=");
719 sb.append(getName());
720 sb.append(", description=");
721 sb.append(getDescription());
722 sb.append(", settings=");
723 sb.append(getSettings());
724 sb.append(", active=");
725 sb.append(getActive());
726 sb.append("}");
727
728 return sb.toString();
729 }
730
731 public String toXmlString() {
732 StringBundler sb = new StringBundler(37);
733
734 sb.append("<model><model-name>");
735 sb.append("com.liferay.portal.model.LayoutPrototype");
736 sb.append("</model-name>");
737
738 sb.append(
739 "<column><column-name>uuid</column-name><column-value><![CDATA[");
740 sb.append(getUuid());
741 sb.append("]]></column-value></column>");
742 sb.append(
743 "<column><column-name>layoutPrototypeId</column-name><column-value><![CDATA[");
744 sb.append(getLayoutPrototypeId());
745 sb.append("]]></column-value></column>");
746 sb.append(
747 "<column><column-name>companyId</column-name><column-value><![CDATA[");
748 sb.append(getCompanyId());
749 sb.append("]]></column-value></column>");
750 sb.append(
751 "<column><column-name>userId</column-name><column-value><![CDATA[");
752 sb.append(getUserId());
753 sb.append("]]></column-value></column>");
754 sb.append(
755 "<column><column-name>userName</column-name><column-value><![CDATA[");
756 sb.append(getUserName());
757 sb.append("]]></column-value></column>");
758 sb.append(
759 "<column><column-name>createDate</column-name><column-value><![CDATA[");
760 sb.append(getCreateDate());
761 sb.append("]]></column-value></column>");
762 sb.append(
763 "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
764 sb.append(getModifiedDate());
765 sb.append("]]></column-value></column>");
766 sb.append(
767 "<column><column-name>name</column-name><column-value><![CDATA[");
768 sb.append(getName());
769 sb.append("]]></column-value></column>");
770 sb.append(
771 "<column><column-name>description</column-name><column-value><![CDATA[");
772 sb.append(getDescription());
773 sb.append("]]></column-value></column>");
774 sb.append(
775 "<column><column-name>settings</column-name><column-value><![CDATA[");
776 sb.append(getSettings());
777 sb.append("]]></column-value></column>");
778 sb.append(
779 "<column><column-name>active</column-name><column-value><![CDATA[");
780 sb.append(getActive());
781 sb.append("]]></column-value></column>");
782
783 sb.append("</model>");
784
785 return sb.toString();
786 }
787
788 private static ClassLoader _classLoader = LayoutPrototype.class.getClassLoader();
789 private static Class<?>[] _escapedModelInterfaces = new Class[] {
790 LayoutPrototype.class
791 };
792 private String _uuid;
793 private String _originalUuid;
794 private long _layoutPrototypeId;
795 private long _companyId;
796 private long _originalCompanyId;
797 private boolean _setOriginalCompanyId;
798 private long _userId;
799 private String _userUuid;
800 private String _userName;
801 private Date _createDate;
802 private Date _modifiedDate;
803 private String _name;
804 private String _nameCurrentLanguageId;
805 private String _description;
806 private String _settings;
807 private boolean _active;
808 private boolean _originalActive;
809 private boolean _setOriginalActive;
810 private long _columnBitmask;
811 private LayoutPrototype _escapedModel;
812 }