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