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