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