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