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