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