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.json.JSON;
020 import com.liferay.portal.kernel.language.LanguageUtil;
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
034 import com.liferay.portlet.expando.model.ExpandoBridge;
035 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
036
037 import java.io.Serializable;
038
039 import java.sql.Types;
040
041 import java.util.ArrayList;
042 import java.util.HashMap;
043 import java.util.List;
044 import java.util.Locale;
045 import java.util.Map;
046
047
060 @JSON(strict = true)
061 public class LayoutPrototypeModelImpl extends BaseModelImpl<LayoutPrototype>
062 implements LayoutPrototypeModel {
063
068 public static final String TABLE_NAME = "LayoutPrototype";
069 public static final Object[][] TABLE_COLUMNS = {
070 { "uuid_", Types.VARCHAR },
071 { "layoutPrototypeId", Types.BIGINT },
072 { "companyId", Types.BIGINT },
073 { "name", Types.VARCHAR },
074 { "description", Types.VARCHAR },
075 { "settings_", Types.VARCHAR },
076 { "active_", Types.BOOLEAN }
077 };
078 public static final String TABLE_SQL_CREATE = "create table LayoutPrototype (uuid_ VARCHAR(75) null,layoutPrototypeId LONG not null primary key,companyId LONG,name STRING null,description STRING null,settings_ STRING null,active_ BOOLEAN)";
079 public static final String TABLE_SQL_DROP = "drop table LayoutPrototype";
080 public static final String DATA_SOURCE = "liferayDataSource";
081 public static final String SESSION_FACTORY = "liferaySessionFactory";
082 public static final String TX_MANAGER = "liferayTransactionManager";
083 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
084 "value.object.entity.cache.enabled.com.liferay.portal.model.LayoutPrototype"),
085 true);
086 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
087 "value.object.finder.cache.enabled.com.liferay.portal.model.LayoutPrototype"),
088 true);
089 public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
090 "value.object.column.bitmask.enabled.com.liferay.portal.model.LayoutPrototype"),
091 true);
092 public static long ACTIVE_COLUMN_BITMASK = 1L;
093 public static long COMPANYID_COLUMN_BITMASK = 2L;
094 public static long UUID_COLUMN_BITMASK = 4L;
095
096
102 public static LayoutPrototype toModel(LayoutPrototypeSoap soapModel) {
103 if (soapModel == null) {
104 return null;
105 }
106
107 LayoutPrototype model = new LayoutPrototypeImpl();
108
109 model.setUuid(soapModel.getUuid());
110 model.setLayoutPrototypeId(soapModel.getLayoutPrototypeId());
111 model.setCompanyId(soapModel.getCompanyId());
112 model.setName(soapModel.getName());
113 model.setDescription(soapModel.getDescription());
114 model.setSettings(soapModel.getSettings());
115 model.setActive(soapModel.getActive());
116
117 return model;
118 }
119
120
126 public static List<LayoutPrototype> toModels(
127 LayoutPrototypeSoap[] soapModels) {
128 if (soapModels == null) {
129 return null;
130 }
131
132 List<LayoutPrototype> models = new ArrayList<LayoutPrototype>(soapModels.length);
133
134 for (LayoutPrototypeSoap soapModel : soapModels) {
135 models.add(toModel(soapModel));
136 }
137
138 return models;
139 }
140
141 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
142 "lock.expiration.time.com.liferay.portal.model.LayoutPrototype"));
143
144 public LayoutPrototypeModelImpl() {
145 }
146
147 public long getPrimaryKey() {
148 return _layoutPrototypeId;
149 }
150
151 public void setPrimaryKey(long primaryKey) {
152 setLayoutPrototypeId(primaryKey);
153 }
154
155 public Serializable getPrimaryKeyObj() {
156 return new Long(_layoutPrototypeId);
157 }
158
159 public void setPrimaryKeyObj(Serializable primaryKeyObj) {
160 setPrimaryKey(((Long)primaryKeyObj).longValue());
161 }
162
163 public Class<?> getModelClass() {
164 return LayoutPrototype.class;
165 }
166
167 public String getModelClassName() {
168 return LayoutPrototype.class.getName();
169 }
170
171 @Override
172 public Map<String, Object> getModelAttributes() {
173 Map<String, Object> attributes = new HashMap<String, Object>();
174
175 attributes.put("uuid", getUuid());
176 attributes.put("layoutPrototypeId", getLayoutPrototypeId());
177 attributes.put("companyId", getCompanyId());
178 attributes.put("name", getName());
179 attributes.put("description", getDescription());
180 attributes.put("settings", getSettings());
181 attributes.put("active", getActive());
182
183 return attributes;
184 }
185
186 @Override
187 public void setModelAttributes(Map<String, Object> attributes) {
188 String uuid = (String)attributes.get("uuid");
189
190 if (uuid != null) {
191 setUuid(uuid);
192 }
193
194 Long layoutPrototypeId = (Long)attributes.get("layoutPrototypeId");
195
196 if (layoutPrototypeId != null) {
197 setLayoutPrototypeId(layoutPrototypeId);
198 }
199
200 Long companyId = (Long)attributes.get("companyId");
201
202 if (companyId != null) {
203 setCompanyId(companyId);
204 }
205
206 String name = (String)attributes.get("name");
207
208 if (name != null) {
209 setName(name);
210 }
211
212 String description = (String)attributes.get("description");
213
214 if (description != null) {
215 setDescription(description);
216 }
217
218 String settings = (String)attributes.get("settings");
219
220 if (settings != null) {
221 setSettings(settings);
222 }
223
224 Boolean active = (Boolean)attributes.get("active");
225
226 if (active != null) {
227 setActive(active);
228 }
229 }
230
231 @JSON
232 public String getUuid() {
233 if (_uuid == null) {
234 return StringPool.BLANK;
235 }
236 else {
237 return _uuid;
238 }
239 }
240
241 public void setUuid(String uuid) {
242 if (_originalUuid == null) {
243 _originalUuid = _uuid;
244 }
245
246 _uuid = uuid;
247 }
248
249 public String getOriginalUuid() {
250 return GetterUtil.getString(_originalUuid);
251 }
252
253 @JSON
254 public long getLayoutPrototypeId() {
255 return _layoutPrototypeId;
256 }
257
258 public void setLayoutPrototypeId(long layoutPrototypeId) {
259 _layoutPrototypeId = layoutPrototypeId;
260 }
261
262 @JSON
263 public long getCompanyId() {
264 return _companyId;
265 }
266
267 public void setCompanyId(long companyId) {
268 _columnBitmask |= COMPANYID_COLUMN_BITMASK;
269
270 if (!_setOriginalCompanyId) {
271 _setOriginalCompanyId = true;
272
273 _originalCompanyId = _companyId;
274 }
275
276 _companyId = companyId;
277 }
278
279 public long getOriginalCompanyId() {
280 return _originalCompanyId;
281 }
282
283 @JSON
284 public String getName() {
285 if (_name == null) {
286 return StringPool.BLANK;
287 }
288 else {
289 return _name;
290 }
291 }
292
293 public String getName(Locale locale) {
294 String languageId = LocaleUtil.toLanguageId(locale);
295
296 return getName(languageId);
297 }
298
299 public String getName(Locale locale, boolean useDefault) {
300 String languageId = LocaleUtil.toLanguageId(locale);
301
302 return getName(languageId, useDefault);
303 }
304
305 public String getName(String languageId) {
306 return LocalizationUtil.getLocalization(getName(), languageId);
307 }
308
309 public String getName(String languageId, boolean useDefault) {
310 return LocalizationUtil.getLocalization(getName(), languageId,
311 useDefault);
312 }
313
314 public String getNameCurrentLanguageId() {
315 return _nameCurrentLanguageId;
316 }
317
318 @JSON
319 public String getNameCurrentValue() {
320 Locale locale = getLocale(_nameCurrentLanguageId);
321
322 return getName(locale);
323 }
324
325 public Map<Locale, String> getNameMap() {
326 return LocalizationUtil.getLocalizationMap(getName());
327 }
328
329 public void setName(String name) {
330 _name = name;
331 }
332
333 public void setName(String name, Locale locale) {
334 setName(name, locale, LocaleUtil.getDefault());
335 }
336
337 public void setName(String name, Locale locale, Locale defaultLocale) {
338 String languageId = LocaleUtil.toLanguageId(locale);
339 String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);
340
341 if (Validator.isNotNull(name)) {
342 setName(LocalizationUtil.updateLocalization(getName(), "Name",
343 name, languageId, defaultLanguageId));
344 }
345 else {
346 setName(LocalizationUtil.removeLocalization(getName(), "Name",
347 languageId));
348 }
349 }
350
351 public void setNameCurrentLanguageId(String languageId) {
352 _nameCurrentLanguageId = languageId;
353 }
354
355 public void setNameMap(Map<Locale, String> nameMap) {
356 setNameMap(nameMap, LocaleUtil.getDefault());
357 }
358
359 public void setNameMap(Map<Locale, String> nameMap, Locale defaultLocale) {
360 if (nameMap == null) {
361 return;
362 }
363
364 Locale[] locales = LanguageUtil.getAvailableLocales();
365
366 for (Locale locale : locales) {
367 String name = nameMap.get(locale);
368
369 setName(name, locale, defaultLocale);
370 }
371 }
372
373 @JSON
374 public String getDescription() {
375 if (_description == null) {
376 return StringPool.BLANK;
377 }
378 else {
379 return _description;
380 }
381 }
382
383 public void setDescription(String description) {
384 _description = description;
385 }
386
387 @JSON
388 public String getSettings() {
389 if (_settings == null) {
390 return StringPool.BLANK;
391 }
392 else {
393 return _settings;
394 }
395 }
396
397 public void setSettings(String settings) {
398 _settings = settings;
399 }
400
401 @JSON
402 public boolean getActive() {
403 return _active;
404 }
405
406 public boolean isActive() {
407 return _active;
408 }
409
410 public void setActive(boolean active) {
411 _columnBitmask |= ACTIVE_COLUMN_BITMASK;
412
413 if (!_setOriginalActive) {
414 _setOriginalActive = true;
415
416 _originalActive = _active;
417 }
418
419 _active = active;
420 }
421
422 public boolean getOriginalActive() {
423 return _originalActive;
424 }
425
426 public long getColumnBitmask() {
427 return _columnBitmask;
428 }
429
430 @Override
431 public ExpandoBridge getExpandoBridge() {
432 return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
433 LayoutPrototype.class.getName(), getPrimaryKey());
434 }
435
436 @Override
437 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
438 ExpandoBridge expandoBridge = getExpandoBridge();
439
440 expandoBridge.setAttributes(serviceContext);
441 }
442
443 @SuppressWarnings("unused")
444 public void prepareLocalizedFieldsForImport(Locale defaultImportLocale)
445 throws LocaleException {
446 setName(getName(defaultImportLocale), defaultImportLocale,
447 defaultImportLocale);
448 }
449
450 @Override
451 public LayoutPrototype toEscapedModel() {
452 if (_escapedModel == null) {
453 _escapedModel = (LayoutPrototype)ProxyUtil.newProxyInstance(_classLoader,
454 _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
455 }
456
457 return _escapedModel;
458 }
459
460 public LayoutPrototype toUnescapedModel() {
461 return (LayoutPrototype)this;
462 }
463
464 @Override
465 public Object clone() {
466 LayoutPrototypeImpl layoutPrototypeImpl = new LayoutPrototypeImpl();
467
468 layoutPrototypeImpl.setUuid(getUuid());
469 layoutPrototypeImpl.setLayoutPrototypeId(getLayoutPrototypeId());
470 layoutPrototypeImpl.setCompanyId(getCompanyId());
471 layoutPrototypeImpl.setName(getName());
472 layoutPrototypeImpl.setDescription(getDescription());
473 layoutPrototypeImpl.setSettings(getSettings());
474 layoutPrototypeImpl.setActive(getActive());
475
476 layoutPrototypeImpl.resetOriginalValues();
477
478 return layoutPrototypeImpl;
479 }
480
481 public int compareTo(LayoutPrototype layoutPrototype) {
482 long primaryKey = layoutPrototype.getPrimaryKey();
483
484 if (getPrimaryKey() < primaryKey) {
485 return -1;
486 }
487 else if (getPrimaryKey() > primaryKey) {
488 return 1;
489 }
490 else {
491 return 0;
492 }
493 }
494
495 @Override
496 public boolean equals(Object obj) {
497 if (this == obj) {
498 return true;
499 }
500
501 if (!(obj instanceof LayoutPrototype)) {
502 return false;
503 }
504
505 LayoutPrototype layoutPrototype = (LayoutPrototype)obj;
506
507 long primaryKey = layoutPrototype.getPrimaryKey();
508
509 if (getPrimaryKey() == primaryKey) {
510 return true;
511 }
512 else {
513 return false;
514 }
515 }
516
517 @Override
518 public int hashCode() {
519 return (int)getPrimaryKey();
520 }
521
522 @Override
523 public void resetOriginalValues() {
524 LayoutPrototypeModelImpl layoutPrototypeModelImpl = this;
525
526 layoutPrototypeModelImpl._originalUuid = layoutPrototypeModelImpl._uuid;
527
528 layoutPrototypeModelImpl._originalCompanyId = layoutPrototypeModelImpl._companyId;
529
530 layoutPrototypeModelImpl._setOriginalCompanyId = false;
531
532 layoutPrototypeModelImpl._originalActive = layoutPrototypeModelImpl._active;
533
534 layoutPrototypeModelImpl._setOriginalActive = false;
535
536 layoutPrototypeModelImpl._columnBitmask = 0;
537 }
538
539 @Override
540 public CacheModel<LayoutPrototype> toCacheModel() {
541 LayoutPrototypeCacheModel layoutPrototypeCacheModel = new LayoutPrototypeCacheModel();
542
543 layoutPrototypeCacheModel.uuid = getUuid();
544
545 String uuid = layoutPrototypeCacheModel.uuid;
546
547 if ((uuid != null) && (uuid.length() == 0)) {
548 layoutPrototypeCacheModel.uuid = null;
549 }
550
551 layoutPrototypeCacheModel.layoutPrototypeId = getLayoutPrototypeId();
552
553 layoutPrototypeCacheModel.companyId = getCompanyId();
554
555 layoutPrototypeCacheModel.name = getName();
556
557 String name = layoutPrototypeCacheModel.name;
558
559 if ((name != null) && (name.length() == 0)) {
560 layoutPrototypeCacheModel.name = null;
561 }
562
563 layoutPrototypeCacheModel.description = getDescription();
564
565 String description = layoutPrototypeCacheModel.description;
566
567 if ((description != null) && (description.length() == 0)) {
568 layoutPrototypeCacheModel.description = null;
569 }
570
571 layoutPrototypeCacheModel.settings = getSettings();
572
573 String settings = layoutPrototypeCacheModel.settings;
574
575 if ((settings != null) && (settings.length() == 0)) {
576 layoutPrototypeCacheModel.settings = null;
577 }
578
579 layoutPrototypeCacheModel.active = getActive();
580
581 return layoutPrototypeCacheModel;
582 }
583
584 @Override
585 public String toString() {
586 StringBundler sb = new StringBundler(15);
587
588 sb.append("{uuid=");
589 sb.append(getUuid());
590 sb.append(", layoutPrototypeId=");
591 sb.append(getLayoutPrototypeId());
592 sb.append(", companyId=");
593 sb.append(getCompanyId());
594 sb.append(", name=");
595 sb.append(getName());
596 sb.append(", description=");
597 sb.append(getDescription());
598 sb.append(", settings=");
599 sb.append(getSettings());
600 sb.append(", active=");
601 sb.append(getActive());
602 sb.append("}");
603
604 return sb.toString();
605 }
606
607 public String toXmlString() {
608 StringBundler sb = new StringBundler(25);
609
610 sb.append("<model><model-name>");
611 sb.append("com.liferay.portal.model.LayoutPrototype");
612 sb.append("</model-name>");
613
614 sb.append(
615 "<column><column-name>uuid</column-name><column-value><![CDATA[");
616 sb.append(getUuid());
617 sb.append("]]></column-value></column>");
618 sb.append(
619 "<column><column-name>layoutPrototypeId</column-name><column-value><![CDATA[");
620 sb.append(getLayoutPrototypeId());
621 sb.append("]]></column-value></column>");
622 sb.append(
623 "<column><column-name>companyId</column-name><column-value><![CDATA[");
624 sb.append(getCompanyId());
625 sb.append("]]></column-value></column>");
626 sb.append(
627 "<column><column-name>name</column-name><column-value><![CDATA[");
628 sb.append(getName());
629 sb.append("]]></column-value></column>");
630 sb.append(
631 "<column><column-name>description</column-name><column-value><![CDATA[");
632 sb.append(getDescription());
633 sb.append("]]></column-value></column>");
634 sb.append(
635 "<column><column-name>settings</column-name><column-value><![CDATA[");
636 sb.append(getSettings());
637 sb.append("]]></column-value></column>");
638 sb.append(
639 "<column><column-name>active</column-name><column-value><![CDATA[");
640 sb.append(getActive());
641 sb.append("]]></column-value></column>");
642
643 sb.append("</model>");
644
645 return sb.toString();
646 }
647
648 private static ClassLoader _classLoader = LayoutPrototype.class.getClassLoader();
649 private static Class<?>[] _escapedModelInterfaces = new Class[] {
650 LayoutPrototype.class
651 };
652 private String _uuid;
653 private String _originalUuid;
654 private long _layoutPrototypeId;
655 private long _companyId;
656 private long _originalCompanyId;
657 private boolean _setOriginalCompanyId;
658 private String _name;
659 private String _nameCurrentLanguageId;
660 private String _description;
661 private String _settings;
662 private boolean _active;
663 private boolean _originalActive;
664 private boolean _setOriginalActive;
665 private long _columnBitmask;
666 private LayoutPrototype _escapedModel;
667 }