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.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.json.JSON;
020    import com.liferay.portal.kernel.language.LanguageUtil;
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.DDMContent;
034    import com.liferay.portlet.dynamicdatamapping.model.DDMContentModel;
035    import com.liferay.portlet.expando.model.ExpandoBridge;
036    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
037    
038    import java.io.Serializable;
039    
040    import java.sql.Types;
041    
042    import java.util.Date;
043    import java.util.Locale;
044    import java.util.Map;
045    
046    /**
047     * The base model implementation for the DDMContent service. Represents a row in the "DDMContent" database table, with each column mapped to a property of this class.
048     *
049     * <p>
050     * This implementation and its corresponding interface {@link com.liferay.portlet.dynamicdatamapping.model.DDMContentModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link DDMContentImpl}.
051     * </p>
052     *
053     * @author Brian Wing Shun Chan
054     * @see DDMContentImpl
055     * @see com.liferay.portlet.dynamicdatamapping.model.DDMContent
056     * @see com.liferay.portlet.dynamicdatamapping.model.DDMContentModel
057     * @generated
058     */
059    public class DDMContentModelImpl extends BaseModelImpl<DDMContent>
060            implements DDMContentModel {
061            /*
062             * NOTE FOR DEVELOPERS:
063             *
064             * Never modify or reference this class directly. All methods that expect a d d m content model instance should use the {@link com.liferay.portlet.dynamicdatamapping.model.DDMContent} interface instead.
065             */
066            public static final String TABLE_NAME = "DDMContent";
067            public static final Object[][] TABLE_COLUMNS = {
068                            { "uuid_", Types.VARCHAR },
069                            { "contentId", Types.BIGINT },
070                            { "groupId", Types.BIGINT },
071                            { "companyId", Types.BIGINT },
072                            { "userId", Types.BIGINT },
073                            { "userName", Types.VARCHAR },
074                            { "createDate", Types.TIMESTAMP },
075                            { "modifiedDate", Types.TIMESTAMP },
076                            { "name", Types.VARCHAR },
077                            { "description", Types.VARCHAR },
078                            { "xml", Types.CLOB }
079                    };
080            public static final String TABLE_SQL_CREATE = "create table DDMContent (uuid_ VARCHAR(75) null,contentId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,name STRING null,description STRING null,xml TEXT null)";
081            public static final String TABLE_SQL_DROP = "drop table DDMContent";
082            public static final String DATA_SOURCE = "liferayDataSource";
083            public static final String SESSION_FACTORY = "liferaySessionFactory";
084            public static final String TX_MANAGER = "liferayTransactionManager";
085            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
086                                    "value.object.entity.cache.enabled.com.liferay.portlet.dynamicdatamapping.model.DDMContent"),
087                            true);
088            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
089                                    "value.object.finder.cache.enabled.com.liferay.portlet.dynamicdatamapping.model.DDMContent"),
090                            true);
091            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
092                                    "value.object.column.bitmask.enabled.com.liferay.portlet.dynamicdatamapping.model.DDMContent"),
093                            true);
094            public static long COMPANYID_COLUMN_BITMASK = 1L;
095            public static long GROUPID_COLUMN_BITMASK = 2L;
096            public static long UUID_COLUMN_BITMASK = 4L;
097            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
098                                    "lock.expiration.time.com.liferay.portlet.dynamicdatamapping.model.DDMContent"));
099    
100            public DDMContentModelImpl() {
101            }
102    
103            public long getPrimaryKey() {
104                    return _contentId;
105            }
106    
107            public void setPrimaryKey(long primaryKey) {
108                    setContentId(primaryKey);
109            }
110    
111            public Serializable getPrimaryKeyObj() {
112                    return new Long(_contentId);
113            }
114    
115            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
116                    setPrimaryKey(((Long)primaryKeyObj).longValue());
117            }
118    
119            public Class<?> getModelClass() {
120                    return DDMContent.class;
121            }
122    
123            public String getModelClassName() {
124                    return DDMContent.class.getName();
125            }
126    
127            public String getUuid() {
128                    if (_uuid == null) {
129                            return StringPool.BLANK;
130                    }
131                    else {
132                            return _uuid;
133                    }
134            }
135    
136            public void setUuid(String uuid) {
137                    if (_originalUuid == null) {
138                            _originalUuid = _uuid;
139                    }
140    
141                    _uuid = uuid;
142            }
143    
144            public String getOriginalUuid() {
145                    return GetterUtil.getString(_originalUuid);
146            }
147    
148            public long getContentId() {
149                    return _contentId;
150            }
151    
152            public void setContentId(long contentId) {
153                    _contentId = contentId;
154            }
155    
156            public long getGroupId() {
157                    return _groupId;
158            }
159    
160            public void setGroupId(long groupId) {
161                    _columnBitmask |= GROUPID_COLUMN_BITMASK;
162    
163                    if (!_setOriginalGroupId) {
164                            _setOriginalGroupId = true;
165    
166                            _originalGroupId = _groupId;
167                    }
168    
169                    _groupId = groupId;
170            }
171    
172            public long getOriginalGroupId() {
173                    return _originalGroupId;
174            }
175    
176            public long getCompanyId() {
177                    return _companyId;
178            }
179    
180            public void setCompanyId(long companyId) {
181                    _columnBitmask |= COMPANYID_COLUMN_BITMASK;
182    
183                    if (!_setOriginalCompanyId) {
184                            _setOriginalCompanyId = true;
185    
186                            _originalCompanyId = _companyId;
187                    }
188    
189                    _companyId = companyId;
190            }
191    
192            public long getOriginalCompanyId() {
193                    return _originalCompanyId;
194            }
195    
196            public long getUserId() {
197                    return _userId;
198            }
199    
200            public void setUserId(long userId) {
201                    _userId = userId;
202            }
203    
204            public String getUserUuid() throws SystemException {
205                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
206            }
207    
208            public void setUserUuid(String userUuid) {
209                    _userUuid = userUuid;
210            }
211    
212            public String getUserName() {
213                    if (_userName == null) {
214                            return StringPool.BLANK;
215                    }
216                    else {
217                            return _userName;
218                    }
219            }
220    
221            public void setUserName(String userName) {
222                    _userName = userName;
223            }
224    
225            public Date getCreateDate() {
226                    return _createDate;
227            }
228    
229            public void setCreateDate(Date createDate) {
230                    _createDate = createDate;
231            }
232    
233            public Date getModifiedDate() {
234                    return _modifiedDate;
235            }
236    
237            public void setModifiedDate(Date modifiedDate) {
238                    _modifiedDate = modifiedDate;
239            }
240    
241            public String getName() {
242                    if (_name == null) {
243                            return StringPool.BLANK;
244                    }
245                    else {
246                            return _name;
247                    }
248            }
249    
250            public String getName(Locale locale) {
251                    String languageId = LocaleUtil.toLanguageId(locale);
252    
253                    return getName(languageId);
254            }
255    
256            public String getName(Locale locale, boolean useDefault) {
257                    String languageId = LocaleUtil.toLanguageId(locale);
258    
259                    return getName(languageId, useDefault);
260            }
261    
262            public String getName(String languageId) {
263                    return LocalizationUtil.getLocalization(getName(), languageId);
264            }
265    
266            public String getName(String languageId, boolean useDefault) {
267                    return LocalizationUtil.getLocalization(getName(), languageId,
268                            useDefault);
269            }
270    
271            public String getNameCurrentLanguageId() {
272                    return _nameCurrentLanguageId;
273            }
274    
275            @JSON
276            public String getNameCurrentValue() {
277                    Locale locale = getLocale(_nameCurrentLanguageId);
278    
279                    return getName(locale);
280            }
281    
282            public Map<Locale, String> getNameMap() {
283                    return LocalizationUtil.getLocalizationMap(getName());
284            }
285    
286            public void setName(String name) {
287                    _name = name;
288            }
289    
290            public void setName(String name, Locale locale) {
291                    setName(name, locale, LocaleUtil.getDefault());
292            }
293    
294            public void setName(String name, Locale locale, Locale defaultLocale) {
295                    String languageId = LocaleUtil.toLanguageId(locale);
296                    String defaultLanguageId = LocaleUtil.toLanguageId(defaultLocale);
297    
298                    if (Validator.isNotNull(name)) {
299                            setName(LocalizationUtil.updateLocalization(getName(), "Name",
300                                            name, languageId, defaultLanguageId));
301                    }
302                    else {
303                            setName(LocalizationUtil.removeLocalization(getName(), "Name",
304                                            languageId));
305                    }
306            }
307    
308            public void setNameCurrentLanguageId(String languageId) {
309                    _nameCurrentLanguageId = languageId;
310            }
311    
312            public void setNameMap(Map<Locale, String> nameMap) {
313                    setNameMap(nameMap, LocaleUtil.getDefault());
314            }
315    
316            public void setNameMap(Map<Locale, String> nameMap, Locale defaultLocale) {
317                    if (nameMap == null) {
318                            return;
319                    }
320    
321                    Locale[] locales = LanguageUtil.getAvailableLocales();
322    
323                    for (Locale locale : locales) {
324                            String name = nameMap.get(locale);
325    
326                            setName(name, locale, defaultLocale);
327                    }
328            }
329    
330            public String getDescription() {
331                    if (_description == null) {
332                            return StringPool.BLANK;
333                    }
334                    else {
335                            return _description;
336                    }
337            }
338    
339            public void setDescription(String description) {
340                    _description = description;
341            }
342    
343            public String getXml() {
344                    if (_xml == null) {
345                            return StringPool.BLANK;
346                    }
347                    else {
348                            return _xml;
349                    }
350            }
351    
352            public void setXml(String xml) {
353                    _xml = xml;
354            }
355    
356            public long getColumnBitmask() {
357                    return _columnBitmask;
358            }
359    
360            @Override
361            public DDMContent toEscapedModel() {
362                    if (_escapedModelProxy == null) {
363                            _escapedModelProxy = (DDMContent)ProxyUtil.newProxyInstance(_classLoader,
364                                            _escapedModelProxyInterfaces,
365                                            new AutoEscapeBeanHandler(this));
366                    }
367    
368                    return _escapedModelProxy;
369            }
370    
371            @Override
372            public ExpandoBridge getExpandoBridge() {
373                    if (_expandoBridge == null) {
374                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
375                                            DDMContent.class.getName(), getPrimaryKey());
376                    }
377    
378                    return _expandoBridge;
379            }
380    
381            @Override
382            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
383                    getExpandoBridge().setAttributes(serviceContext);
384            }
385    
386            @Override
387            public Object clone() {
388                    DDMContentImpl ddmContentImpl = new DDMContentImpl();
389    
390                    ddmContentImpl.setUuid(getUuid());
391                    ddmContentImpl.setContentId(getContentId());
392                    ddmContentImpl.setGroupId(getGroupId());
393                    ddmContentImpl.setCompanyId(getCompanyId());
394                    ddmContentImpl.setUserId(getUserId());
395                    ddmContentImpl.setUserName(getUserName());
396                    ddmContentImpl.setCreateDate(getCreateDate());
397                    ddmContentImpl.setModifiedDate(getModifiedDate());
398                    ddmContentImpl.setName(getName());
399                    ddmContentImpl.setDescription(getDescription());
400                    ddmContentImpl.setXml(getXml());
401    
402                    ddmContentImpl.resetOriginalValues();
403    
404                    return ddmContentImpl;
405            }
406    
407            public int compareTo(DDMContent ddmContent) {
408                    long primaryKey = ddmContent.getPrimaryKey();
409    
410                    if (getPrimaryKey() < primaryKey) {
411                            return -1;
412                    }
413                    else if (getPrimaryKey() > primaryKey) {
414                            return 1;
415                    }
416                    else {
417                            return 0;
418                    }
419            }
420    
421            @Override
422            public boolean equals(Object obj) {
423                    if (obj == null) {
424                            return false;
425                    }
426    
427                    DDMContent ddmContent = null;
428    
429                    try {
430                            ddmContent = (DDMContent)obj;
431                    }
432                    catch (ClassCastException cce) {
433                            return false;
434                    }
435    
436                    long primaryKey = ddmContent.getPrimaryKey();
437    
438                    if (getPrimaryKey() == primaryKey) {
439                            return true;
440                    }
441                    else {
442                            return false;
443                    }
444            }
445    
446            @Override
447            public int hashCode() {
448                    return (int)getPrimaryKey();
449            }
450    
451            @Override
452            public void resetOriginalValues() {
453                    DDMContentModelImpl ddmContentModelImpl = this;
454    
455                    ddmContentModelImpl._originalUuid = ddmContentModelImpl._uuid;
456    
457                    ddmContentModelImpl._originalGroupId = ddmContentModelImpl._groupId;
458    
459                    ddmContentModelImpl._setOriginalGroupId = false;
460    
461                    ddmContentModelImpl._originalCompanyId = ddmContentModelImpl._companyId;
462    
463                    ddmContentModelImpl._setOriginalCompanyId = false;
464    
465                    ddmContentModelImpl._columnBitmask = 0;
466            }
467    
468            @Override
469            public CacheModel<DDMContent> toCacheModel() {
470                    DDMContentCacheModel ddmContentCacheModel = new DDMContentCacheModel();
471    
472                    ddmContentCacheModel.uuid = getUuid();
473    
474                    String uuid = ddmContentCacheModel.uuid;
475    
476                    if ((uuid != null) && (uuid.length() == 0)) {
477                            ddmContentCacheModel.uuid = null;
478                    }
479    
480                    ddmContentCacheModel.contentId = getContentId();
481    
482                    ddmContentCacheModel.groupId = getGroupId();
483    
484                    ddmContentCacheModel.companyId = getCompanyId();
485    
486                    ddmContentCacheModel.userId = getUserId();
487    
488                    ddmContentCacheModel.userName = getUserName();
489    
490                    String userName = ddmContentCacheModel.userName;
491    
492                    if ((userName != null) && (userName.length() == 0)) {
493                            ddmContentCacheModel.userName = null;
494                    }
495    
496                    Date createDate = getCreateDate();
497    
498                    if (createDate != null) {
499                            ddmContentCacheModel.createDate = createDate.getTime();
500                    }
501                    else {
502                            ddmContentCacheModel.createDate = Long.MIN_VALUE;
503                    }
504    
505                    Date modifiedDate = getModifiedDate();
506    
507                    if (modifiedDate != null) {
508                            ddmContentCacheModel.modifiedDate = modifiedDate.getTime();
509                    }
510                    else {
511                            ddmContentCacheModel.modifiedDate = Long.MIN_VALUE;
512                    }
513    
514                    ddmContentCacheModel.name = getName();
515    
516                    String name = ddmContentCacheModel.name;
517    
518                    if ((name != null) && (name.length() == 0)) {
519                            ddmContentCacheModel.name = null;
520                    }
521    
522                    ddmContentCacheModel.description = getDescription();
523    
524                    String description = ddmContentCacheModel.description;
525    
526                    if ((description != null) && (description.length() == 0)) {
527                            ddmContentCacheModel.description = null;
528                    }
529    
530                    ddmContentCacheModel.xml = getXml();
531    
532                    String xml = ddmContentCacheModel.xml;
533    
534                    if ((xml != null) && (xml.length() == 0)) {
535                            ddmContentCacheModel.xml = null;
536                    }
537    
538                    return ddmContentCacheModel;
539            }
540    
541            @Override
542            public String toString() {
543                    StringBundler sb = new StringBundler(23);
544    
545                    sb.append("{uuid=");
546                    sb.append(getUuid());
547                    sb.append(", contentId=");
548                    sb.append(getContentId());
549                    sb.append(", groupId=");
550                    sb.append(getGroupId());
551                    sb.append(", companyId=");
552                    sb.append(getCompanyId());
553                    sb.append(", userId=");
554                    sb.append(getUserId());
555                    sb.append(", userName=");
556                    sb.append(getUserName());
557                    sb.append(", createDate=");
558                    sb.append(getCreateDate());
559                    sb.append(", modifiedDate=");
560                    sb.append(getModifiedDate());
561                    sb.append(", name=");
562                    sb.append(getName());
563                    sb.append(", description=");
564                    sb.append(getDescription());
565                    sb.append(", xml=");
566                    sb.append(getXml());
567                    sb.append("}");
568    
569                    return sb.toString();
570            }
571    
572            public String toXmlString() {
573                    StringBundler sb = new StringBundler(37);
574    
575                    sb.append("<model><model-name>");
576                    sb.append("com.liferay.portlet.dynamicdatamapping.model.DDMContent");
577                    sb.append("</model-name>");
578    
579                    sb.append(
580                            "<column><column-name>uuid</column-name><column-value><![CDATA[");
581                    sb.append(getUuid());
582                    sb.append("]]></column-value></column>");
583                    sb.append(
584                            "<column><column-name>contentId</column-name><column-value><![CDATA[");
585                    sb.append(getContentId());
586                    sb.append("]]></column-value></column>");
587                    sb.append(
588                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
589                    sb.append(getGroupId());
590                    sb.append("]]></column-value></column>");
591                    sb.append(
592                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
593                    sb.append(getCompanyId());
594                    sb.append("]]></column-value></column>");
595                    sb.append(
596                            "<column><column-name>userId</column-name><column-value><![CDATA[");
597                    sb.append(getUserId());
598                    sb.append("]]></column-value></column>");
599                    sb.append(
600                            "<column><column-name>userName</column-name><column-value><![CDATA[");
601                    sb.append(getUserName());
602                    sb.append("]]></column-value></column>");
603                    sb.append(
604                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
605                    sb.append(getCreateDate());
606                    sb.append("]]></column-value></column>");
607                    sb.append(
608                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
609                    sb.append(getModifiedDate());
610                    sb.append("]]></column-value></column>");
611                    sb.append(
612                            "<column><column-name>name</column-name><column-value><![CDATA[");
613                    sb.append(getName());
614                    sb.append("]]></column-value></column>");
615                    sb.append(
616                            "<column><column-name>description</column-name><column-value><![CDATA[");
617                    sb.append(getDescription());
618                    sb.append("]]></column-value></column>");
619                    sb.append(
620                            "<column><column-name>xml</column-name><column-value><![CDATA[");
621                    sb.append(getXml());
622                    sb.append("]]></column-value></column>");
623    
624                    sb.append("</model>");
625    
626                    return sb.toString();
627            }
628    
629            private static ClassLoader _classLoader = DDMContent.class.getClassLoader();
630            private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
631                            DDMContent.class
632                    };
633            private String _uuid;
634            private String _originalUuid;
635            private long _contentId;
636            private long _groupId;
637            private long _originalGroupId;
638            private boolean _setOriginalGroupId;
639            private long _companyId;
640            private long _originalCompanyId;
641            private boolean _setOriginalCompanyId;
642            private long _userId;
643            private String _userUuid;
644            private String _userName;
645            private Date _createDate;
646            private Date _modifiedDate;
647            private String _name;
648            private String _nameCurrentLanguageId;
649            private String _description;
650            private String _xml;
651            private transient ExpandoBridge _expandoBridge;
652            private long _columnBitmask;
653            private DDMContent _escapedModelProxy;
654    }