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.model.CacheModel;
024    import com.liferay.portal.kernel.model.ClusterGroup;
025    import com.liferay.portal.kernel.model.ClusterGroupModel;
026    import com.liferay.portal.kernel.model.impl.BaseModelImpl;
027    import com.liferay.portal.kernel.service.ServiceContext;
028    import com.liferay.portal.kernel.util.GetterUtil;
029    import com.liferay.portal.kernel.util.ProxyUtil;
030    import com.liferay.portal.kernel.util.StringBundler;
031    import com.liferay.portal.kernel.util.StringPool;
032    
033    import java.io.Serializable;
034    
035    import java.sql.Types;
036    
037    import java.util.HashMap;
038    import java.util.Map;
039    
040    /**
041     * The base model implementation for the ClusterGroup service. Represents a row in the "ClusterGroup" database table, with each column mapped to a property of this class.
042     *
043     * <p>
044     * This implementation and its corresponding interface {@link ClusterGroupModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link ClusterGroupImpl}.
045     * </p>
046     *
047     * @author Brian Wing Shun Chan
048     * @see ClusterGroupImpl
049     * @see ClusterGroup
050     * @see ClusterGroupModel
051     * @generated
052     */
053    @ProviderType
054    public class ClusterGroupModelImpl extends BaseModelImpl<ClusterGroup>
055            implements ClusterGroupModel {
056            /*
057             * NOTE FOR DEVELOPERS:
058             *
059             * Never modify or reference this class directly. All methods that expect a cluster group model instance should use the {@link ClusterGroup} interface instead.
060             */
061            public static final String TABLE_NAME = "ClusterGroup";
062            public static final Object[][] TABLE_COLUMNS = {
063                            { "mvccVersion", Types.BIGINT },
064                            { "clusterGroupId", Types.BIGINT },
065                            { "name", Types.VARCHAR },
066                            { "clusterNodeIds", Types.VARCHAR },
067                            { "wholeCluster", Types.BOOLEAN }
068                    };
069            public static final Map<String, Integer> TABLE_COLUMNS_MAP = new HashMap<String, Integer>();
070    
071            static {
072                    TABLE_COLUMNS_MAP.put("mvccVersion", Types.BIGINT);
073                    TABLE_COLUMNS_MAP.put("clusterGroupId", Types.BIGINT);
074                    TABLE_COLUMNS_MAP.put("name", Types.VARCHAR);
075                    TABLE_COLUMNS_MAP.put("clusterNodeIds", Types.VARCHAR);
076                    TABLE_COLUMNS_MAP.put("wholeCluster", Types.BOOLEAN);
077            }
078    
079            public static final String TABLE_SQL_CREATE = "create table ClusterGroup (mvccVersion LONG default 0 not null,clusterGroupId LONG not null primary key,name VARCHAR(75) null,clusterNodeIds VARCHAR(75) null,wholeCluster BOOLEAN)";
080            public static final String TABLE_SQL_DROP = "drop table ClusterGroup";
081            public static final String ORDER_BY_JPQL = " ORDER BY clusterGroup.clusterGroupId ASC";
082            public static final String ORDER_BY_SQL = " ORDER BY ClusterGroup.clusterGroupId ASC";
083            public static final String DATA_SOURCE = "liferayDataSource";
084            public static final String SESSION_FACTORY = "liferaySessionFactory";
085            public static final String TX_MANAGER = "liferayTransactionManager";
086            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
087                                    "value.object.entity.cache.enabled.com.liferay.portal.kernel.model.ClusterGroup"),
088                            true);
089            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
090                                    "value.object.finder.cache.enabled.com.liferay.portal.kernel.model.ClusterGroup"),
091                            true);
092            public static final boolean COLUMN_BITMASK_ENABLED = false;
093            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
094                                    "lock.expiration.time.com.liferay.portal.kernel.model.ClusterGroup"));
095    
096            public ClusterGroupModelImpl() {
097            }
098    
099            @Override
100            public long getPrimaryKey() {
101                    return _clusterGroupId;
102            }
103    
104            @Override
105            public void setPrimaryKey(long primaryKey) {
106                    setClusterGroupId(primaryKey);
107            }
108    
109            @Override
110            public Serializable getPrimaryKeyObj() {
111                    return _clusterGroupId;
112            }
113    
114            @Override
115            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
116                    setPrimaryKey(((Long)primaryKeyObj).longValue());
117            }
118    
119            @Override
120            public Class<?> getModelClass() {
121                    return ClusterGroup.class;
122            }
123    
124            @Override
125            public String getModelClassName() {
126                    return ClusterGroup.class.getName();
127            }
128    
129            @Override
130            public Map<String, Object> getModelAttributes() {
131                    Map<String, Object> attributes = new HashMap<String, Object>();
132    
133                    attributes.put("mvccVersion", getMvccVersion());
134                    attributes.put("clusterGroupId", getClusterGroupId());
135                    attributes.put("name", getName());
136                    attributes.put("clusterNodeIds", getClusterNodeIds());
137                    attributes.put("wholeCluster", getWholeCluster());
138    
139                    attributes.put("entityCacheEnabled", isEntityCacheEnabled());
140                    attributes.put("finderCacheEnabled", isFinderCacheEnabled());
141    
142                    return attributes;
143            }
144    
145            @Override
146            public void setModelAttributes(Map<String, Object> attributes) {
147                    Long mvccVersion = (Long)attributes.get("mvccVersion");
148    
149                    if (mvccVersion != null) {
150                            setMvccVersion(mvccVersion);
151                    }
152    
153                    Long clusterGroupId = (Long)attributes.get("clusterGroupId");
154    
155                    if (clusterGroupId != null) {
156                            setClusterGroupId(clusterGroupId);
157                    }
158    
159                    String name = (String)attributes.get("name");
160    
161                    if (name != null) {
162                            setName(name);
163                    }
164    
165                    String clusterNodeIds = (String)attributes.get("clusterNodeIds");
166    
167                    if (clusterNodeIds != null) {
168                            setClusterNodeIds(clusterNodeIds);
169                    }
170    
171                    Boolean wholeCluster = (Boolean)attributes.get("wholeCluster");
172    
173                    if (wholeCluster != null) {
174                            setWholeCluster(wholeCluster);
175                    }
176            }
177    
178            @Override
179            public long getMvccVersion() {
180                    return _mvccVersion;
181            }
182    
183            @Override
184            public void setMvccVersion(long mvccVersion) {
185                    _mvccVersion = mvccVersion;
186            }
187    
188            @Override
189            public long getClusterGroupId() {
190                    return _clusterGroupId;
191            }
192    
193            @Override
194            public void setClusterGroupId(long clusterGroupId) {
195                    _clusterGroupId = clusterGroupId;
196            }
197    
198            @Override
199            public String getName() {
200                    if (_name == null) {
201                            return StringPool.BLANK;
202                    }
203                    else {
204                            return _name;
205                    }
206            }
207    
208            @Override
209            public void setName(String name) {
210                    _name = name;
211            }
212    
213            @Override
214            public String getClusterNodeIds() {
215                    if (_clusterNodeIds == null) {
216                            return StringPool.BLANK;
217                    }
218                    else {
219                            return _clusterNodeIds;
220                    }
221            }
222    
223            @Override
224            public void setClusterNodeIds(String clusterNodeIds) {
225                    _clusterNodeIds = clusterNodeIds;
226            }
227    
228            @Override
229            public boolean getWholeCluster() {
230                    return _wholeCluster;
231            }
232    
233            @Override
234            public boolean isWholeCluster() {
235                    return _wholeCluster;
236            }
237    
238            @Override
239            public void setWholeCluster(boolean wholeCluster) {
240                    _wholeCluster = wholeCluster;
241            }
242    
243            @Override
244            public ExpandoBridge getExpandoBridge() {
245                    return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
246                            ClusterGroup.class.getName(), getPrimaryKey());
247            }
248    
249            @Override
250            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
251                    ExpandoBridge expandoBridge = getExpandoBridge();
252    
253                    expandoBridge.setAttributes(serviceContext);
254            }
255    
256            @Override
257            public ClusterGroup toEscapedModel() {
258                    if (_escapedModel == null) {
259                            _escapedModel = (ClusterGroup)ProxyUtil.newProxyInstance(_classLoader,
260                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
261                    }
262    
263                    return _escapedModel;
264            }
265    
266            @Override
267            public Object clone() {
268                    ClusterGroupImpl clusterGroupImpl = new ClusterGroupImpl();
269    
270                    clusterGroupImpl.setMvccVersion(getMvccVersion());
271                    clusterGroupImpl.setClusterGroupId(getClusterGroupId());
272                    clusterGroupImpl.setName(getName());
273                    clusterGroupImpl.setClusterNodeIds(getClusterNodeIds());
274                    clusterGroupImpl.setWholeCluster(getWholeCluster());
275    
276                    clusterGroupImpl.resetOriginalValues();
277    
278                    return clusterGroupImpl;
279            }
280    
281            @Override
282            public int compareTo(ClusterGroup clusterGroup) {
283                    long primaryKey = clusterGroup.getPrimaryKey();
284    
285                    if (getPrimaryKey() < primaryKey) {
286                            return -1;
287                    }
288                    else if (getPrimaryKey() > primaryKey) {
289                            return 1;
290                    }
291                    else {
292                            return 0;
293                    }
294            }
295    
296            @Override
297            public boolean equals(Object obj) {
298                    if (this == obj) {
299                            return true;
300                    }
301    
302                    if (!(obj instanceof ClusterGroup)) {
303                            return false;
304                    }
305    
306                    ClusterGroup clusterGroup = (ClusterGroup)obj;
307    
308                    long primaryKey = clusterGroup.getPrimaryKey();
309    
310                    if (getPrimaryKey() == primaryKey) {
311                            return true;
312                    }
313                    else {
314                            return false;
315                    }
316            }
317    
318            @Override
319            public int hashCode() {
320                    return (int)getPrimaryKey();
321            }
322    
323            @Override
324            public boolean isEntityCacheEnabled() {
325                    return ENTITY_CACHE_ENABLED;
326            }
327    
328            @Override
329            public boolean isFinderCacheEnabled() {
330                    return FINDER_CACHE_ENABLED;
331            }
332    
333            @Override
334            public void resetOriginalValues() {
335            }
336    
337            @Override
338            public CacheModel<ClusterGroup> toCacheModel() {
339                    ClusterGroupCacheModel clusterGroupCacheModel = new ClusterGroupCacheModel();
340    
341                    clusterGroupCacheModel.mvccVersion = getMvccVersion();
342    
343                    clusterGroupCacheModel.clusterGroupId = getClusterGroupId();
344    
345                    clusterGroupCacheModel.name = getName();
346    
347                    String name = clusterGroupCacheModel.name;
348    
349                    if ((name != null) && (name.length() == 0)) {
350                            clusterGroupCacheModel.name = null;
351                    }
352    
353                    clusterGroupCacheModel.clusterNodeIds = getClusterNodeIds();
354    
355                    String clusterNodeIds = clusterGroupCacheModel.clusterNodeIds;
356    
357                    if ((clusterNodeIds != null) && (clusterNodeIds.length() == 0)) {
358                            clusterGroupCacheModel.clusterNodeIds = null;
359                    }
360    
361                    clusterGroupCacheModel.wholeCluster = getWholeCluster();
362    
363                    return clusterGroupCacheModel;
364            }
365    
366            @Override
367            public String toString() {
368                    StringBundler sb = new StringBundler(11);
369    
370                    sb.append("{mvccVersion=");
371                    sb.append(getMvccVersion());
372                    sb.append(", clusterGroupId=");
373                    sb.append(getClusterGroupId());
374                    sb.append(", name=");
375                    sb.append(getName());
376                    sb.append(", clusterNodeIds=");
377                    sb.append(getClusterNodeIds());
378                    sb.append(", wholeCluster=");
379                    sb.append(getWholeCluster());
380                    sb.append("}");
381    
382                    return sb.toString();
383            }
384    
385            @Override
386            public String toXmlString() {
387                    StringBundler sb = new StringBundler(19);
388    
389                    sb.append("<model><model-name>");
390                    sb.append("com.liferay.portal.kernel.model.ClusterGroup");
391                    sb.append("</model-name>");
392    
393                    sb.append(
394                            "<column><column-name>mvccVersion</column-name><column-value><![CDATA[");
395                    sb.append(getMvccVersion());
396                    sb.append("]]></column-value></column>");
397                    sb.append(
398                            "<column><column-name>clusterGroupId</column-name><column-value><![CDATA[");
399                    sb.append(getClusterGroupId());
400                    sb.append("]]></column-value></column>");
401                    sb.append(
402                            "<column><column-name>name</column-name><column-value><![CDATA[");
403                    sb.append(getName());
404                    sb.append("]]></column-value></column>");
405                    sb.append(
406                            "<column><column-name>clusterNodeIds</column-name><column-value><![CDATA[");
407                    sb.append(getClusterNodeIds());
408                    sb.append("]]></column-value></column>");
409                    sb.append(
410                            "<column><column-name>wholeCluster</column-name><column-value><![CDATA[");
411                    sb.append(getWholeCluster());
412                    sb.append("]]></column-value></column>");
413    
414                    sb.append("</model>");
415    
416                    return sb.toString();
417            }
418    
419            private static final ClassLoader _classLoader = ClusterGroup.class.getClassLoader();
420            private static final Class<?>[] _escapedModelInterfaces = new Class[] {
421                            ClusterGroup.class
422                    };
423            private long _mvccVersion;
424            private long _clusterGroupId;
425            private String _name;
426            private String _clusterNodeIds;
427            private boolean _wholeCluster;
428            private ClusterGroup _escapedModel;
429    }