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.portlet.dynamicdatamapping.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.impl.BaseModelImpl;
030    import com.liferay.portal.service.ServiceContext;
031    import com.liferay.portal.util.PortalUtil;
032    
033    import com.liferay.portlet.dynamicdatamapping.model.DDMTemplate;
034    import com.liferay.portlet.dynamicdatamapping.model.DDMTemplateModel;
035    import com.liferay.portlet.dynamicdatamapping.model.DDMTemplateSoap;
036    import com.liferay.portlet.expando.model.ExpandoBridge;
037    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
038    
039    import java.io.Serializable;
040    
041    import java.sql.Types;
042    
043    import java.util.ArrayList;
044    import java.util.Date;
045    import java.util.HashMap;
046    import java.util.List;
047    import java.util.Locale;
048    import java.util.Map;
049    
050    /**
051     * The base model implementation for the DDMTemplate service. Represents a row in the "DDMTemplate" database table, with each column mapped to a property of this class.
052     *
053     * <p>
054     * This implementation and its corresponding interface {@link com.liferay.portlet.dynamicdatamapping.model.DDMTemplateModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link DDMTemplateImpl}.
055     * </p>
056     *
057     * @author Brian Wing Shun Chan
058     * @see DDMTemplateImpl
059     * @see com.liferay.portlet.dynamicdatamapping.model.DDMTemplate
060     * @see com.liferay.portlet.dynamicdatamapping.model.DDMTemplateModel
061     * @generated
062     */
063    @JSON(strict = true)
064    public class DDMTemplateModelImpl extends BaseModelImpl<DDMTemplate>
065            implements DDMTemplateModel {
066            /*
067             * NOTE FOR DEVELOPERS:
068             *
069             * Never modify or reference this class directly. All methods that expect a d d m template model instance should use the {@link com.liferay.portlet.dynamicdatamapping.model.DDMTemplate} interface instead.
070             */
071            public static final String TABLE_NAME = "DDMTemplate";
072            public static final Object[][] TABLE_COLUMNS = {
073                            { "uuid_", Types.VARCHAR },
074                            { "templateId", Types.BIGINT },
075                            { "groupId", Types.BIGINT },
076                            { "companyId", Types.BIGINT },
077                            { "userId", Types.BIGINT },
078                            { "userName", Types.VARCHAR },
079                            { "createDate", Types.TIMESTAMP },
080                            { "modifiedDate", Types.TIMESTAMP },
081                            { "classNameId", Types.BIGINT },
082                            { "classPK", Types.BIGINT },
083                            { "templateKey", Types.VARCHAR },
084                            { "name", Types.VARCHAR },
085                            { "description", Types.VARCHAR },
086                            { "type_", Types.VARCHAR },
087                            { "mode_", Types.VARCHAR },
088                            { "language", Types.VARCHAR },
089                            { "script", Types.CLOB },
090                            { "cacheable", Types.BOOLEAN },
091                            { "smallImage", Types.BOOLEAN },
092                            { "smallImageId", Types.BIGINT },
093                            { "smallImageURL", Types.VARCHAR }
094                    };
095            public static final String TABLE_SQL_CREATE = "create table DDMTemplate (uuid_ VARCHAR(75) null,templateId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,classNameId LONG,classPK LONG,templateKey VARCHAR(75) null,name STRING null,description STRING null,type_ VARCHAR(75) null,mode_ VARCHAR(75) null,language VARCHAR(75) null,script TEXT null,cacheable BOOLEAN,smallImage BOOLEAN,smallImageId LONG,smallImageURL VARCHAR(75) null)";
096            public static final String TABLE_SQL_DROP = "drop table DDMTemplate";
097            public static final String ORDER_BY_JPQL = " ORDER BY ddmTemplate.templateId ASC";
098            public static final String ORDER_BY_SQL = " ORDER BY DDMTemplate.templateId ASC";
099            public static final String DATA_SOURCE = "liferayDataSource";
100            public static final String SESSION_FACTORY = "liferaySessionFactory";
101            public static final String TX_MANAGER = "liferayTransactionManager";
102            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
103                                    "value.object.entity.cache.enabled.com.liferay.portlet.dynamicdatamapping.model.DDMTemplate"),
104                            true);
105            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
106                                    "value.object.finder.cache.enabled.com.liferay.portlet.dynamicdatamapping.model.DDMTemplate"),
107                            true);
108            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
109                                    "value.object.column.bitmask.enabled.com.liferay.portlet.dynamicdatamapping.model.DDMTemplate"),
110                            true);
111            public static long CLASSNAMEID_COLUMN_BITMASK = 1L;
112            public static long CLASSPK_COLUMN_BITMASK = 2L;
113            public static long COMPANYID_COLUMN_BITMASK = 4L;
114            public static long GROUPID_COLUMN_BITMASK = 8L;
115            public static long LANGUAGE_COLUMN_BITMASK = 16L;
116            public static long MODE_COLUMN_BITMASK = 32L;
117            public static long TEMPLATEKEY_COLUMN_BITMASK = 64L;
118            public static long TYPE_COLUMN_BITMASK = 128L;
119            public static long UUID_COLUMN_BITMASK = 256L;
120            public static long TEMPLATEID_COLUMN_BITMASK = 512L;
121    
122            /**
123             * Converts the soap model instance into a normal model instance.
124             *
125             * @param soapModel the soap model instance to convert
126             * @return the normal model instance
127             */
128            public static DDMTemplate toModel(DDMTemplateSoap soapModel) {
129                    if (soapModel == null) {
130                            return null;
131                    }
132    
133                    DDMTemplate model = new DDMTemplateImpl();
134    
135                    model.setUuid(soapModel.getUuid());
136                    model.setTemplateId(soapModel.getTemplateId());
137                    model.setGroupId(soapModel.getGroupId());
138                    model.setCompanyId(soapModel.getCompanyId());
139                    model.setUserId(soapModel.getUserId());
140                    model.setUserName(soapModel.getUserName());
141                    model.setCreateDate(soapModel.getCreateDate());
142                    model.setModifiedDate(soapModel.getModifiedDate());
143                    model.setClassNameId(soapModel.getClassNameId());
144                    model.setClassPK(soapModel.getClassPK());
145                    model.setTemplateKey(soapModel.getTemplateKey());
146                    model.setName(soapModel.getName());
147                    model.setDescription(soapModel.getDescription());
148                    model.setType(soapModel.getType());
149                    model.setMode(soapModel.getMode());
150                    model.setLanguage(soapModel.getLanguage());
151                    model.setScript(soapModel.getScript());
152                    model.setCacheable(soapModel.getCacheable());
153                    model.setSmallImage(soapModel.getSmallImage());
154                    model.setSmallImageId(soapModel.getSmallImageId());
155                    model.setSmallImageURL(soapModel.getSmallImageURL());
156    
157                    return model;
158            }
159    
160            /**
161             * Converts the soap model instances into normal model instances.
162             *
163             * @param soapModels the soap model instances to convert
164             * @return the normal model instances
165             */
166            public static List<DDMTemplate> toModels(DDMTemplateSoap[] soapModels) {
167                    if (soapModels == null) {
168                            return null;
169                    }
170    
171                    List<DDMTemplate> models = new ArrayList<DDMTemplate>(soapModels.length);
172    
173                    for (DDMTemplateSoap soapModel : soapModels) {
174                            models.add(toModel(soapModel));
175                    }
176    
177                    return models;
178            }
179    
180            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
181                                    "lock.expiration.time.com.liferay.portlet.dynamicdatamapping.model.DDMTemplate"));
182    
183            public DDMTemplateModelImpl() {
184            }
185    
186            public long getPrimaryKey() {
187                    return _templateId;
188            }
189    
190            public void setPrimaryKey(long primaryKey) {
191                    setTemplateId(primaryKey);
192            }
193    
194            public Serializable getPrimaryKeyObj() {
195                    return _templateId;
196            }
197    
198            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
199                    setPrimaryKey(((Long)primaryKeyObj).longValue());
200            }
201    
202            public Class<?> getModelClass() {
203                    return DDMTemplate.class;
204            }
205    
206            public String getModelClassName() {
207                    return DDMTemplate.class.getName();
208            }
209    
210            @Override
211            public Map<String, Object> getModelAttributes() {
212                    Map<String, Object> attributes = new HashMap<String, Object>();
213    
214                    attributes.put("uuid", getUuid());
215                    attributes.put("templateId", getTemplateId());
216                    attributes.put("groupId", getGroupId());
217                    attributes.put("companyId", getCompanyId());
218                    attributes.put("userId", getUserId());
219                    attributes.put("userName", getUserName());
220                    attributes.put("createDate", getCreateDate());
221                    attributes.put("modifiedDate", getModifiedDate());
222                    attributes.put("classNameId", getClassNameId());
223                    attributes.put("classPK", getClassPK());
224                    attributes.put("templateKey", getTemplateKey());
225                    attributes.put("name", getName());
226                    attributes.put("description", getDescription());
227                    attributes.put("type", getType());
228                    attributes.put("mode", getMode());
229                    attributes.put("language", getLanguage());
230                    attributes.put("script", getScript());
231                    attributes.put("cacheable", getCacheable());
232                    attributes.put("smallImage", getSmallImage());
233                    attributes.put("smallImageId", getSmallImageId());
234                    attributes.put("smallImageURL", getSmallImageURL());
235    
236                    return attributes;
237            }
238    
239            @Override
240            public void setModelAttributes(Map<String, Object> attributes) {
241                    String uuid = (String)attributes.get("uuid");
242    
243                    if (uuid != null) {
244                            setUuid(uuid);
245                    }
246    
247                    Long templateId = (Long)attributes.get("templateId");
248    
249                    if (templateId != null) {
250                            setTemplateId(templateId);
251                    }
252    
253                    Long groupId = (Long)attributes.get("groupId");
254    
255                    if (groupId != null) {
256                            setGroupId(groupId);
257                    }
258    
259                    Long companyId = (Long)attributes.get("companyId");
260    
261                    if (companyId != null) {
262                            setCompanyId(companyId);
263                    }
264    
265                    Long userId = (Long)attributes.get("userId");
266    
267                    if (userId != null) {
268                            setUserId(userId);
269                    }
270    
271                    String userName = (String)attributes.get("userName");
272    
273                    if (userName != null) {
274                            setUserName(userName);
275                    }
276    
277                    Date createDate = (Date)attributes.get("createDate");
278    
279                    if (createDate != null) {
280                            setCreateDate(createDate);
281                    }
282    
283                    Date modifiedDate = (Date)attributes.get("modifiedDate");
284    
285                    if (modifiedDate != null) {
286                            setModifiedDate(modifiedDate);
287                    }
288    
289                    Long classNameId = (Long)attributes.get("classNameId");
290    
291                    if (classNameId != null) {
292                            setClassNameId(classNameId);
293                    }
294    
295                    Long classPK = (Long)attributes.get("classPK");
296    
297                    if (classPK != null) {
298                            setClassPK(classPK);
299                    }
300    
301                    String templateKey = (String)attributes.get("templateKey");
302    
303                    if (templateKey != null) {
304                            setTemplateKey(templateKey);
305                    }
306    
307                    String name = (String)attributes.get("name");
308    
309                    if (name != null) {
310                            setName(name);
311                    }
312    
313                    String description = (String)attributes.get("description");
314    
315                    if (description != null) {
316                            setDescription(description);
317                    }
318    
319                    String type = (String)attributes.get("type");
320    
321                    if (type != null) {
322                            setType(type);
323                    }
324    
325                    String mode = (String)attributes.get("mode");
326    
327                    if (mode != null) {
328                            setMode(mode);
329                    }
330    
331                    String language = (String)attributes.get("language");
332    
333                    if (language != null) {
334                            setLanguage(language);
335                    }
336    
337                    String script = (String)attributes.get("script");
338    
339                    if (script != null) {
340                            setScript(script);
341                    }
342    
343                    Boolean cacheable = (Boolean)attributes.get("cacheable");
344    
345                    if (cacheable != null) {
346                            setCacheable(cacheable);
347                    }
348    
349                    Boolean smallImage = (Boolean)attributes.get("smallImage");
350    
351                    if (smallImage != null) {
352                            setSmallImage(smallImage);
353                    }
354    
355                    Long smallImageId = (Long)attributes.get("smallImageId");
356    
357                    if (smallImageId != null) {
358                            setSmallImageId(smallImageId);
359                    }
360    
361                    String smallImageURL = (String)attributes.get("smallImageURL");
362    
363                    if (smallImageURL != null) {
364                            setSmallImageURL(smallImageURL);
365                    }
366            }
367    
368            @JSON
369            public String getUuid() {
370                    if (_uuid == null) {
371                            return StringPool.BLANK;
372                    }
373                    else {
374                            return _uuid;
375                    }
376            }
377    
378            public void setUuid(String uuid) {
379                    if (_originalUuid == null) {
380                            _originalUuid = _uuid;
381                    }
382    
383                    _uuid = uuid;
384            }
385    
386            public String getOriginalUuid() {
387                    return GetterUtil.getString(_originalUuid);
388            }
389    
390            @JSON
391            public long getTemplateId() {
392                    return _templateId;
393            }
394    
395            public void setTemplateId(long templateId) {
396                    _templateId = templateId;
397            }
398    
399            @JSON
400            public long getGroupId() {
401                    return _groupId;
402            }
403    
404            public void setGroupId(long groupId) {
405                    _columnBitmask |= GROUPID_COLUMN_BITMASK;
406    
407                    if (!_setOriginalGroupId) {
408                            _setOriginalGroupId = true;
409    
410                            _originalGroupId = _groupId;
411                    }
412    
413                    _groupId = groupId;
414            }
415    
416            public long getOriginalGroupId() {
417                    return _originalGroupId;
418            }
419    
420            @JSON
421            public long getCompanyId() {
422                    return _companyId;
423            }
424    
425            public void setCompanyId(long companyId) {
426                    _columnBitmask |= COMPANYID_COLUMN_BITMASK;
427    
428                    if (!_setOriginalCompanyId) {
429                            _setOriginalCompanyId = true;
430    
431                            _originalCompanyId = _companyId;
432                    }
433    
434                    _companyId = companyId;
435            }
436    
437            public long getOriginalCompanyId() {
438                    return _originalCompanyId;
439            }
440    
441            @JSON
442            public long getUserId() {
443                    return _userId;
444            }
445    
446            public void setUserId(long userId) {
447                    _userId = userId;
448            }
449    
450            public String getUserUuid() throws SystemException {
451                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
452            }
453    
454            public void setUserUuid(String userUuid) {
455                    _userUuid = userUuid;
456            }
457    
458            @JSON
459            public String getUserName() {
460                    if (_userName == null) {
461                            return StringPool.BLANK;
462                    }
463                    else {
464                            return _userName;
465                    }
466            }
467    
468            public void setUserName(String userName) {
469                    _userName = userName;
470            }
471    
472            @JSON
473            public Date getCreateDate() {
474                    return _createDate;
475            }
476    
477            public void setCreateDate(Date createDate) {
478                    _createDate = createDate;
479            }
480    
481            @JSON
482            public Date getModifiedDate() {
483                    return _modifiedDate;
484            }
485    
486            public void setModifiedDate(Date modifiedDate) {
487                    _modifiedDate = modifiedDate;
488            }
489    
490            public String getClassName() {
491                    if (getClassNameId() <= 0) {
492                            return StringPool.BLANK;
493                    }
494    
495                    return PortalUtil.getClassName(getClassNameId());
496            }
497    
498            public void setClassName(String className) {
499                    long classNameId = 0;
500    
501                    if (Validator.isNotNull(className)) {
502                            classNameId = PortalUtil.getClassNameId(className);
503                    }
504    
505                    setClassNameId(classNameId);
506            }
507    
508            @JSON
509            public long getClassNameId() {
510                    return _classNameId;
511            }
512    
513            public void setClassNameId(long classNameId) {
514                    _columnBitmask |= CLASSNAMEID_COLUMN_BITMASK;
515    
516                    if (!_setOriginalClassNameId) {
517                            _setOriginalClassNameId = true;
518    
519                            _originalClassNameId = _classNameId;
520                    }
521    
522                    _classNameId = classNameId;
523            }
524    
525            public long getOriginalClassNameId() {
526                    return _originalClassNameId;
527            }
528    
529            @JSON
530            public long getClassPK() {
531                    return _classPK;
532            }
533    
534            public void setClassPK(long classPK) {
535                    _columnBitmask |= CLASSPK_COLUMN_BITMASK;
536    
537                    if (!_setOriginalClassPK) {
538                            _setOriginalClassPK = true;
539    
540                            _originalClassPK = _classPK;
541                    }
542    
543                    _classPK = classPK;
544            }
545    
546            public long getOriginalClassPK() {
547                    return _originalClassPK;
548            }
549    
550            @JSON
551            public String getTemplateKey() {
552                    if (_templateKey == null) {
553                            return StringPool.BLANK;
554                    }
555                    else {
556                            return _templateKey;
557                    }
558            }
559    
560            public void setTemplateKey(String templateKey) {
561                    _columnBitmask |= TEMPLATEKEY_COLUMN_BITMASK;
562    
563                    if (_originalTemplateKey == null) {
564                            _originalTemplateKey = _templateKey;
565                    }
566    
567                    _templateKey = templateKey;
568            }
569    
570            public String getOriginalTemplateKey() {
571                    return GetterUtil.getString(_originalTemplateKey);
572            }
573    
574            @JSON
575            public String getName() {
576                    if (_name == null) {
577                            return StringPool.BLANK;
578                    }
579                    else {
580                            return _name;
581                    }
582            }
583    
584            public String getName(Locale locale) {
585                    String languageId = LocaleUtil.toLanguageId(locale);
586    
587                    return getName(languageId);
588            }
589    
590            public String getName(Locale locale, boolean useDefault) {
591                    String languageId = LocaleUtil.toLanguageId(locale);
592    
593                    return getName(languageId, useDefault);
594            }
595    
596            public String getName(String languageId) {
597                    return LocalizationUtil.getLocalization(getName(), languageId);
598            }
599    
600            public String getName(String languageId, boolean useDefault) {
601                    return LocalizationUtil.getLocalization(getName(), languageId,
602                            useDefault);
603            }
604    
605            public String getNameCurrentLanguageId() {
606                    return _nameCurrentLanguageId;
607            }
608    
609            @JSON
610            public String getNameCurrentValue() {
611                    Locale locale = getLocale(_nameCurrentLanguageId);
612    
613                    return getName(locale);
614            }
615    
616            public Map<Locale, String> getNameMap() {
617                    return LocalizationUtil.getLocalizationMap(getName());
618            }
619    
620            public void setName(String name) {
621                    _name = name;
622            }
623    
624            public void setName(String name, Locale locale) {
625                    setName(name, locale, LocaleUtil.getDefault());
626            }
627    
628            public void setName(String name, Locale locale, Locale defaultLocale) {
629                    String languageId = LocaleUtil.toLanguageId(locale);
630                    String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);
631    
632                    if (Validator.isNotNull(name)) {
633                            setName(LocalizationUtil.updateLocalization(getName(), "Name",
634                                            name, languageId, defaultLanguageId));
635                    }
636                    else {
637                            setName(LocalizationUtil.removeLocalization(getName(), "Name",
638                                            languageId));
639                    }
640            }
641    
642            public void setNameCurrentLanguageId(String languageId) {
643                    _nameCurrentLanguageId = languageId;
644            }
645    
646            public void setNameMap(Map<Locale, String> nameMap) {
647                    setNameMap(nameMap, LocaleUtil.getDefault());
648            }
649    
650            public void setNameMap(Map<Locale, String> nameMap, Locale defaultLocale) {
651                    if (nameMap == null) {
652                            return;
653                    }
654    
655                    setName(LocalizationUtil.updateLocalization(nameMap, getName(), "Name",
656                                    LocaleUtil.toLanguageId(defaultLocale)));
657            }
658    
659            @JSON
660            public String getDescription() {
661                    if (_description == null) {
662                            return StringPool.BLANK;
663                    }
664                    else {
665                            return _description;
666                    }
667            }
668    
669            public String getDescription(Locale locale) {
670                    String languageId = LocaleUtil.toLanguageId(locale);
671    
672                    return getDescription(languageId);
673            }
674    
675            public String getDescription(Locale locale, boolean useDefault) {
676                    String languageId = LocaleUtil.toLanguageId(locale);
677    
678                    return getDescription(languageId, useDefault);
679            }
680    
681            public String getDescription(String languageId) {
682                    return LocalizationUtil.getLocalization(getDescription(), languageId);
683            }
684    
685            public String getDescription(String languageId, boolean useDefault) {
686                    return LocalizationUtil.getLocalization(getDescription(), languageId,
687                            useDefault);
688            }
689    
690            public String getDescriptionCurrentLanguageId() {
691                    return _descriptionCurrentLanguageId;
692            }
693    
694            @JSON
695            public String getDescriptionCurrentValue() {
696                    Locale locale = getLocale(_descriptionCurrentLanguageId);
697    
698                    return getDescription(locale);
699            }
700    
701            public Map<Locale, String> getDescriptionMap() {
702                    return LocalizationUtil.getLocalizationMap(getDescription());
703            }
704    
705            public void setDescription(String description) {
706                    _description = description;
707            }
708    
709            public void setDescription(String description, Locale locale) {
710                    setDescription(description, locale, LocaleUtil.getDefault());
711            }
712    
713            public void setDescription(String description, Locale locale,
714                    Locale defaultLocale) {
715                    String languageId = LocaleUtil.toLanguageId(locale);
716                    String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);
717    
718                    if (Validator.isNotNull(description)) {
719                            setDescription(LocalizationUtil.updateLocalization(
720                                            getDescription(), "Description", description, languageId,
721                                            defaultLanguageId));
722                    }
723                    else {
724                            setDescription(LocalizationUtil.removeLocalization(
725                                            getDescription(), "Description", languageId));
726                    }
727            }
728    
729            public void setDescriptionCurrentLanguageId(String languageId) {
730                    _descriptionCurrentLanguageId = languageId;
731            }
732    
733            public void setDescriptionMap(Map<Locale, String> descriptionMap) {
734                    setDescriptionMap(descriptionMap, LocaleUtil.getDefault());
735            }
736    
737            public void setDescriptionMap(Map<Locale, String> descriptionMap,
738                    Locale defaultLocale) {
739                    if (descriptionMap == null) {
740                            return;
741                    }
742    
743                    setDescription(LocalizationUtil.updateLocalization(descriptionMap,
744                                    getDescription(), "Description",
745                                    LocaleUtil.toLanguageId(defaultLocale)));
746            }
747    
748            @JSON
749            public String getType() {
750                    if (_type == null) {
751                            return StringPool.BLANK;
752                    }
753                    else {
754                            return _type;
755                    }
756            }
757    
758            public void setType(String type) {
759                    _columnBitmask |= TYPE_COLUMN_BITMASK;
760    
761                    if (_originalType == null) {
762                            _originalType = _type;
763                    }
764    
765                    _type = type;
766            }
767    
768            public String getOriginalType() {
769                    return GetterUtil.getString(_originalType);
770            }
771    
772            @JSON
773            public String getMode() {
774                    if (_mode == null) {
775                            return StringPool.BLANK;
776                    }
777                    else {
778                            return _mode;
779                    }
780            }
781    
782            public void setMode(String mode) {
783                    _columnBitmask |= MODE_COLUMN_BITMASK;
784    
785                    if (_originalMode == null) {
786                            _originalMode = _mode;
787                    }
788    
789                    _mode = mode;
790            }
791    
792            public String getOriginalMode() {
793                    return GetterUtil.getString(_originalMode);
794            }
795    
796            @JSON
797            public String getLanguage() {
798                    if (_language == null) {
799                            return StringPool.BLANK;
800                    }
801                    else {
802                            return _language;
803                    }
804            }
805    
806            public void setLanguage(String language) {
807                    _columnBitmask |= LANGUAGE_COLUMN_BITMASK;
808    
809                    if (_originalLanguage == null) {
810                            _originalLanguage = _language;
811                    }
812    
813                    _language = language;
814            }
815    
816            public String getOriginalLanguage() {
817                    return GetterUtil.getString(_originalLanguage);
818            }
819    
820            @JSON
821            public String getScript() {
822                    if (_script == null) {
823                            return StringPool.BLANK;
824                    }
825                    else {
826                            return _script;
827                    }
828            }
829    
830            public void setScript(String script) {
831                    _script = script;
832            }
833    
834            @JSON
835            public boolean getCacheable() {
836                    return _cacheable;
837            }
838    
839            public boolean isCacheable() {
840                    return _cacheable;
841            }
842    
843            public void setCacheable(boolean cacheable) {
844                    _cacheable = cacheable;
845            }
846    
847            @JSON
848            public boolean getSmallImage() {
849                    return _smallImage;
850            }
851    
852            public boolean isSmallImage() {
853                    return _smallImage;
854            }
855    
856            public void setSmallImage(boolean smallImage) {
857                    _smallImage = smallImage;
858            }
859    
860            @JSON
861            public long getSmallImageId() {
862                    return _smallImageId;
863            }
864    
865            public void setSmallImageId(long smallImageId) {
866                    _smallImageId = smallImageId;
867            }
868    
869            @JSON
870            public String getSmallImageURL() {
871                    if (_smallImageURL == null) {
872                            return StringPool.BLANK;
873                    }
874                    else {
875                            return _smallImageURL;
876                    }
877            }
878    
879            public void setSmallImageURL(String smallImageURL) {
880                    _smallImageURL = smallImageURL;
881            }
882    
883            public long getColumnBitmask() {
884                    return _columnBitmask;
885            }
886    
887            @Override
888            public ExpandoBridge getExpandoBridge() {
889                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
890                            DDMTemplate.class.getName(), getPrimaryKey());
891            }
892    
893            @Override
894            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
895                    ExpandoBridge expandoBridge = getExpandoBridge();
896    
897                    expandoBridge.setAttributes(serviceContext);
898            }
899    
900            @SuppressWarnings("unused")
901            public void prepareLocalizedFieldsForImport(Locale defaultImportLocale)
902                    throws LocaleException {
903                    setName(getName(defaultImportLocale), defaultImportLocale,
904                            defaultImportLocale);
905                    setDescription(getDescription(defaultImportLocale),
906                            defaultImportLocale, defaultImportLocale);
907            }
908    
909            @Override
910            public DDMTemplate toEscapedModel() {
911                    if (_escapedModel == null) {
912                            _escapedModel = (DDMTemplate)ProxyUtil.newProxyInstance(_classLoader,
913                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
914                    }
915    
916                    return _escapedModel;
917            }
918    
919            @Override
920            public Object clone() {
921                    DDMTemplateImpl ddmTemplateImpl = new DDMTemplateImpl();
922    
923                    ddmTemplateImpl.setUuid(getUuid());
924                    ddmTemplateImpl.setTemplateId(getTemplateId());
925                    ddmTemplateImpl.setGroupId(getGroupId());
926                    ddmTemplateImpl.setCompanyId(getCompanyId());
927                    ddmTemplateImpl.setUserId(getUserId());
928                    ddmTemplateImpl.setUserName(getUserName());
929                    ddmTemplateImpl.setCreateDate(getCreateDate());
930                    ddmTemplateImpl.setModifiedDate(getModifiedDate());
931                    ddmTemplateImpl.setClassNameId(getClassNameId());
932                    ddmTemplateImpl.setClassPK(getClassPK());
933                    ddmTemplateImpl.setTemplateKey(getTemplateKey());
934                    ddmTemplateImpl.setName(getName());
935                    ddmTemplateImpl.setDescription(getDescription());
936                    ddmTemplateImpl.setType(getType());
937                    ddmTemplateImpl.setMode(getMode());
938                    ddmTemplateImpl.setLanguage(getLanguage());
939                    ddmTemplateImpl.setScript(getScript());
940                    ddmTemplateImpl.setCacheable(getCacheable());
941                    ddmTemplateImpl.setSmallImage(getSmallImage());
942                    ddmTemplateImpl.setSmallImageId(getSmallImageId());
943                    ddmTemplateImpl.setSmallImageURL(getSmallImageURL());
944    
945                    ddmTemplateImpl.resetOriginalValues();
946    
947                    return ddmTemplateImpl;
948            }
949    
950            public int compareTo(DDMTemplate ddmTemplate) {
951                    long primaryKey = ddmTemplate.getPrimaryKey();
952    
953                    if (getPrimaryKey() < primaryKey) {
954                            return -1;
955                    }
956                    else if (getPrimaryKey() > primaryKey) {
957                            return 1;
958                    }
959                    else {
960                            return 0;
961                    }
962            }
963    
964            @Override
965            public boolean equals(Object obj) {
966                    if (obj == null) {
967                            return false;
968                    }
969    
970                    DDMTemplate ddmTemplate = null;
971    
972                    try {
973                            ddmTemplate = (DDMTemplate)obj;
974                    }
975                    catch (ClassCastException cce) {
976                            return false;
977                    }
978    
979                    long primaryKey = ddmTemplate.getPrimaryKey();
980    
981                    if (getPrimaryKey() == primaryKey) {
982                            return true;
983                    }
984                    else {
985                            return false;
986                    }
987            }
988    
989            @Override
990            public int hashCode() {
991                    return (int)getPrimaryKey();
992            }
993    
994            @Override
995            public void resetOriginalValues() {
996                    DDMTemplateModelImpl ddmTemplateModelImpl = this;
997    
998                    ddmTemplateModelImpl._originalUuid = ddmTemplateModelImpl._uuid;
999    
1000                    ddmTemplateModelImpl._originalGroupId = ddmTemplateModelImpl._groupId;
1001    
1002                    ddmTemplateModelImpl._setOriginalGroupId = false;
1003    
1004                    ddmTemplateModelImpl._originalCompanyId = ddmTemplateModelImpl._companyId;
1005    
1006                    ddmTemplateModelImpl._setOriginalCompanyId = false;
1007    
1008                    ddmTemplateModelImpl._originalClassNameId = ddmTemplateModelImpl._classNameId;
1009    
1010                    ddmTemplateModelImpl._setOriginalClassNameId = false;
1011    
1012                    ddmTemplateModelImpl._originalClassPK = ddmTemplateModelImpl._classPK;
1013    
1014                    ddmTemplateModelImpl._setOriginalClassPK = false;
1015    
1016                    ddmTemplateModelImpl._originalTemplateKey = ddmTemplateModelImpl._templateKey;
1017    
1018                    ddmTemplateModelImpl._originalType = ddmTemplateModelImpl._type;
1019    
1020                    ddmTemplateModelImpl._originalMode = ddmTemplateModelImpl._mode;
1021    
1022                    ddmTemplateModelImpl._originalLanguage = ddmTemplateModelImpl._language;
1023    
1024                    ddmTemplateModelImpl._columnBitmask = 0;
1025            }
1026    
1027            @Override
1028            public CacheModel<DDMTemplate> toCacheModel() {
1029                    DDMTemplateCacheModel ddmTemplateCacheModel = new DDMTemplateCacheModel();
1030    
1031                    ddmTemplateCacheModel.uuid = getUuid();
1032    
1033                    String uuid = ddmTemplateCacheModel.uuid;
1034    
1035                    if ((uuid != null) && (uuid.length() == 0)) {
1036                            ddmTemplateCacheModel.uuid = null;
1037                    }
1038    
1039                    ddmTemplateCacheModel.templateId = getTemplateId();
1040    
1041                    ddmTemplateCacheModel.groupId = getGroupId();
1042    
1043                    ddmTemplateCacheModel.companyId = getCompanyId();
1044    
1045                    ddmTemplateCacheModel.userId = getUserId();
1046    
1047                    ddmTemplateCacheModel.userName = getUserName();
1048    
1049                    String userName = ddmTemplateCacheModel.userName;
1050    
1051                    if ((userName != null) && (userName.length() == 0)) {
1052                            ddmTemplateCacheModel.userName = null;
1053                    }
1054    
1055                    Date createDate = getCreateDate();
1056    
1057                    if (createDate != null) {
1058                            ddmTemplateCacheModel.createDate = createDate.getTime();
1059                    }
1060                    else {
1061                            ddmTemplateCacheModel.createDate = Long.MIN_VALUE;
1062                    }
1063    
1064                    Date modifiedDate = getModifiedDate();
1065    
1066                    if (modifiedDate != null) {
1067                            ddmTemplateCacheModel.modifiedDate = modifiedDate.getTime();
1068                    }
1069                    else {
1070                            ddmTemplateCacheModel.modifiedDate = Long.MIN_VALUE;
1071                    }
1072    
1073                    ddmTemplateCacheModel.classNameId = getClassNameId();
1074    
1075                    ddmTemplateCacheModel.classPK = getClassPK();
1076    
1077                    ddmTemplateCacheModel.templateKey = getTemplateKey();
1078    
1079                    String templateKey = ddmTemplateCacheModel.templateKey;
1080    
1081                    if ((templateKey != null) && (templateKey.length() == 0)) {
1082                            ddmTemplateCacheModel.templateKey = null;
1083                    }
1084    
1085                    ddmTemplateCacheModel.name = getName();
1086    
1087                    String name = ddmTemplateCacheModel.name;
1088    
1089                    if ((name != null) && (name.length() == 0)) {
1090                            ddmTemplateCacheModel.name = null;
1091                    }
1092    
1093                    ddmTemplateCacheModel.description = getDescription();
1094    
1095                    String description = ddmTemplateCacheModel.description;
1096    
1097                    if ((description != null) && (description.length() == 0)) {
1098                            ddmTemplateCacheModel.description = null;
1099                    }
1100    
1101                    ddmTemplateCacheModel.type = getType();
1102    
1103                    String type = ddmTemplateCacheModel.type;
1104    
1105                    if ((type != null) && (type.length() == 0)) {
1106                            ddmTemplateCacheModel.type = null;
1107                    }
1108    
1109                    ddmTemplateCacheModel.mode = getMode();
1110    
1111                    String mode = ddmTemplateCacheModel.mode;
1112    
1113                    if ((mode != null) && (mode.length() == 0)) {
1114                            ddmTemplateCacheModel.mode = null;
1115                    }
1116    
1117                    ddmTemplateCacheModel.language = getLanguage();
1118    
1119                    String language = ddmTemplateCacheModel.language;
1120    
1121                    if ((language != null) && (language.length() == 0)) {
1122                            ddmTemplateCacheModel.language = null;
1123                    }
1124    
1125                    ddmTemplateCacheModel.script = getScript();
1126    
1127                    String script = ddmTemplateCacheModel.script;
1128    
1129                    if ((script != null) && (script.length() == 0)) {
1130                            ddmTemplateCacheModel.script = null;
1131                    }
1132    
1133                    ddmTemplateCacheModel.cacheable = getCacheable();
1134    
1135                    ddmTemplateCacheModel.smallImage = getSmallImage();
1136    
1137                    ddmTemplateCacheModel.smallImageId = getSmallImageId();
1138    
1139                    ddmTemplateCacheModel.smallImageURL = getSmallImageURL();
1140    
1141                    String smallImageURL = ddmTemplateCacheModel.smallImageURL;
1142    
1143                    if ((smallImageURL != null) && (smallImageURL.length() == 0)) {
1144                            ddmTemplateCacheModel.smallImageURL = null;
1145                    }
1146    
1147                    return ddmTemplateCacheModel;
1148            }
1149    
1150            @Override
1151            public String toString() {
1152                    StringBundler sb = new StringBundler(43);
1153    
1154                    sb.append("{uuid=");
1155                    sb.append(getUuid());
1156                    sb.append(", templateId=");
1157                    sb.append(getTemplateId());
1158                    sb.append(", groupId=");
1159                    sb.append(getGroupId());
1160                    sb.append(", companyId=");
1161                    sb.append(getCompanyId());
1162                    sb.append(", userId=");
1163                    sb.append(getUserId());
1164                    sb.append(", userName=");
1165                    sb.append(getUserName());
1166                    sb.append(", createDate=");
1167                    sb.append(getCreateDate());
1168                    sb.append(", modifiedDate=");
1169                    sb.append(getModifiedDate());
1170                    sb.append(", classNameId=");
1171                    sb.append(getClassNameId());
1172                    sb.append(", classPK=");
1173                    sb.append(getClassPK());
1174                    sb.append(", templateKey=");
1175                    sb.append(getTemplateKey());
1176                    sb.append(", name=");
1177                    sb.append(getName());
1178                    sb.append(", description=");
1179                    sb.append(getDescription());
1180                    sb.append(", type=");
1181                    sb.append(getType());
1182                    sb.append(", mode=");
1183                    sb.append(getMode());
1184                    sb.append(", language=");
1185                    sb.append(getLanguage());
1186                    sb.append(", script=");
1187                    sb.append(getScript());
1188                    sb.append(", cacheable=");
1189                    sb.append(getCacheable());
1190                    sb.append(", smallImage=");
1191                    sb.append(getSmallImage());
1192                    sb.append(", smallImageId=");
1193                    sb.append(getSmallImageId());
1194                    sb.append(", smallImageURL=");
1195                    sb.append(getSmallImageURL());
1196                    sb.append("}");
1197    
1198                    return sb.toString();
1199            }
1200    
1201            public String toXmlString() {
1202                    StringBundler sb = new StringBundler(67);
1203    
1204                    sb.append("<model><model-name>");
1205                    sb.append("com.liferay.portlet.dynamicdatamapping.model.DDMTemplate");
1206                    sb.append("</model-name>");
1207    
1208                    sb.append(
1209                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
1210                    sb.append(getUuid());
1211                    sb.append("]]></column-value></column>");
1212                    sb.append(
1213                            "<column><column-name>templateId</column-name><column-value><![CDATA[");
1214                    sb.append(getTemplateId());
1215                    sb.append("]]></column-value></column>");
1216                    sb.append(
1217                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
1218                    sb.append(getGroupId());
1219                    sb.append("]]></column-value></column>");
1220                    sb.append(
1221                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
1222                    sb.append(getCompanyId());
1223                    sb.append("]]></column-value></column>");
1224                    sb.append(
1225                            "<column><column-name>userId</column-name><column-value><![CDATA[");
1226                    sb.append(getUserId());
1227                    sb.append("]]></column-value></column>");
1228                    sb.append(
1229                            "<column><column-name>userName</column-name><column-value><![CDATA[");
1230                    sb.append(getUserName());
1231                    sb.append("]]></column-value></column>");
1232                    sb.append(
1233                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
1234                    sb.append(getCreateDate());
1235                    sb.append("]]></column-value></column>");
1236                    sb.append(
1237                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
1238                    sb.append(getModifiedDate());
1239                    sb.append("]]></column-value></column>");
1240                    sb.append(
1241                            "<column><column-name>classNameId</column-name><column-value><![CDATA[");
1242                    sb.append(getClassNameId());
1243                    sb.append("]]></column-value></column>");
1244                    sb.append(
1245                            "<column><column-name>classPK</column-name><column-value><![CDATA[");
1246                    sb.append(getClassPK());
1247                    sb.append("]]></column-value></column>");
1248                    sb.append(
1249                            "<column><column-name>templateKey</column-name><column-value><![CDATA[");
1250                    sb.append(getTemplateKey());
1251                    sb.append("]]></column-value></column>");
1252                    sb.append(
1253                            "<column><column-name>name</column-name><column-value><![CDATA[");
1254                    sb.append(getName());
1255                    sb.append("]]></column-value></column>");
1256                    sb.append(
1257                            "<column><column-name>description</column-name><column-value><![CDATA[");
1258                    sb.append(getDescription());
1259                    sb.append("]]></column-value></column>");
1260                    sb.append(
1261                            "<column><column-name>type</column-name><column-value><![CDATA[");
1262                    sb.append(getType());
1263                    sb.append("]]></column-value></column>");
1264                    sb.append(
1265                            "<column><column-name>mode</column-name><column-value><![CDATA[");
1266                    sb.append(getMode());
1267                    sb.append("]]></column-value></column>");
1268                    sb.append(
1269                            "<column><column-name>language</column-name><column-value><![CDATA[");
1270                    sb.append(getLanguage());
1271                    sb.append("]]></column-value></column>");
1272                    sb.append(
1273                            "<column><column-name>script</column-name><column-value><![CDATA[");
1274                    sb.append(getScript());
1275                    sb.append("]]></column-value></column>");
1276                    sb.append(
1277                            "<column><column-name>cacheable</column-name><column-value><![CDATA[");
1278                    sb.append(getCacheable());
1279                    sb.append("]]></column-value></column>");
1280                    sb.append(
1281                            "<column><column-name>smallImage</column-name><column-value><![CDATA[");
1282                    sb.append(getSmallImage());
1283                    sb.append("]]></column-value></column>");
1284                    sb.append(
1285                            "<column><column-name>smallImageId</column-name><column-value><![CDATA[");
1286                    sb.append(getSmallImageId());
1287                    sb.append("]]></column-value></column>");
1288                    sb.append(
1289                            "<column><column-name>smallImageURL</column-name><column-value><![CDATA[");
1290                    sb.append(getSmallImageURL());
1291                    sb.append("]]></column-value></column>");
1292    
1293                    sb.append("</model>");
1294    
1295                    return sb.toString();
1296            }
1297    
1298            private static ClassLoader _classLoader = DDMTemplate.class.getClassLoader();
1299            private static Class<?>[] _escapedModelInterfaces = new Class[] {
1300                            DDMTemplate.class
1301                    };
1302            private String _uuid;
1303            private String _originalUuid;
1304            private long _templateId;
1305            private long _groupId;
1306            private long _originalGroupId;
1307            private boolean _setOriginalGroupId;
1308            private long _companyId;
1309            private long _originalCompanyId;
1310            private boolean _setOriginalCompanyId;
1311            private long _userId;
1312            private String _userUuid;
1313            private String _userName;
1314            private Date _createDate;
1315            private Date _modifiedDate;
1316            private long _classNameId;
1317            private long _originalClassNameId;
1318            private boolean _setOriginalClassNameId;
1319            private long _classPK;
1320            private long _originalClassPK;
1321            private boolean _setOriginalClassPK;
1322            private String _templateKey;
1323            private String _originalTemplateKey;
1324            private String _name;
1325            private String _nameCurrentLanguageId;
1326            private String _description;
1327            private String _descriptionCurrentLanguageId;
1328            private String _type;
1329            private String _originalType;
1330            private String _mode;
1331            private String _originalMode;
1332            private String _language;
1333            private String _originalLanguage;
1334            private String _script;
1335            private boolean _cacheable;
1336            private boolean _smallImage;
1337            private long _smallImageId;
1338            private String _smallImageURL;
1339            private long _columnBitmask;
1340            private DDMTemplate _escapedModel;
1341    }