001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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                    _tagId = tagId;
107    
108                    if (!_setOriginalTagId) {
109                            _setOriginalTagId = true;
110    
111                            _originalTagId = tagId;
112                    }
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                    _classNameId = classNameId;
133    
134                    if (!_setOriginalClassNameId) {
135                            _setOriginalClassNameId = true;
136    
137                            _originalClassNameId = classNameId;
138                    }
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 clone = new AssetTagStatsImpl();
179    
180                    clone.setTagStatsId(getTagStatsId());
181                    clone.setTagId(getTagId());
182                    clone.setClassNameId(getClassNameId());
183                    clone.setAssetCount(getAssetCount());
184    
185                    return clone;
186            }
187    
188            public int compareTo(AssetTagStats assetTagStats) {
189                    int value = 0;
190    
191                    if (getAssetCount() < assetTagStats.getAssetCount()) {
192                            value = -1;
193                    }
194                    else if (getAssetCount() > assetTagStats.getAssetCount()) {
195                            value = 1;
196                    }
197                    else {
198                            value = 0;
199                    }
200    
201                    value = value * -1;
202    
203                    if (value != 0) {
204                            return value;
205                    }
206    
207                    return 0;
208            }
209    
210            public boolean equals(Object obj) {
211                    if (obj == null) {
212                            return false;
213                    }
214    
215                    AssetTagStats assetTagStats = null;
216    
217                    try {
218                            assetTagStats = (AssetTagStats)obj;
219                    }
220                    catch (ClassCastException cce) {
221                            return false;
222                    }
223    
224                    long pk = assetTagStats.getPrimaryKey();
225    
226                    if (getPrimaryKey() == pk) {
227                            return true;
228                    }
229                    else {
230                            return false;
231                    }
232            }
233    
234            public int hashCode() {
235                    return (int)getPrimaryKey();
236            }
237    
238            public String toString() {
239                    StringBundler sb = new StringBundler(9);
240    
241                    sb.append("{tagStatsId=");
242                    sb.append(getTagStatsId());
243                    sb.append(", tagId=");
244                    sb.append(getTagId());
245                    sb.append(", classNameId=");
246                    sb.append(getClassNameId());
247                    sb.append(", assetCount=");
248                    sb.append(getAssetCount());
249                    sb.append("}");
250    
251                    return sb.toString();
252            }
253    
254            public String toXmlString() {
255                    StringBundler sb = new StringBundler(16);
256    
257                    sb.append("<model><model-name>");
258                    sb.append("com.liferay.portlet.asset.model.AssetTagStats");
259                    sb.append("</model-name>");
260    
261                    sb.append(
262                            "<column><column-name>tagStatsId</column-name><column-value><![CDATA[");
263                    sb.append(getTagStatsId());
264                    sb.append("]]></column-value></column>");
265                    sb.append(
266                            "<column><column-name>tagId</column-name><column-value><![CDATA[");
267                    sb.append(getTagId());
268                    sb.append("]]></column-value></column>");
269                    sb.append(
270                            "<column><column-name>classNameId</column-name><column-value><![CDATA[");
271                    sb.append(getClassNameId());
272                    sb.append("]]></column-value></column>");
273                    sb.append(
274                            "<column><column-name>assetCount</column-name><column-value><![CDATA[");
275                    sb.append(getAssetCount());
276                    sb.append("]]></column-value></column>");
277    
278                    sb.append("</model>");
279    
280                    return sb.toString();
281            }
282    
283            private long _tagStatsId;
284            private long _tagId;
285            private long _originalTagId;
286            private boolean _setOriginalTagId;
287            private long _classNameId;
288            private long _originalClassNameId;
289            private boolean _setOriginalClassNameId;
290            private int _assetCount;
291            private transient ExpandoBridge _expandoBridge;
292    }