001    /**
002     * Copyright (c) 2000-2011 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.portlet.asset.model.impl;
016    
017    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.util.GetterUtil;
019    import com.liferay.portal.kernel.util.StringBundler;
020    import com.liferay.portal.kernel.util.StringPool;
021    import com.liferay.portal.model.impl.BaseModelImpl;
022    import com.liferay.portal.service.ServiceContext;
023    import com.liferay.portal.util.PortalUtil;
024    
025    import com.liferay.portlet.asset.model.AssetTagStats;
026    import com.liferay.portlet.asset.model.AssetTagStatsModel;
027    import com.liferay.portlet.expando.model.ExpandoBridge;
028    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
029    
030    import java.io.Serializable;
031    
032    import java.lang.reflect.Proxy;
033    
034    import java.sql.Types;
035    
036    /**
037     * The base model implementation for the AssetTagStats service. Represents a row in the "AssetTagStats" database table, with each column mapped to a property of this class.
038     *
039     * <p>
040     * This implementation and its corresponding interface {@link com.liferay.portlet.asset.model.AssetTagStatsModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link AssetTagStatsImpl}.
041     * </p>
042     *
043     * <p>
044     * Never modify or reference this class directly. All methods that expect a asset tag stats model instance should use the {@link com.liferay.portlet.asset.model.AssetTagStats} interface instead.
045     * </p>
046     *
047     * @author Brian Wing Shun Chan
048     * @see AssetTagStatsImpl
049     * @see com.liferay.portlet.asset.model.AssetTagStats
050     * @see com.liferay.portlet.asset.model.AssetTagStatsModel
051     * @generated
052     */
053    public class AssetTagStatsModelImpl extends BaseModelImpl<AssetTagStats>
054            implements AssetTagStatsModel {
055            public static final String TABLE_NAME = "AssetTagStats";
056            public static final Object[][] TABLE_COLUMNS = {
057                            { "tagStatsId", new Integer(Types.BIGINT) },
058                            { "tagId", new Integer(Types.BIGINT) },
059                            { "classNameId", new Integer(Types.BIGINT) },
060                            { "assetCount", new Integer(Types.INTEGER) }
061                    };
062            public static final String TABLE_SQL_CREATE = "create table AssetTagStats (tagStatsId LONG not null primary key,tagId LONG,classNameId LONG,assetCount INTEGER)";
063            public static final String TABLE_SQL_DROP = "drop table AssetTagStats";
064            public static final String ORDER_BY_JPQL = " ORDER BY assetTagStats.assetCount DESC";
065            public static final String ORDER_BY_SQL = " ORDER BY AssetTagStats.assetCount DESC";
066            public static final String DATA_SOURCE = "liferayDataSource";
067            public static final String SESSION_FACTORY = "liferaySessionFactory";
068            public static final String TX_MANAGER = "liferayTransactionManager";
069            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
070                                    "value.object.entity.cache.enabled.com.liferay.portlet.asset.model.AssetTagStats"),
071                            true);
072            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
073                                    "value.object.finder.cache.enabled.com.liferay.portlet.asset.model.AssetTagStats"),
074                            true);
075            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
076                                    "lock.expiration.time.com.liferay.portlet.asset.model.AssetTagStats"));
077    
078            public AssetTagStatsModelImpl() {
079            }
080    
081            public long getPrimaryKey() {
082                    return _tagStatsId;
083            }
084    
085            public void setPrimaryKey(long pk) {
086                    setTagStatsId(pk);
087            }
088    
089            public Serializable getPrimaryKeyObj() {
090                    return new Long(_tagStatsId);
091            }
092    
093            public long getTagStatsId() {
094                    return _tagStatsId;
095            }
096    
097            public void setTagStatsId(long tagStatsId) {
098                    _tagStatsId = tagStatsId;
099            }
100    
101            public long getTagId() {
102                    return _tagId;
103            }
104    
105            public void setTagId(long tagId) {
106                    if (!_setOriginalTagId) {
107                            _setOriginalTagId = true;
108    
109                            _originalTagId = _tagId;
110                    }
111    
112                    _tagId = tagId;
113            }
114    
115            public long getOriginalTagId() {
116                    return _originalTagId;
117            }
118    
119            public String getClassName() {
120                    if (getClassNameId() <= 0) {
121                            return StringPool.BLANK;
122                    }
123    
124                    return PortalUtil.getClassName(getClassNameId());
125            }
126    
127            public long getClassNameId() {
128                    return _classNameId;
129            }
130    
131            public void setClassNameId(long classNameId) {
132                    if (!_setOriginalClassNameId) {
133                            _setOriginalClassNameId = true;
134    
135                            _originalClassNameId = _classNameId;
136                    }
137    
138                    _classNameId = classNameId;
139            }
140    
141            public long getOriginalClassNameId() {
142                    return _originalClassNameId;
143            }
144    
145            public int getAssetCount() {
146                    return _assetCount;
147            }
148    
149            public void setAssetCount(int assetCount) {
150                    _assetCount = assetCount;
151            }
152    
153            public AssetTagStats toEscapedModel() {
154                    if (isEscapedModel()) {
155                            return (AssetTagStats)this;
156                    }
157                    else {
158                            return (AssetTagStats)Proxy.newProxyInstance(AssetTagStats.class.getClassLoader(),
159                                    new Class[] { AssetTagStats.class },
160                                    new AutoEscapeBeanHandler(this));
161                    }
162            }
163    
164            public ExpandoBridge getExpandoBridge() {
165                    if (_expandoBridge == null) {
166                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
167                                            AssetTagStats.class.getName(), getPrimaryKey());
168                    }
169    
170                    return _expandoBridge;
171            }
172    
173            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
174                    getExpandoBridge().setAttributes(serviceContext);
175            }
176    
177            public Object clone() {
178                    AssetTagStatsImpl assetTagStatsImpl = new AssetTagStatsImpl();
179    
180                    assetTagStatsImpl.setTagStatsId(getTagStatsId());
181    
182                    assetTagStatsImpl.setTagId(getTagId());
183    
184                    AssetTagStatsModelImpl assetTagStatsModelImpl = assetTagStatsImpl;
185    
186                    assetTagStatsModelImpl._originalTagId = assetTagStatsModelImpl._tagId;
187    
188                    assetTagStatsModelImpl._setOriginalTagId = false;
189                    assetTagStatsImpl.setClassNameId(getClassNameId());
190    
191                    assetTagStatsModelImpl._originalClassNameId = assetTagStatsModelImpl._classNameId;
192    
193                    assetTagStatsModelImpl._setOriginalClassNameId = false;
194                    assetTagStatsImpl.setAssetCount(getAssetCount());
195    
196                    return assetTagStatsImpl;
197            }
198    
199            public int compareTo(AssetTagStats assetTagStats) {
200                    int value = 0;
201    
202                    if (getAssetCount() < assetTagStats.getAssetCount()) {
203                            value = -1;
204                    }
205                    else if (getAssetCount() > assetTagStats.getAssetCount()) {
206                            value = 1;
207                    }
208                    else {
209                            value = 0;
210                    }
211    
212                    value = value * -1;
213    
214                    if (value != 0) {
215                            return value;
216                    }
217    
218                    return 0;
219            }
220    
221            public boolean equals(Object obj) {
222                    if (obj == null) {
223                            return false;
224                    }
225    
226                    AssetTagStats assetTagStats = null;
227    
228                    try {
229                            assetTagStats = (AssetTagStats)obj;
230                    }
231                    catch (ClassCastException cce) {
232                            return false;
233                    }
234    
235                    long pk = assetTagStats.getPrimaryKey();
236    
237                    if (getPrimaryKey() == pk) {
238                            return true;
239                    }
240                    else {
241                            return false;
242                    }
243            }
244    
245            public int hashCode() {
246                    return (int)getPrimaryKey();
247            }
248    
249            public String toString() {
250                    StringBundler sb = new StringBundler(9);
251    
252                    sb.append("{tagStatsId=");
253                    sb.append(getTagStatsId());
254                    sb.append(", tagId=");
255                    sb.append(getTagId());
256                    sb.append(", classNameId=");
257                    sb.append(getClassNameId());
258                    sb.append(", assetCount=");
259                    sb.append(getAssetCount());
260                    sb.append("}");
261    
262                    return sb.toString();
263            }
264    
265            public String toXmlString() {
266                    StringBundler sb = new StringBundler(16);
267    
268                    sb.append("<model><model-name>");
269                    sb.append("com.liferay.portlet.asset.model.AssetTagStats");
270                    sb.append("</model-name>");
271    
272                    sb.append(
273                            "<column><column-name>tagStatsId</column-name><column-value><![CDATA[");
274                    sb.append(getTagStatsId());
275                    sb.append("]]></column-value></column>");
276                    sb.append(
277                            "<column><column-name>tagId</column-name><column-value><![CDATA[");
278                    sb.append(getTagId());
279                    sb.append("]]></column-value></column>");
280                    sb.append(
281                            "<column><column-name>classNameId</column-name><column-value><![CDATA[");
282                    sb.append(getClassNameId());
283                    sb.append("]]></column-value></column>");
284                    sb.append(
285                            "<column><column-name>assetCount</column-name><column-value><![CDATA[");
286                    sb.append(getAssetCount());
287                    sb.append("]]></column-value></column>");
288    
289                    sb.append("</model>");
290    
291                    return sb.toString();
292            }
293    
294            private long _tagStatsId;
295            private long _tagId;
296            private long _originalTagId;
297            private boolean _setOriginalTagId;
298            private long _classNameId;
299            private long _originalClassNameId;
300            private boolean _setOriginalClassNameId;
301            private int _assetCount;
302            private transient ExpandoBridge _expandoBridge;
303    }