001    /**
002     * Copyright (c) 2000-2013 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.language.LanguageUtil;
022    import com.liferay.portal.kernel.util.GetterUtil;
023    import com.liferay.portal.kernel.util.LocaleUtil;
024    import com.liferay.portal.kernel.util.LocalizationUtil;
025    import com.liferay.portal.kernel.util.ProxyUtil;
026    import com.liferay.portal.kernel.util.StringBundler;
027    import com.liferay.portal.kernel.util.StringPool;
028    import com.liferay.portal.kernel.util.Validator;
029    import com.liferay.portal.model.CacheModel;
030    import com.liferay.portal.model.impl.BaseModelImpl;
031    import com.liferay.portal.service.ServiceContext;
032    import com.liferay.portal.util.PortalUtil;
033    
034    import com.liferay.portlet.dynamicdatamapping.model.DDMTemplate;
035    import com.liferay.portlet.dynamicdatamapping.model.DDMTemplateModel;
036    import com.liferay.portlet.dynamicdatamapping.model.DDMTemplateSoap;
037    import com.liferay.portlet.expando.model.ExpandoBridge;
038    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
039    
040    import java.io.Serializable;
041    
042    import java.sql.Types;
043    
044    import java.util.ArrayList;
045    import java.util.Date;
046    import java.util.HashMap;
047    import java.util.List;
048    import java.util.Locale;
049    import java.util.Map;
050    
051    /**
052     * 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.
053     *
054     * <p>
055     * 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}.
056     * </p>
057     *
058     * @author Brian Wing Shun Chan
059     * @see DDMTemplateImpl
060     * @see com.liferay.portlet.dynamicdatamapping.model.DDMTemplate
061     * @see com.liferay.portlet.dynamicdatamapping.model.DDMTemplateModel
062     * @generated
063     */
064    @JSON(strict = true)
065    public class DDMTemplateModelImpl extends BaseModelImpl<DDMTemplate>
066            implements DDMTemplateModel {
067            /*
068             * NOTE FOR DEVELOPERS:
069             *
070             * 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.
071             */
072            public static final String TABLE_NAME = "DDMTemplate";
073            public static final Object[][] TABLE_COLUMNS = {
074                            { "uuid_", Types.VARCHAR },
075                            { "templateId", Types.BIGINT },
076                            { "groupId", Types.BIGINT },
077                            { "companyId", Types.BIGINT },
078                            { "userId", Types.BIGINT },
079                            { "userName", Types.VARCHAR },
080                            { "createDate", Types.TIMESTAMP },
081                            { "modifiedDate", Types.TIMESTAMP },
082                            { "structureId", Types.BIGINT },
083                            { "name", Types.VARCHAR },
084                            { "description", Types.VARCHAR },
085                            { "type_", Types.VARCHAR },
086                            { "mode_", Types.VARCHAR },
087                            { "language", Types.VARCHAR },
088                            { "script", Types.CLOB }
089                    };
090            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,structureId LONG,name STRING null,description STRING null,type_ VARCHAR(75) null,mode_ VARCHAR(75) null,language VARCHAR(75) null,script TEXT null)";
091            public static final String TABLE_SQL_DROP = "drop table DDMTemplate";
092            public static final String DATA_SOURCE = "liferayDataSource";
093            public static final String SESSION_FACTORY = "liferaySessionFactory";
094            public static final String TX_MANAGER = "liferayTransactionManager";
095            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
096                                    "value.object.entity.cache.enabled.com.liferay.portlet.dynamicdatamapping.model.DDMTemplate"),
097                            true);
098            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
099                                    "value.object.finder.cache.enabled.com.liferay.portlet.dynamicdatamapping.model.DDMTemplate"),
100                            true);
101            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
102                                    "value.object.column.bitmask.enabled.com.liferay.portlet.dynamicdatamapping.model.DDMTemplate"),
103                            true);
104            public static long GROUPID_COLUMN_BITMASK = 1L;
105            public static long LANGUAGE_COLUMN_BITMASK = 2L;
106            public static long MODE_COLUMN_BITMASK = 4L;
107            public static long STRUCTUREID_COLUMN_BITMASK = 8L;
108            public static long TYPE_COLUMN_BITMASK = 16L;
109            public static long UUID_COLUMN_BITMASK = 32L;
110    
111            /**
112             * Converts the soap model instance into a normal model instance.
113             *
114             * @param soapModel the soap model instance to convert
115             * @return the normal model instance
116             */
117            public static DDMTemplate toModel(DDMTemplateSoap soapModel) {
118                    if (soapModel == null) {
119                            return null;
120                    }
121    
122                    DDMTemplate model = new DDMTemplateImpl();
123    
124                    model.setUuid(soapModel.getUuid());
125                    model.setTemplateId(soapModel.getTemplateId());
126                    model.setGroupId(soapModel.getGroupId());
127                    model.setCompanyId(soapModel.getCompanyId());
128                    model.setUserId(soapModel.getUserId());
129                    model.setUserName(soapModel.getUserName());
130                    model.setCreateDate(soapModel.getCreateDate());
131                    model.setModifiedDate(soapModel.getModifiedDate());
132                    model.setStructureId(soapModel.getStructureId());
133                    model.setName(soapModel.getName());
134                    model.setDescription(soapModel.getDescription());
135                    model.setType(soapModel.getType());
136                    model.setMode(soapModel.getMode());
137                    model.setLanguage(soapModel.getLanguage());
138                    model.setScript(soapModel.getScript());
139    
140                    return model;
141            }
142    
143            /**
144             * Converts the soap model instances into normal model instances.
145             *
146             * @param soapModels the soap model instances to convert
147             * @return the normal model instances
148             */
149            public static List<DDMTemplate> toModels(DDMTemplateSoap[] soapModels) {
150                    if (soapModels == null) {
151                            return null;
152                    }
153    
154                    List<DDMTemplate> models = new ArrayList<DDMTemplate>(soapModels.length);
155    
156                    for (DDMTemplateSoap soapModel : soapModels) {
157                            models.add(toModel(soapModel));
158                    }
159    
160                    return models;
161            }
162    
163            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
164                                    "lock.expiration.time.com.liferay.portlet.dynamicdatamapping.model.DDMTemplate"));
165    
166            public DDMTemplateModelImpl() {
167            }
168    
169            public long getPrimaryKey() {
170                    return _templateId;
171            }
172    
173            public void setPrimaryKey(long primaryKey) {
174                    setTemplateId(primaryKey);
175            }
176    
177            public Serializable getPrimaryKeyObj() {
178                    return new Long(_templateId);
179            }
180    
181            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
182                    setPrimaryKey(((Long)primaryKeyObj).longValue());
183            }
184    
185            public Class<?> getModelClass() {
186                    return DDMTemplate.class;
187            }
188    
189            public String getModelClassName() {
190                    return DDMTemplate.class.getName();
191            }
192    
193            @Override
194            public Map<String, Object> getModelAttributes() {
195                    Map<String, Object> attributes = new HashMap<String, Object>();
196    
197                    attributes.put("uuid", getUuid());
198                    attributes.put("templateId", getTemplateId());
199                    attributes.put("groupId", getGroupId());
200                    attributes.put("companyId", getCompanyId());
201                    attributes.put("userId", getUserId());
202                    attributes.put("userName", getUserName());
203                    attributes.put("createDate", getCreateDate());
204                    attributes.put("modifiedDate", getModifiedDate());
205                    attributes.put("structureId", getStructureId());
206                    attributes.put("name", getName());
207                    attributes.put("description", getDescription());
208                    attributes.put("type", getType());
209                    attributes.put("mode", getMode());
210                    attributes.put("language", getLanguage());
211                    attributes.put("script", getScript());
212    
213                    return attributes;
214            }
215    
216            @Override
217            public void setModelAttributes(Map<String, Object> attributes) {
218                    String uuid = (String)attributes.get("uuid");
219    
220                    if (uuid != null) {
221                            setUuid(uuid);
222                    }
223    
224                    Long templateId = (Long)attributes.get("templateId");
225    
226                    if (templateId != null) {
227                            setTemplateId(templateId);
228                    }
229    
230                    Long groupId = (Long)attributes.get("groupId");
231    
232                    if (groupId != null) {
233                            setGroupId(groupId);
234                    }
235    
236                    Long companyId = (Long)attributes.get("companyId");
237    
238                    if (companyId != null) {
239                            setCompanyId(companyId);
240                    }
241    
242                    Long userId = (Long)attributes.get("userId");
243    
244                    if (userId != null) {
245                            setUserId(userId);
246                    }
247    
248                    String userName = (String)attributes.get("userName");
249    
250                    if (userName != null) {
251                            setUserName(userName);
252                    }
253    
254                    Date createDate = (Date)attributes.get("createDate");
255    
256                    if (createDate != null) {
257                            setCreateDate(createDate);
258                    }
259    
260                    Date modifiedDate = (Date)attributes.get("modifiedDate");
261    
262                    if (modifiedDate != null) {
263                            setModifiedDate(modifiedDate);
264                    }
265    
266                    Long structureId = (Long)attributes.get("structureId");
267    
268                    if (structureId != null) {
269                            setStructureId(structureId);
270                    }
271    
272                    String name = (String)attributes.get("name");
273    
274                    if (name != null) {
275                            setName(name);
276                    }
277    
278                    String description = (String)attributes.get("description");
279    
280                    if (description != null) {
281                            setDescription(description);
282                    }
283    
284                    String type = (String)attributes.get("type");
285    
286                    if (type != null) {
287                            setType(type);
288                    }
289    
290                    String mode = (String)attributes.get("mode");
291    
292                    if (mode != null) {
293                            setMode(mode);
294                    }
295    
296                    String language = (String)attributes.get("language");
297    
298                    if (language != null) {
299                            setLanguage(language);
300                    }
301    
302                    String script = (String)attributes.get("script");
303    
304                    if (script != null) {
305                            setScript(script);
306                    }
307            }
308    
309            @JSON
310            public String getUuid() {
311                    if (_uuid == null) {
312                            return StringPool.BLANK;
313                    }
314                    else {
315                            return _uuid;
316                    }
317            }
318    
319            public void setUuid(String uuid) {
320                    if (_originalUuid == null) {
321                            _originalUuid = _uuid;
322                    }
323    
324                    _uuid = uuid;
325            }
326    
327            public String getOriginalUuid() {
328                    return GetterUtil.getString(_originalUuid);
329            }
330    
331            @JSON
332            public long getTemplateId() {
333                    return _templateId;
334            }
335    
336            public void setTemplateId(long templateId) {
337                    _templateId = templateId;
338            }
339    
340            @JSON
341            public long getGroupId() {
342                    return _groupId;
343            }
344    
345            public void setGroupId(long groupId) {
346                    _columnBitmask |= GROUPID_COLUMN_BITMASK;
347    
348                    if (!_setOriginalGroupId) {
349                            _setOriginalGroupId = true;
350    
351                            _originalGroupId = _groupId;
352                    }
353    
354                    _groupId = groupId;
355            }
356    
357            public long getOriginalGroupId() {
358                    return _originalGroupId;
359            }
360    
361            @JSON
362            public long getCompanyId() {
363                    return _companyId;
364            }
365    
366            public void setCompanyId(long companyId) {
367                    _companyId = companyId;
368            }
369    
370            @JSON
371            public long getUserId() {
372                    return _userId;
373            }
374    
375            public void setUserId(long userId) {
376                    _userId = userId;
377            }
378    
379            public String getUserUuid() throws SystemException {
380                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
381            }
382    
383            public void setUserUuid(String userUuid) {
384                    _userUuid = userUuid;
385            }
386    
387            @JSON
388            public String getUserName() {
389                    if (_userName == null) {
390                            return StringPool.BLANK;
391                    }
392                    else {
393                            return _userName;
394                    }
395            }
396    
397            public void setUserName(String userName) {
398                    _userName = userName;
399            }
400    
401            @JSON
402            public Date getCreateDate() {
403                    return _createDate;
404            }
405    
406            public void setCreateDate(Date createDate) {
407                    _createDate = createDate;
408            }
409    
410            @JSON
411            public Date getModifiedDate() {
412                    return _modifiedDate;
413            }
414    
415            public void setModifiedDate(Date modifiedDate) {
416                    _modifiedDate = modifiedDate;
417            }
418    
419            @JSON
420            public long getStructureId() {
421                    return _structureId;
422            }
423    
424            public void setStructureId(long structureId) {
425                    _columnBitmask |= STRUCTUREID_COLUMN_BITMASK;
426    
427                    if (!_setOriginalStructureId) {
428                            _setOriginalStructureId = true;
429    
430                            _originalStructureId = _structureId;
431                    }
432    
433                    _structureId = structureId;
434            }
435    
436            public long getOriginalStructureId() {
437                    return _originalStructureId;
438            }
439    
440            @JSON
441            public String getName() {
442                    if (_name == null) {
443                            return StringPool.BLANK;
444                    }
445                    else {
446                            return _name;
447                    }
448            }
449    
450            public String getName(Locale locale) {
451                    String languageId = LocaleUtil.toLanguageId(locale);
452    
453                    return getName(languageId);
454            }
455    
456            public String getName(Locale locale, boolean useDefault) {
457                    String languageId = LocaleUtil.toLanguageId(locale);
458    
459                    return getName(languageId, useDefault);
460            }
461    
462            public String getName(String languageId) {
463                    return LocalizationUtil.getLocalization(getName(), languageId);
464            }
465    
466            public String getName(String languageId, boolean useDefault) {
467                    return LocalizationUtil.getLocalization(getName(), languageId,
468                            useDefault);
469            }
470    
471            public String getNameCurrentLanguageId() {
472                    return _nameCurrentLanguageId;
473            }
474    
475            @JSON
476            public String getNameCurrentValue() {
477                    Locale locale = getLocale(_nameCurrentLanguageId);
478    
479                    return getName(locale);
480            }
481    
482            public Map<Locale, String> getNameMap() {
483                    return LocalizationUtil.getLocalizationMap(getName());
484            }
485    
486            public void setName(String name) {
487                    _name = name;
488            }
489    
490            public void setName(String name, Locale locale) {
491                    setName(name, locale, LocaleUtil.getDefault());
492            }
493    
494            public void setName(String name, Locale locale, Locale defaultLocale) {
495                    String languageId = LocaleUtil.toLanguageId(locale);
496                    String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);
497    
498                    if (Validator.isNotNull(name)) {
499                            setName(LocalizationUtil.updateLocalization(getName(), "Name",
500                                            name, languageId, defaultLanguageId));
501                    }
502                    else {
503                            setName(LocalizationUtil.removeLocalization(getName(), "Name",
504                                            languageId));
505                    }
506            }
507    
508            public void setNameCurrentLanguageId(String languageId) {
509                    _nameCurrentLanguageId = languageId;
510            }
511    
512            public void setNameMap(Map<Locale, String> nameMap) {
513                    setNameMap(nameMap, LocaleUtil.getDefault());
514            }
515    
516            public void setNameMap(Map<Locale, String> nameMap, Locale defaultLocale) {
517                    if (nameMap == null) {
518                            return;
519                    }
520    
521                    Locale[] locales = LanguageUtil.getAvailableLocales();
522    
523                    for (Locale locale : locales) {
524                            String name = nameMap.get(locale);
525    
526                            setName(name, locale, defaultLocale);
527                    }
528            }
529    
530            @JSON
531            public String getDescription() {
532                    if (_description == null) {
533                            return StringPool.BLANK;
534                    }
535                    else {
536                            return _description;
537                    }
538            }
539    
540            public String getDescription(Locale locale) {
541                    String languageId = LocaleUtil.toLanguageId(locale);
542    
543                    return getDescription(languageId);
544            }
545    
546            public String getDescription(Locale locale, boolean useDefault) {
547                    String languageId = LocaleUtil.toLanguageId(locale);
548    
549                    return getDescription(languageId, useDefault);
550            }
551    
552            public String getDescription(String languageId) {
553                    return LocalizationUtil.getLocalization(getDescription(), languageId);
554            }
555    
556            public String getDescription(String languageId, boolean useDefault) {
557                    return LocalizationUtil.getLocalization(getDescription(), languageId,
558                            useDefault);
559            }
560    
561            public String getDescriptionCurrentLanguageId() {
562                    return _descriptionCurrentLanguageId;
563            }
564    
565            @JSON
566            public String getDescriptionCurrentValue() {
567                    Locale locale = getLocale(_descriptionCurrentLanguageId);
568    
569                    return getDescription(locale);
570            }
571    
572            public Map<Locale, String> getDescriptionMap() {
573                    return LocalizationUtil.getLocalizationMap(getDescription());
574            }
575    
576            public void setDescription(String description) {
577                    _description = description;
578            }
579    
580            public void setDescription(String description, Locale locale) {
581                    setDescription(description, locale, LocaleUtil.getDefault());
582            }
583    
584            public void setDescription(String description, Locale locale,
585                    Locale defaultLocale) {
586                    String languageId = LocaleUtil.toLanguageId(locale);
587                    String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);
588    
589                    if (Validator.isNotNull(description)) {
590                            setDescription(LocalizationUtil.updateLocalization(
591                                            getDescription(), "Description", description, languageId,
592                                            defaultLanguageId));
593                    }
594                    else {
595                            setDescription(LocalizationUtil.removeLocalization(
596                                            getDescription(), "Description", languageId));
597                    }
598            }
599    
600            public void setDescriptionCurrentLanguageId(String languageId) {
601                    _descriptionCurrentLanguageId = languageId;
602            }
603    
604            public void setDescriptionMap(Map<Locale, String> descriptionMap) {
605                    setDescriptionMap(descriptionMap, LocaleUtil.getDefault());
606            }
607    
608            public void setDescriptionMap(Map<Locale, String> descriptionMap,
609                    Locale defaultLocale) {
610                    if (descriptionMap == null) {
611                            return;
612                    }
613    
614                    Locale[] locales = LanguageUtil.getAvailableLocales();
615    
616                    for (Locale locale : locales) {
617                            String description = descriptionMap.get(locale);
618    
619                            setDescription(description, locale, defaultLocale);
620                    }
621            }
622    
623            @JSON
624            public String getType() {
625                    if (_type == null) {
626                            return StringPool.BLANK;
627                    }
628                    else {
629                            return _type;
630                    }
631            }
632    
633            public void setType(String type) {
634                    _columnBitmask |= TYPE_COLUMN_BITMASK;
635    
636                    if (_originalType == null) {
637                            _originalType = _type;
638                    }
639    
640                    _type = type;
641            }
642    
643            public String getOriginalType() {
644                    return GetterUtil.getString(_originalType);
645            }
646    
647            @JSON
648            public String getMode() {
649                    if (_mode == null) {
650                            return StringPool.BLANK;
651                    }
652                    else {
653                            return _mode;
654                    }
655            }
656    
657            public void setMode(String mode) {
658                    _columnBitmask |= MODE_COLUMN_BITMASK;
659    
660                    if (_originalMode == null) {
661                            _originalMode = _mode;
662                    }
663    
664                    _mode = mode;
665            }
666    
667            public String getOriginalMode() {
668                    return GetterUtil.getString(_originalMode);
669            }
670    
671            @JSON
672            public String getLanguage() {
673                    if (_language == null) {
674                            return StringPool.BLANK;
675                    }
676                    else {
677                            return _language;
678                    }
679            }
680    
681            public void setLanguage(String language) {
682                    _columnBitmask |= LANGUAGE_COLUMN_BITMASK;
683    
684                    if (_originalLanguage == null) {
685                            _originalLanguage = _language;
686                    }
687    
688                    _language = language;
689            }
690    
691            public String getOriginalLanguage() {
692                    return GetterUtil.getString(_originalLanguage);
693            }
694    
695            @JSON
696            public String getScript() {
697                    if (_script == null) {
698                            return StringPool.BLANK;
699                    }
700                    else {
701                            return _script;
702                    }
703            }
704    
705            public void setScript(String script) {
706                    _script = script;
707            }
708    
709            public long getColumnBitmask() {
710                    return _columnBitmask;
711            }
712    
713            @Override
714            public ExpandoBridge getExpandoBridge() {
715                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
716                            DDMTemplate.class.getName(), getPrimaryKey());
717            }
718    
719            @Override
720            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
721                    ExpandoBridge expandoBridge = getExpandoBridge();
722    
723                    expandoBridge.setAttributes(serviceContext);
724            }
725    
726            @SuppressWarnings("unused")
727            public void prepareLocalizedFieldsForImport(Locale defaultImportLocale)
728                    throws LocaleException {
729                    setName(getName(defaultImportLocale), defaultImportLocale,
730                            defaultImportLocale);
731                    setDescription(getDescription(defaultImportLocale),
732                            defaultImportLocale, defaultImportLocale);
733            }
734    
735            @Override
736            public DDMTemplate toEscapedModel() {
737                    if (_escapedModel == null) {
738                            _escapedModel = (DDMTemplate)ProxyUtil.newProxyInstance(_classLoader,
739                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
740                    }
741    
742                    return _escapedModel;
743            }
744    
745            public DDMTemplate toUnescapedModel() {
746                    return (DDMTemplate)this;
747            }
748    
749            @Override
750            public Object clone() {
751                    DDMTemplateImpl ddmTemplateImpl = new DDMTemplateImpl();
752    
753                    ddmTemplateImpl.setUuid(getUuid());
754                    ddmTemplateImpl.setTemplateId(getTemplateId());
755                    ddmTemplateImpl.setGroupId(getGroupId());
756                    ddmTemplateImpl.setCompanyId(getCompanyId());
757                    ddmTemplateImpl.setUserId(getUserId());
758                    ddmTemplateImpl.setUserName(getUserName());
759                    ddmTemplateImpl.setCreateDate(getCreateDate());
760                    ddmTemplateImpl.setModifiedDate(getModifiedDate());
761                    ddmTemplateImpl.setStructureId(getStructureId());
762                    ddmTemplateImpl.setName(getName());
763                    ddmTemplateImpl.setDescription(getDescription());
764                    ddmTemplateImpl.setType(getType());
765                    ddmTemplateImpl.setMode(getMode());
766                    ddmTemplateImpl.setLanguage(getLanguage());
767                    ddmTemplateImpl.setScript(getScript());
768    
769                    ddmTemplateImpl.resetOriginalValues();
770    
771                    return ddmTemplateImpl;
772            }
773    
774            public int compareTo(DDMTemplate ddmTemplate) {
775                    long primaryKey = ddmTemplate.getPrimaryKey();
776    
777                    if (getPrimaryKey() < primaryKey) {
778                            return -1;
779                    }
780                    else if (getPrimaryKey() > primaryKey) {
781                            return 1;
782                    }
783                    else {
784                            return 0;
785                    }
786            }
787    
788            @Override
789            public boolean equals(Object obj) {
790                    if (this == obj) {
791                            return true;
792                    }
793    
794                    if (!(obj instanceof DDMTemplate)) {
795                            return false;
796                    }
797    
798                    DDMTemplate ddmTemplate = (DDMTemplate)obj;
799    
800                    long primaryKey = ddmTemplate.getPrimaryKey();
801    
802                    if (getPrimaryKey() == primaryKey) {
803                            return true;
804                    }
805                    else {
806                            return false;
807                    }
808            }
809    
810            @Override
811            public int hashCode() {
812                    return (int)getPrimaryKey();
813            }
814    
815            @Override
816            public void resetOriginalValues() {
817                    DDMTemplateModelImpl ddmTemplateModelImpl = this;
818    
819                    ddmTemplateModelImpl._originalUuid = ddmTemplateModelImpl._uuid;
820    
821                    ddmTemplateModelImpl._originalGroupId = ddmTemplateModelImpl._groupId;
822    
823                    ddmTemplateModelImpl._setOriginalGroupId = false;
824    
825                    ddmTemplateModelImpl._originalStructureId = ddmTemplateModelImpl._structureId;
826    
827                    ddmTemplateModelImpl._setOriginalStructureId = false;
828    
829                    ddmTemplateModelImpl._originalType = ddmTemplateModelImpl._type;
830    
831                    ddmTemplateModelImpl._originalMode = ddmTemplateModelImpl._mode;
832    
833                    ddmTemplateModelImpl._originalLanguage = ddmTemplateModelImpl._language;
834    
835                    ddmTemplateModelImpl._columnBitmask = 0;
836            }
837    
838            @Override
839            public CacheModel<DDMTemplate> toCacheModel() {
840                    DDMTemplateCacheModel ddmTemplateCacheModel = new DDMTemplateCacheModel();
841    
842                    ddmTemplateCacheModel.uuid = getUuid();
843    
844                    String uuid = ddmTemplateCacheModel.uuid;
845    
846                    if ((uuid != null) && (uuid.length() == 0)) {
847                            ddmTemplateCacheModel.uuid = null;
848                    }
849    
850                    ddmTemplateCacheModel.templateId = getTemplateId();
851    
852                    ddmTemplateCacheModel.groupId = getGroupId();
853    
854                    ddmTemplateCacheModel.companyId = getCompanyId();
855    
856                    ddmTemplateCacheModel.userId = getUserId();
857    
858                    ddmTemplateCacheModel.userName = getUserName();
859    
860                    String userName = ddmTemplateCacheModel.userName;
861    
862                    if ((userName != null) && (userName.length() == 0)) {
863                            ddmTemplateCacheModel.userName = null;
864                    }
865    
866                    Date createDate = getCreateDate();
867    
868                    if (createDate != null) {
869                            ddmTemplateCacheModel.createDate = createDate.getTime();
870                    }
871                    else {
872                            ddmTemplateCacheModel.createDate = Long.MIN_VALUE;
873                    }
874    
875                    Date modifiedDate = getModifiedDate();
876    
877                    if (modifiedDate != null) {
878                            ddmTemplateCacheModel.modifiedDate = modifiedDate.getTime();
879                    }
880                    else {
881                            ddmTemplateCacheModel.modifiedDate = Long.MIN_VALUE;
882                    }
883    
884                    ddmTemplateCacheModel.structureId = getStructureId();
885    
886                    ddmTemplateCacheModel.name = getName();
887    
888                    String name = ddmTemplateCacheModel.name;
889    
890                    if ((name != null) && (name.length() == 0)) {
891                            ddmTemplateCacheModel.name = null;
892                    }
893    
894                    ddmTemplateCacheModel.description = getDescription();
895    
896                    String description = ddmTemplateCacheModel.description;
897    
898                    if ((description != null) && (description.length() == 0)) {
899                            ddmTemplateCacheModel.description = null;
900                    }
901    
902                    ddmTemplateCacheModel.type = getType();
903    
904                    String type = ddmTemplateCacheModel.type;
905    
906                    if ((type != null) && (type.length() == 0)) {
907                            ddmTemplateCacheModel.type = null;
908                    }
909    
910                    ddmTemplateCacheModel.mode = getMode();
911    
912                    String mode = ddmTemplateCacheModel.mode;
913    
914                    if ((mode != null) && (mode.length() == 0)) {
915                            ddmTemplateCacheModel.mode = null;
916                    }
917    
918                    ddmTemplateCacheModel.language = getLanguage();
919    
920                    String language = ddmTemplateCacheModel.language;
921    
922                    if ((language != null) && (language.length() == 0)) {
923                            ddmTemplateCacheModel.language = null;
924                    }
925    
926                    ddmTemplateCacheModel.script = getScript();
927    
928                    String script = ddmTemplateCacheModel.script;
929    
930                    if ((script != null) && (script.length() == 0)) {
931                            ddmTemplateCacheModel.script = null;
932                    }
933    
934                    return ddmTemplateCacheModel;
935            }
936    
937            @Override
938            public String toString() {
939                    StringBundler sb = new StringBundler(31);
940    
941                    sb.append("{uuid=");
942                    sb.append(getUuid());
943                    sb.append(", templateId=");
944                    sb.append(getTemplateId());
945                    sb.append(", groupId=");
946                    sb.append(getGroupId());
947                    sb.append(", companyId=");
948                    sb.append(getCompanyId());
949                    sb.append(", userId=");
950                    sb.append(getUserId());
951                    sb.append(", userName=");
952                    sb.append(getUserName());
953                    sb.append(", createDate=");
954                    sb.append(getCreateDate());
955                    sb.append(", modifiedDate=");
956                    sb.append(getModifiedDate());
957                    sb.append(", structureId=");
958                    sb.append(getStructureId());
959                    sb.append(", name=");
960                    sb.append(getName());
961                    sb.append(", description=");
962                    sb.append(getDescription());
963                    sb.append(", type=");
964                    sb.append(getType());
965                    sb.append(", mode=");
966                    sb.append(getMode());
967                    sb.append(", language=");
968                    sb.append(getLanguage());
969                    sb.append(", script=");
970                    sb.append(getScript());
971                    sb.append("}");
972    
973                    return sb.toString();
974            }
975    
976            public String toXmlString() {
977                    StringBundler sb = new StringBundler(49);
978    
979                    sb.append("<model><model-name>");
980                    sb.append("com.liferay.portlet.dynamicdatamapping.model.DDMTemplate");
981                    sb.append("</model-name>");
982    
983                    sb.append(
984                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
985                    sb.append(getUuid());
986                    sb.append("]]></column-value></column>");
987                    sb.append(
988                            "<column><column-name>templateId</column-name><column-value><![CDATA[");
989                    sb.append(getTemplateId());
990                    sb.append("]]></column-value></column>");
991                    sb.append(
992                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
993                    sb.append(getGroupId());
994                    sb.append("]]></column-value></column>");
995                    sb.append(
996                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
997                    sb.append(getCompanyId());
998                    sb.append("]]></column-value></column>");
999                    sb.append(
1000                            "<column><column-name>userId</column-name><column-value><![CDATA[");
1001                    sb.append(getUserId());
1002                    sb.append("]]></column-value></column>");
1003                    sb.append(
1004                            "<column><column-name>userName</column-name><column-value><![CDATA[");
1005                    sb.append(getUserName());
1006                    sb.append("]]></column-value></column>");
1007                    sb.append(
1008                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
1009                    sb.append(getCreateDate());
1010                    sb.append("]]></column-value></column>");
1011                    sb.append(
1012                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
1013                    sb.append(getModifiedDate());
1014                    sb.append("]]></column-value></column>");
1015                    sb.append(
1016                            "<column><column-name>structureId</column-name><column-value><![CDATA[");
1017                    sb.append(getStructureId());
1018                    sb.append("]]></column-value></column>");
1019                    sb.append(
1020                            "<column><column-name>name</column-name><column-value><![CDATA[");
1021                    sb.append(getName());
1022                    sb.append("]]></column-value></column>");
1023                    sb.append(
1024                            "<column><column-name>description</column-name><column-value><![CDATA[");
1025                    sb.append(getDescription());
1026                    sb.append("]]></column-value></column>");
1027                    sb.append(
1028                            "<column><column-name>type</column-name><column-value><![CDATA[");
1029                    sb.append(getType());
1030                    sb.append("]]></column-value></column>");
1031                    sb.append(
1032                            "<column><column-name>mode</column-name><column-value><![CDATA[");
1033                    sb.append(getMode());
1034                    sb.append("]]></column-value></column>");
1035                    sb.append(
1036                            "<column><column-name>language</column-name><column-value><![CDATA[");
1037                    sb.append(getLanguage());
1038                    sb.append("]]></column-value></column>");
1039                    sb.append(
1040                            "<column><column-name>script</column-name><column-value><![CDATA[");
1041                    sb.append(getScript());
1042                    sb.append("]]></column-value></column>");
1043    
1044                    sb.append("</model>");
1045    
1046                    return sb.toString();
1047            }
1048    
1049            private static ClassLoader _classLoader = DDMTemplate.class.getClassLoader();
1050            private static Class<?>[] _escapedModelInterfaces = new Class[] {
1051                            DDMTemplate.class
1052                    };
1053            private String _uuid;
1054            private String _originalUuid;
1055            private long _templateId;
1056            private long _groupId;
1057            private long _originalGroupId;
1058            private boolean _setOriginalGroupId;
1059            private long _companyId;
1060            private long _userId;
1061            private String _userUuid;
1062            private String _userName;
1063            private Date _createDate;
1064            private Date _modifiedDate;
1065            private long _structureId;
1066            private long _originalStructureId;
1067            private boolean _setOriginalStructureId;
1068            private String _name;
1069            private String _nameCurrentLanguageId;
1070            private String _description;
1071            private String _descriptionCurrentLanguageId;
1072            private String _type;
1073            private String _originalType;
1074            private String _mode;
1075            private String _originalMode;
1076            private String _language;
1077            private String _originalLanguage;
1078            private String _script;
1079            private long _columnBitmask;
1080            private DDMTemplate _escapedModel;
1081    }