001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
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    /**
047     * The base model implementation for the LayoutPrototype service. Represents a row in the "LayoutPrototype" database table, with each column mapped to a property of this class.
048     *
049     * <p>
050     * This implementation and its corresponding interface {@link com.liferay.portal.model.LayoutPrototypeModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link LayoutPrototypeImpl}.
051     * </p>
052     *
053     * @author Brian Wing Shun Chan
054     * @see LayoutPrototypeImpl
055     * @see com.liferay.portal.model.LayoutPrototype
056     * @see com.liferay.portal.model.LayoutPrototypeModel
057     * @generated
058     */
059    @JSON(strict = true)
060    public class LayoutPrototypeModelImpl extends BaseModelImpl<LayoutPrototype>
061            implements LayoutPrototypeModel {
062            /*
063             * NOTE FOR DEVELOPERS:
064             *
065             * Never modify or reference this class directly. All methods that expect a layout prototype model instance should use the {@link com.liferay.portal.model.LayoutPrototype} interface instead.
066             */
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 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.LayoutPrototype"),
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.LayoutPrototype"),
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.LayoutPrototype"),
090                            true);
091            public static long ACTIVE_COLUMN_BITMASK = 1L;
092            public static long COMPANYID_COLUMN_BITMASK = 2L;
093            public static long UUID_COLUMN_BITMASK = 4L;
094    
095            /**
096             * Converts the soap model instance into a normal model instance.
097             *
098             * @param soapModel the soap model instance to convert
099             * @return the normal model instance
100             */
101            public static LayoutPrototype toModel(LayoutPrototypeSoap soapModel) {
102                    if (soapModel == null) {
103                            return null;
104                    }
105    
106                    LayoutPrototype model = new LayoutPrototypeImpl();
107    
108                    model.setUuid(soapModel.getUuid());
109                    model.setLayoutPrototypeId(soapModel.getLayoutPrototypeId());
110                    model.setCompanyId(soapModel.getCompanyId());
111                    model.setName(soapModel.getName());
112                    model.setDescription(soapModel.getDescription());
113                    model.setSettings(soapModel.getSettings());
114                    model.setActive(soapModel.getActive());
115    
116                    return model;
117            }
118    
119            /**
120             * Converts the soap model instances into normal model instances.
121             *
122             * @param soapModels the soap model instances to convert
123             * @return the normal model instances
124             */
125            public static List<LayoutPrototype> toModels(
126                    LayoutPrototypeSoap[] soapModels) {
127                    if (soapModels == null) {
128                            return null;
129                    }
130    
131                    List<LayoutPrototype> models = new ArrayList<LayoutPrototype>(soapModels.length);
132    
133                    for (LayoutPrototypeSoap soapModel : soapModels) {
134                            models.add(toModel(soapModel));
135                    }
136    
137                    return models;
138            }
139    
140            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
141                                    "lock.expiration.time.com.liferay.portal.model.LayoutPrototype"));
142    
143            public LayoutPrototypeModelImpl() {
144            }
145    
146            public long getPrimaryKey() {
147                    return _layoutPrototypeId;
148            }
149    
150            public void setPrimaryKey(long primaryKey) {
151                    setLayoutPrototypeId(primaryKey);
152            }
153    
154            public Serializable getPrimaryKeyObj() {
155                    return new Long(_layoutPrototypeId);
156            }
157    
158            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
159                    setPrimaryKey(((Long)primaryKeyObj).longValue());
160            }
161    
162            public Class<?> getModelClass() {
163                    return LayoutPrototype.class;
164            }
165    
166            public String getModelClassName() {
167                    return LayoutPrototype.class.getName();
168            }
169    
170            @Override
171            public Map<String, Object> getModelAttributes() {
172                    Map<String, Object> attributes = new HashMap<String, Object>();
173    
174                    attributes.put("uuid", getUuid());
175                    attributes.put("layoutPrototypeId", getLayoutPrototypeId());
176                    attributes.put("companyId", getCompanyId());
177                    attributes.put("name", getName());
178                    attributes.put("description", getDescription());
179                    attributes.put("settings", getSettings());
180                    attributes.put("active", getActive());
181    
182                    return attributes;
183            }
184    
185            @Override
186            public void setModelAttributes(Map<String, Object> attributes) {
187                    String uuid = (String)attributes.get("uuid");
188    
189                    if (uuid != null) {
190                            setUuid(uuid);
191                    }
192    
193                    Long layoutPrototypeId = (Long)attributes.get("layoutPrototypeId");
194    
195                    if (layoutPrototypeId != null) {
196                            setLayoutPrototypeId(layoutPrototypeId);
197                    }
198    
199                    Long companyId = (Long)attributes.get("companyId");
200    
201                    if (companyId != null) {
202                            setCompanyId(companyId);
203                    }
204    
205                    String name = (String)attributes.get("name");
206    
207                    if (name != null) {
208                            setName(name);
209                    }
210    
211                    String description = (String)attributes.get("description");
212    
213                    if (description != null) {
214                            setDescription(description);
215                    }
216    
217                    String settings = (String)attributes.get("settings");
218    
219                    if (settings != null) {
220                            setSettings(settings);
221                    }
222    
223                    Boolean active = (Boolean)attributes.get("active");
224    
225                    if (active != null) {
226                            setActive(active);
227                    }
228            }
229    
230            @JSON
231            public String getUuid() {
232                    if (_uuid == null) {
233                            return StringPool.BLANK;
234                    }
235                    else {
236                            return _uuid;
237                    }
238            }
239    
240            public void setUuid(String uuid) {
241                    if (_originalUuid == null) {
242                            _originalUuid = _uuid;
243                    }
244    
245                    _uuid = uuid;
246            }
247    
248            public String getOriginalUuid() {
249                    return GetterUtil.getString(_originalUuid);
250            }
251    
252            @JSON
253            public long getLayoutPrototypeId() {
254                    return _layoutPrototypeId;
255            }
256    
257            public void setLayoutPrototypeId(long layoutPrototypeId) {
258                    _layoutPrototypeId = layoutPrototypeId;
259            }
260    
261            @JSON
262            public long getCompanyId() {
263                    return _companyId;
264            }
265    
266            public void setCompanyId(long companyId) {
267                    _columnBitmask |= COMPANYID_COLUMN_BITMASK;
268    
269                    if (!_setOriginalCompanyId) {
270                            _setOriginalCompanyId = true;
271    
272                            _originalCompanyId = _companyId;
273                    }
274    
275                    _companyId = companyId;
276            }
277    
278            public long getOriginalCompanyId() {
279                    return _originalCompanyId;
280            }
281    
282            @JSON
283            public String getName() {
284                    if (_name == null) {
285                            return StringPool.BLANK;
286                    }
287                    else {
288                            return _name;
289                    }
290            }
291    
292            public String getName(Locale locale) {
293                    String languageId = LocaleUtil.toLanguageId(locale);
294    
295                    return getName(languageId);
296            }
297    
298            public String getName(Locale locale, boolean useDefault) {
299                    String languageId = LocaleUtil.toLanguageId(locale);
300    
301                    return getName(languageId, useDefault);
302            }
303    
304            public String getName(String languageId) {
305                    return LocalizationUtil.getLocalization(getName(), languageId);
306            }
307    
308            public String getName(String languageId, boolean useDefault) {
309                    return LocalizationUtil.getLocalization(getName(), languageId,
310                            useDefault);
311            }
312    
313            public String getNameCurrentLanguageId() {
314                    return _nameCurrentLanguageId;
315            }
316    
317            @JSON
318            public String getNameCurrentValue() {
319                    Locale locale = getLocale(_nameCurrentLanguageId);
320    
321                    return getName(locale);
322            }
323    
324            public Map<Locale, String> getNameMap() {
325                    return LocalizationUtil.getLocalizationMap(getName());
326            }
327    
328            public void setName(String name) {
329                    _name = name;
330            }
331    
332            public void setName(String name, Locale locale) {
333                    setName(name, locale, LocaleUtil.getDefault());
334            }
335    
336            public void setName(String name, Locale locale, Locale defaultLocale) {
337                    String languageId = LocaleUtil.toLanguageId(locale);
338                    String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);
339    
340                    if (Validator.isNotNull(name)) {
341                            setName(LocalizationUtil.updateLocalization(getName(), "Name",
342                                            name, languageId, defaultLanguageId));
343                    }
344                    else {
345                            setName(LocalizationUtil.removeLocalization(getName(), "Name",
346                                            languageId));
347                    }
348            }
349    
350            public void setNameCurrentLanguageId(String languageId) {
351                    _nameCurrentLanguageId = languageId;
352            }
353    
354            public void setNameMap(Map<Locale, String> nameMap) {
355                    setNameMap(nameMap, LocaleUtil.getDefault());
356            }
357    
358            public void setNameMap(Map<Locale, String> nameMap, Locale defaultLocale) {
359                    if (nameMap == null) {
360                            return;
361                    }
362    
363                    setName(LocalizationUtil.updateLocalization(nameMap, getName(), "Name",
364                                    LocaleUtil.toLanguageId(defaultLocale)));
365            }
366    
367            @JSON
368            public String getDescription() {
369                    if (_description == null) {
370                            return StringPool.BLANK;
371                    }
372                    else {
373                            return _description;
374                    }
375            }
376    
377            public void setDescription(String description) {
378                    _description = description;
379            }
380    
381            @JSON
382            public String getSettings() {
383                    if (_settings == null) {
384                            return StringPool.BLANK;
385                    }
386                    else {
387                            return _settings;
388                    }
389            }
390    
391            public void setSettings(String settings) {
392                    _settings = settings;
393            }
394    
395            @JSON
396            public boolean getActive() {
397                    return _active;
398            }
399    
400            public boolean isActive() {
401                    return _active;
402            }
403    
404            public void setActive(boolean active) {
405                    _columnBitmask |= ACTIVE_COLUMN_BITMASK;
406    
407                    if (!_setOriginalActive) {
408                            _setOriginalActive = true;
409    
410                            _originalActive = _active;
411                    }
412    
413                    _active = active;
414            }
415    
416            public boolean getOriginalActive() {
417                    return _originalActive;
418            }
419    
420            public long getColumnBitmask() {
421                    return _columnBitmask;
422            }
423    
424            @Override
425            public ExpandoBridge getExpandoBridge() {
426                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
427                            LayoutPrototype.class.getName(), getPrimaryKey());
428            }
429    
430            @Override
431            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
432                    ExpandoBridge expandoBridge = getExpandoBridge();
433    
434                    expandoBridge.setAttributes(serviceContext);
435            }
436    
437            @SuppressWarnings("unused")
438            public void prepareLocalizedFieldsForImport(Locale defaultImportLocale)
439                    throws LocaleException {
440                    setName(getName(defaultImportLocale), defaultImportLocale,
441                            defaultImportLocale);
442            }
443    
444            @Override
445            public LayoutPrototype toEscapedModel() {
446                    if (_escapedModelProxy == null) {
447                            _escapedModelProxy = (LayoutPrototype)ProxyUtil.newProxyInstance(_classLoader,
448                                            _escapedModelProxyInterfaces,
449                                            new AutoEscapeBeanHandler(this));
450                    }
451    
452                    return _escapedModelProxy;
453            }
454    
455            @Override
456            public Object clone() {
457                    LayoutPrototypeImpl layoutPrototypeImpl = new LayoutPrototypeImpl();
458    
459                    layoutPrototypeImpl.setUuid(getUuid());
460                    layoutPrototypeImpl.setLayoutPrototypeId(getLayoutPrototypeId());
461                    layoutPrototypeImpl.setCompanyId(getCompanyId());
462                    layoutPrototypeImpl.setName(getName());
463                    layoutPrototypeImpl.setDescription(getDescription());
464                    layoutPrototypeImpl.setSettings(getSettings());
465                    layoutPrototypeImpl.setActive(getActive());
466    
467                    layoutPrototypeImpl.resetOriginalValues();
468    
469                    return layoutPrototypeImpl;
470            }
471    
472            public int compareTo(LayoutPrototype layoutPrototype) {
473                    long primaryKey = layoutPrototype.getPrimaryKey();
474    
475                    if (getPrimaryKey() < primaryKey) {
476                            return -1;
477                    }
478                    else if (getPrimaryKey() > primaryKey) {
479                            return 1;
480                    }
481                    else {
482                            return 0;
483                    }
484            }
485    
486            @Override
487            public boolean equals(Object obj) {
488                    if (obj == null) {
489                            return false;
490                    }
491    
492                    LayoutPrototype layoutPrototype = null;
493    
494                    try {
495                            layoutPrototype = (LayoutPrototype)obj;
496                    }
497                    catch (ClassCastException cce) {
498                            return false;
499                    }
500    
501                    long primaryKey = layoutPrototype.getPrimaryKey();
502    
503                    if (getPrimaryKey() == primaryKey) {
504                            return true;
505                    }
506                    else {
507                            return false;
508                    }
509            }
510    
511            @Override
512            public int hashCode() {
513                    return (int)getPrimaryKey();
514            }
515    
516            @Override
517            public void resetOriginalValues() {
518                    LayoutPrototypeModelImpl layoutPrototypeModelImpl = this;
519    
520                    layoutPrototypeModelImpl._originalUuid = layoutPrototypeModelImpl._uuid;
521    
522                    layoutPrototypeModelImpl._originalCompanyId = layoutPrototypeModelImpl._companyId;
523    
524                    layoutPrototypeModelImpl._setOriginalCompanyId = false;
525    
526                    layoutPrototypeModelImpl._originalActive = layoutPrototypeModelImpl._active;
527    
528                    layoutPrototypeModelImpl._setOriginalActive = false;
529    
530                    layoutPrototypeModelImpl._columnBitmask = 0;
531            }
532    
533            @Override
534            public CacheModel<LayoutPrototype> toCacheModel() {
535                    LayoutPrototypeCacheModel layoutPrototypeCacheModel = new LayoutPrototypeCacheModel();
536    
537                    layoutPrototypeCacheModel.uuid = getUuid();
538    
539                    String uuid = layoutPrototypeCacheModel.uuid;
540    
541                    if ((uuid != null) && (uuid.length() == 0)) {
542                            layoutPrototypeCacheModel.uuid = null;
543                    }
544    
545                    layoutPrototypeCacheModel.layoutPrototypeId = getLayoutPrototypeId();
546    
547                    layoutPrototypeCacheModel.companyId = getCompanyId();
548    
549                    layoutPrototypeCacheModel.name = getName();
550    
551                    String name = layoutPrototypeCacheModel.name;
552    
553                    if ((name != null) && (name.length() == 0)) {
554                            layoutPrototypeCacheModel.name = null;
555                    }
556    
557                    layoutPrototypeCacheModel.description = getDescription();
558    
559                    String description = layoutPrototypeCacheModel.description;
560    
561                    if ((description != null) && (description.length() == 0)) {
562                            layoutPrototypeCacheModel.description = null;
563                    }
564    
565                    layoutPrototypeCacheModel.settings = getSettings();
566    
567                    String settings = layoutPrototypeCacheModel.settings;
568    
569                    if ((settings != null) && (settings.length() == 0)) {
570                            layoutPrototypeCacheModel.settings = null;
571                    }
572    
573                    layoutPrototypeCacheModel.active = getActive();
574    
575                    return layoutPrototypeCacheModel;
576            }
577    
578            @Override
579            public String toString() {
580                    StringBundler sb = new StringBundler(15);
581    
582                    sb.append("{uuid=");
583                    sb.append(getUuid());
584                    sb.append(", layoutPrototypeId=");
585                    sb.append(getLayoutPrototypeId());
586                    sb.append(", companyId=");
587                    sb.append(getCompanyId());
588                    sb.append(", name=");
589                    sb.append(getName());
590                    sb.append(", description=");
591                    sb.append(getDescription());
592                    sb.append(", settings=");
593                    sb.append(getSettings());
594                    sb.append(", active=");
595                    sb.append(getActive());
596                    sb.append("}");
597    
598                    return sb.toString();
599            }
600    
601            public String toXmlString() {
602                    StringBundler sb = new StringBundler(25);
603    
604                    sb.append("<model><model-name>");
605                    sb.append("com.liferay.portal.model.LayoutPrototype");
606                    sb.append("</model-name>");
607    
608                    sb.append(
609                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
610                    sb.append(getUuid());
611                    sb.append("]]></column-value></column>");
612                    sb.append(
613                            "<column><column-name>layoutPrototypeId</column-name><column-value><![CDATA[");
614                    sb.append(getLayoutPrototypeId());
615                    sb.append("]]></column-value></column>");
616                    sb.append(
617                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
618                    sb.append(getCompanyId());
619                    sb.append("]]></column-value></column>");
620                    sb.append(
621                            "<column><column-name>name</column-name><column-value><![CDATA[");
622                    sb.append(getName());
623                    sb.append("]]></column-value></column>");
624                    sb.append(
625                            "<column><column-name>description</column-name><column-value><![CDATA[");
626                    sb.append(getDescription());
627                    sb.append("]]></column-value></column>");
628                    sb.append(
629                            "<column><column-name>settings</column-name><column-value><![CDATA[");
630                    sb.append(getSettings());
631                    sb.append("]]></column-value></column>");
632                    sb.append(
633                            "<column><column-name>active</column-name><column-value><![CDATA[");
634                    sb.append(getActive());
635                    sb.append("]]></column-value></column>");
636    
637                    sb.append("</model>");
638    
639                    return sb.toString();
640            }
641    
642            private static ClassLoader _classLoader = LayoutPrototype.class.getClassLoader();
643            private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
644                            LayoutPrototype.class
645                    };
646            private String _uuid;
647            private String _originalUuid;
648            private long _layoutPrototypeId;
649            private long _companyId;
650            private long _originalCompanyId;
651            private boolean _setOriginalCompanyId;
652            private String _name;
653            private String _nameCurrentLanguageId;
654            private String _description;
655            private String _settings;
656            private boolean _active;
657            private boolean _originalActive;
658            private boolean _setOriginalActive;
659            private long _columnBitmask;
660            private LayoutPrototype _escapedModelProxy;
661    }