001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.model.impl;
016    
017    import aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
020    import com.liferay.portal.kernel.json.JSON;
021    import com.liferay.portal.kernel.util.GetterUtil;
022    import com.liferay.portal.kernel.util.ProxyUtil;
023    import com.liferay.portal.kernel.util.StringBundler;
024    import com.liferay.portal.kernel.util.StringPool;
025    import com.liferay.portal.model.CacheModel;
026    import com.liferay.portal.model.PluginSetting;
027    import com.liferay.portal.model.PluginSettingModel;
028    import com.liferay.portal.model.PluginSettingSoap;
029    import com.liferay.portal.service.ServiceContext;
030    
031    import com.liferay.portlet.expando.model.ExpandoBridge;
032    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
033    
034    import java.io.Serializable;
035    
036    import java.sql.Types;
037    
038    import java.util.ArrayList;
039    import java.util.HashMap;
040    import java.util.List;
041    import java.util.Map;
042    
043    /**
044     * The base model implementation for the PluginSetting service. Represents a row in the "PluginSetting" database table, with each column mapped to a property of this class.
045     *
046     * <p>
047     * This implementation and its corresponding interface {@link PluginSettingModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link PluginSettingImpl}.
048     * </p>
049     *
050     * @author Brian Wing Shun Chan
051     * @see PluginSettingImpl
052     * @see PluginSetting
053     * @see PluginSettingModel
054     * @generated
055     */
056    @JSON(strict = true)
057    @ProviderType
058    public class PluginSettingModelImpl extends BaseModelImpl<PluginSetting>
059            implements PluginSettingModel {
060            /*
061             * NOTE FOR DEVELOPERS:
062             *
063             * Never modify or reference this class directly. All methods that expect a plugin setting model instance should use the {@link PluginSetting} interface instead.
064             */
065            public static final String TABLE_NAME = "PluginSetting";
066            public static final Object[][] TABLE_COLUMNS = {
067                            { "mvccVersion", Types.BIGINT },
068                            { "pluginSettingId", Types.BIGINT },
069                            { "companyId", Types.BIGINT },
070                            { "pluginId", Types.VARCHAR },
071                            { "pluginType", Types.VARCHAR },
072                            { "roles", Types.VARCHAR },
073                            { "active_", Types.BOOLEAN }
074                    };
075            public static final Map<String, Integer> TABLE_COLUMNS_MAP = new HashMap<String, Integer>();
076    
077            static {
078                    TABLE_COLUMNS_MAP.put("mvccVersion", Types.BIGINT);
079                    TABLE_COLUMNS_MAP.put("pluginSettingId", Types.BIGINT);
080                    TABLE_COLUMNS_MAP.put("companyId", Types.BIGINT);
081                    TABLE_COLUMNS_MAP.put("pluginId", Types.VARCHAR);
082                    TABLE_COLUMNS_MAP.put("pluginType", Types.VARCHAR);
083                    TABLE_COLUMNS_MAP.put("roles", Types.VARCHAR);
084                    TABLE_COLUMNS_MAP.put("active_", Types.BOOLEAN);
085            }
086    
087            public static final String TABLE_SQL_CREATE = "create table PluginSetting (mvccVersion LONG default 0,pluginSettingId LONG not null primary key,companyId LONG,pluginId VARCHAR(75) null,pluginType VARCHAR(75) null,roles STRING null,active_ BOOLEAN)";
088            public static final String TABLE_SQL_DROP = "drop table PluginSetting";
089            public static final String ORDER_BY_JPQL = " ORDER BY pluginSetting.pluginSettingId ASC";
090            public static final String ORDER_BY_SQL = " ORDER BY PluginSetting.pluginSettingId ASC";
091            public static final String DATA_SOURCE = "liferayDataSource";
092            public static final String SESSION_FACTORY = "liferaySessionFactory";
093            public static final String TX_MANAGER = "liferayTransactionManager";
094            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
095                                    "value.object.entity.cache.enabled.com.liferay.portal.model.PluginSetting"),
096                            true);
097            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
098                                    "value.object.finder.cache.enabled.com.liferay.portal.model.PluginSetting"),
099                            true);
100            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
101                                    "value.object.column.bitmask.enabled.com.liferay.portal.model.PluginSetting"),
102                            true);
103            public static final long COMPANYID_COLUMN_BITMASK = 1L;
104            public static final long PLUGINID_COLUMN_BITMASK = 2L;
105            public static final long PLUGINTYPE_COLUMN_BITMASK = 4L;
106            public static final long PLUGINSETTINGID_COLUMN_BITMASK = 8L;
107    
108            /**
109             * Converts the soap model instance into a normal model instance.
110             *
111             * @param soapModel the soap model instance to convert
112             * @return the normal model instance
113             */
114            public static PluginSetting toModel(PluginSettingSoap soapModel) {
115                    if (soapModel == null) {
116                            return null;
117                    }
118    
119                    PluginSetting model = new PluginSettingImpl();
120    
121                    model.setMvccVersion(soapModel.getMvccVersion());
122                    model.setPluginSettingId(soapModel.getPluginSettingId());
123                    model.setCompanyId(soapModel.getCompanyId());
124                    model.setPluginId(soapModel.getPluginId());
125                    model.setPluginType(soapModel.getPluginType());
126                    model.setRoles(soapModel.getRoles());
127                    model.setActive(soapModel.getActive());
128    
129                    return model;
130            }
131    
132            /**
133             * Converts the soap model instances into normal model instances.
134             *
135             * @param soapModels the soap model instances to convert
136             * @return the normal model instances
137             */
138            public static List<PluginSetting> toModels(PluginSettingSoap[] soapModels) {
139                    if (soapModels == null) {
140                            return null;
141                    }
142    
143                    List<PluginSetting> models = new ArrayList<PluginSetting>(soapModels.length);
144    
145                    for (PluginSettingSoap soapModel : soapModels) {
146                            models.add(toModel(soapModel));
147                    }
148    
149                    return models;
150            }
151    
152            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
153                                    "lock.expiration.time.com.liferay.portal.model.PluginSetting"));
154    
155            public PluginSettingModelImpl() {
156            }
157    
158            @Override
159            public long getPrimaryKey() {
160                    return _pluginSettingId;
161            }
162    
163            @Override
164            public void setPrimaryKey(long primaryKey) {
165                    setPluginSettingId(primaryKey);
166            }
167    
168            @Override
169            public Serializable getPrimaryKeyObj() {
170                    return _pluginSettingId;
171            }
172    
173            @Override
174            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
175                    setPrimaryKey(((Long)primaryKeyObj).longValue());
176            }
177    
178            @Override
179            public Class<?> getModelClass() {
180                    return PluginSetting.class;
181            }
182    
183            @Override
184            public String getModelClassName() {
185                    return PluginSetting.class.getName();
186            }
187    
188            @Override
189            public Map<String, Object> getModelAttributes() {
190                    Map<String, Object> attributes = new HashMap<String, Object>();
191    
192                    attributes.put("mvccVersion", getMvccVersion());
193                    attributes.put("pluginSettingId", getPluginSettingId());
194                    attributes.put("companyId", getCompanyId());
195                    attributes.put("pluginId", getPluginId());
196                    attributes.put("pluginType", getPluginType());
197                    attributes.put("roles", getRoles());
198                    attributes.put("active", getActive());
199    
200                    attributes.put("entityCacheEnabled", isEntityCacheEnabled());
201                    attributes.put("finderCacheEnabled", isFinderCacheEnabled());
202    
203                    return attributes;
204            }
205    
206            @Override
207            public void setModelAttributes(Map<String, Object> attributes) {
208                    Long mvccVersion = (Long)attributes.get("mvccVersion");
209    
210                    if (mvccVersion != null) {
211                            setMvccVersion(mvccVersion);
212                    }
213    
214                    Long pluginSettingId = (Long)attributes.get("pluginSettingId");
215    
216                    if (pluginSettingId != null) {
217                            setPluginSettingId(pluginSettingId);
218                    }
219    
220                    Long companyId = (Long)attributes.get("companyId");
221    
222                    if (companyId != null) {
223                            setCompanyId(companyId);
224                    }
225    
226                    String pluginId = (String)attributes.get("pluginId");
227    
228                    if (pluginId != null) {
229                            setPluginId(pluginId);
230                    }
231    
232                    String pluginType = (String)attributes.get("pluginType");
233    
234                    if (pluginType != null) {
235                            setPluginType(pluginType);
236                    }
237    
238                    String roles = (String)attributes.get("roles");
239    
240                    if (roles != null) {
241                            setRoles(roles);
242                    }
243    
244                    Boolean active = (Boolean)attributes.get("active");
245    
246                    if (active != null) {
247                            setActive(active);
248                    }
249            }
250    
251            @JSON
252            @Override
253            public long getMvccVersion() {
254                    return _mvccVersion;
255            }
256    
257            @Override
258            public void setMvccVersion(long mvccVersion) {
259                    _mvccVersion = mvccVersion;
260            }
261    
262            @JSON
263            @Override
264            public long getPluginSettingId() {
265                    return _pluginSettingId;
266            }
267    
268            @Override
269            public void setPluginSettingId(long pluginSettingId) {
270                    _pluginSettingId = pluginSettingId;
271            }
272    
273            @JSON
274            @Override
275            public long getCompanyId() {
276                    return _companyId;
277            }
278    
279            @Override
280            public void setCompanyId(long companyId) {
281                    _columnBitmask |= COMPANYID_COLUMN_BITMASK;
282    
283                    if (!_setOriginalCompanyId) {
284                            _setOriginalCompanyId = true;
285    
286                            _originalCompanyId = _companyId;
287                    }
288    
289                    _companyId = companyId;
290            }
291    
292            public long getOriginalCompanyId() {
293                    return _originalCompanyId;
294            }
295    
296            @JSON
297            @Override
298            public String getPluginId() {
299                    if (_pluginId == null) {
300                            return StringPool.BLANK;
301                    }
302                    else {
303                            return _pluginId;
304                    }
305            }
306    
307            @Override
308            public void setPluginId(String pluginId) {
309                    _columnBitmask |= PLUGINID_COLUMN_BITMASK;
310    
311                    if (_originalPluginId == null) {
312                            _originalPluginId = _pluginId;
313                    }
314    
315                    _pluginId = pluginId;
316            }
317    
318            public String getOriginalPluginId() {
319                    return GetterUtil.getString(_originalPluginId);
320            }
321    
322            @JSON
323            @Override
324            public String getPluginType() {
325                    if (_pluginType == null) {
326                            return StringPool.BLANK;
327                    }
328                    else {
329                            return _pluginType;
330                    }
331            }
332    
333            @Override
334            public void setPluginType(String pluginType) {
335                    _columnBitmask |= PLUGINTYPE_COLUMN_BITMASK;
336    
337                    if (_originalPluginType == null) {
338                            _originalPluginType = _pluginType;
339                    }
340    
341                    _pluginType = pluginType;
342            }
343    
344            public String getOriginalPluginType() {
345                    return GetterUtil.getString(_originalPluginType);
346            }
347    
348            @JSON
349            @Override
350            public String getRoles() {
351                    if (_roles == null) {
352                            return StringPool.BLANK;
353                    }
354                    else {
355                            return _roles;
356                    }
357            }
358    
359            @Override
360            public void setRoles(String roles) {
361                    _roles = roles;
362            }
363    
364            @JSON
365            @Override
366            public boolean getActive() {
367                    return _active;
368            }
369    
370            @Override
371            public boolean isActive() {
372                    return _active;
373            }
374    
375            @Override
376            public void setActive(boolean active) {
377                    _active = active;
378            }
379    
380            public long getColumnBitmask() {
381                    return _columnBitmask;
382            }
383    
384            @Override
385            public ExpandoBridge getExpandoBridge() {
386                    return ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
387                            PluginSetting.class.getName(), getPrimaryKey());
388            }
389    
390            @Override
391            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
392                    ExpandoBridge expandoBridge = getExpandoBridge();
393    
394                    expandoBridge.setAttributes(serviceContext);
395            }
396    
397            @Override
398            public PluginSetting toEscapedModel() {
399                    if (_escapedModel == null) {
400                            _escapedModel = (PluginSetting)ProxyUtil.newProxyInstance(_classLoader,
401                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
402                    }
403    
404                    return _escapedModel;
405            }
406    
407            @Override
408            public Object clone() {
409                    PluginSettingImpl pluginSettingImpl = new PluginSettingImpl();
410    
411                    pluginSettingImpl.setMvccVersion(getMvccVersion());
412                    pluginSettingImpl.setPluginSettingId(getPluginSettingId());
413                    pluginSettingImpl.setCompanyId(getCompanyId());
414                    pluginSettingImpl.setPluginId(getPluginId());
415                    pluginSettingImpl.setPluginType(getPluginType());
416                    pluginSettingImpl.setRoles(getRoles());
417                    pluginSettingImpl.setActive(getActive());
418    
419                    pluginSettingImpl.resetOriginalValues();
420    
421                    return pluginSettingImpl;
422            }
423    
424            @Override
425            public int compareTo(PluginSetting pluginSetting) {
426                    long primaryKey = pluginSetting.getPrimaryKey();
427    
428                    if (getPrimaryKey() < primaryKey) {
429                            return -1;
430                    }
431                    else if (getPrimaryKey() > primaryKey) {
432                            return 1;
433                    }
434                    else {
435                            return 0;
436                    }
437            }
438    
439            @Override
440            public boolean equals(Object obj) {
441                    if (this == obj) {
442                            return true;
443                    }
444    
445                    if (!(obj instanceof PluginSetting)) {
446                            return false;
447                    }
448    
449                    PluginSetting pluginSetting = (PluginSetting)obj;
450    
451                    long primaryKey = pluginSetting.getPrimaryKey();
452    
453                    if (getPrimaryKey() == primaryKey) {
454                            return true;
455                    }
456                    else {
457                            return false;
458                    }
459            }
460    
461            @Override
462            public int hashCode() {
463                    return (int)getPrimaryKey();
464            }
465    
466            @Override
467            public boolean isEntityCacheEnabled() {
468                    return ENTITY_CACHE_ENABLED;
469            }
470    
471            @Override
472            public boolean isFinderCacheEnabled() {
473                    return FINDER_CACHE_ENABLED;
474            }
475    
476            @Override
477            public void resetOriginalValues() {
478                    PluginSettingModelImpl pluginSettingModelImpl = this;
479    
480                    pluginSettingModelImpl._originalCompanyId = pluginSettingModelImpl._companyId;
481    
482                    pluginSettingModelImpl._setOriginalCompanyId = false;
483    
484                    pluginSettingModelImpl._originalPluginId = pluginSettingModelImpl._pluginId;
485    
486                    pluginSettingModelImpl._originalPluginType = pluginSettingModelImpl._pluginType;
487    
488                    pluginSettingModelImpl._columnBitmask = 0;
489            }
490    
491            @Override
492            public CacheModel<PluginSetting> toCacheModel() {
493                    PluginSettingCacheModel pluginSettingCacheModel = new PluginSettingCacheModel();
494    
495                    pluginSettingCacheModel.mvccVersion = getMvccVersion();
496    
497                    pluginSettingCacheModel.pluginSettingId = getPluginSettingId();
498    
499                    pluginSettingCacheModel.companyId = getCompanyId();
500    
501                    pluginSettingCacheModel.pluginId = getPluginId();
502    
503                    String pluginId = pluginSettingCacheModel.pluginId;
504    
505                    if ((pluginId != null) && (pluginId.length() == 0)) {
506                            pluginSettingCacheModel.pluginId = null;
507                    }
508    
509                    pluginSettingCacheModel.pluginType = getPluginType();
510    
511                    String pluginType = pluginSettingCacheModel.pluginType;
512    
513                    if ((pluginType != null) && (pluginType.length() == 0)) {
514                            pluginSettingCacheModel.pluginType = null;
515                    }
516    
517                    pluginSettingCacheModel.roles = getRoles();
518    
519                    String roles = pluginSettingCacheModel.roles;
520    
521                    if ((roles != null) && (roles.length() == 0)) {
522                            pluginSettingCacheModel.roles = null;
523                    }
524    
525                    pluginSettingCacheModel.active = getActive();
526    
527                    return pluginSettingCacheModel;
528            }
529    
530            @Override
531            public String toString() {
532                    StringBundler sb = new StringBundler(15);
533    
534                    sb.append("{mvccVersion=");
535                    sb.append(getMvccVersion());
536                    sb.append(", pluginSettingId=");
537                    sb.append(getPluginSettingId());
538                    sb.append(", companyId=");
539                    sb.append(getCompanyId());
540                    sb.append(", pluginId=");
541                    sb.append(getPluginId());
542                    sb.append(", pluginType=");
543                    sb.append(getPluginType());
544                    sb.append(", roles=");
545                    sb.append(getRoles());
546                    sb.append(", active=");
547                    sb.append(getActive());
548                    sb.append("}");
549    
550                    return sb.toString();
551            }
552    
553            @Override
554            public String toXmlString() {
555                    StringBundler sb = new StringBundler(25);
556    
557                    sb.append("<model><model-name>");
558                    sb.append("com.liferay.portal.model.PluginSetting");
559                    sb.append("</model-name>");
560    
561                    sb.append(
562                            "<column><column-name>mvccVersion</column-name><column-value><![CDATA[");
563                    sb.append(getMvccVersion());
564                    sb.append("]]></column-value></column>");
565                    sb.append(
566                            "<column><column-name>pluginSettingId</column-name><column-value><![CDATA[");
567                    sb.append(getPluginSettingId());
568                    sb.append("]]></column-value></column>");
569                    sb.append(
570                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
571                    sb.append(getCompanyId());
572                    sb.append("]]></column-value></column>");
573                    sb.append(
574                            "<column><column-name>pluginId</column-name><column-value><![CDATA[");
575                    sb.append(getPluginId());
576                    sb.append("]]></column-value></column>");
577                    sb.append(
578                            "<column><column-name>pluginType</column-name><column-value><![CDATA[");
579                    sb.append(getPluginType());
580                    sb.append("]]></column-value></column>");
581                    sb.append(
582                            "<column><column-name>roles</column-name><column-value><![CDATA[");
583                    sb.append(getRoles());
584                    sb.append("]]></column-value></column>");
585                    sb.append(
586                            "<column><column-name>active</column-name><column-value><![CDATA[");
587                    sb.append(getActive());
588                    sb.append("]]></column-value></column>");
589    
590                    sb.append("</model>");
591    
592                    return sb.toString();
593            }
594    
595            private static final ClassLoader _classLoader = PluginSetting.class.getClassLoader();
596            private static final Class<?>[] _escapedModelInterfaces = new Class[] {
597                            PluginSetting.class
598                    };
599            private long _mvccVersion;
600            private long _pluginSettingId;
601            private long _companyId;
602            private long _originalCompanyId;
603            private boolean _setOriginalCompanyId;
604            private String _pluginId;
605            private String _originalPluginId;
606            private String _pluginType;
607            private String _originalPluginType;
608            private String _roles;
609            private boolean _active;
610            private long _columnBitmask;
611            private PluginSetting _escapedModel;
612    }