1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.asset.model.impl;
16  
17  import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
18  import com.liferay.portal.kernel.util.GetterUtil;
19  import com.liferay.portal.kernel.util.StringBundler;
20  import com.liferay.portal.kernel.util.StringPool;
21  import com.liferay.portal.model.impl.BaseModelImpl;
22  import com.liferay.portal.service.ServiceContext;
23  import com.liferay.portal.util.PortalUtil;
24  
25  import com.liferay.portlet.asset.model.AssetTagStats;
26  import com.liferay.portlet.asset.model.AssetTagStatsSoap;
27  import com.liferay.portlet.expando.model.ExpandoBridge;
28  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
29  
30  import java.io.Serializable;
31  
32  import java.lang.reflect.Proxy;
33  
34  import java.sql.Types;
35  
36  import java.util.ArrayList;
37  import java.util.List;
38  
39  /**
40   * <a href="AssetTagStatsModelImpl.java.html"><b><i>View Source</i></b></a>
41   *
42   * <p>
43   * ServiceBuilder generated this class. Modifications in this class will be
44   * overwritten the next time is generated.
45   * </p>
46   *
47   * <p>
48   * This interface is a model that represents the AssetTagStats table in the
49   * database.
50   * </p>
51   *
52   * @author    Brian Wing Shun Chan
53   * @see       AssetTagStatsImpl
54   * @see       com.liferay.portlet.asset.model.AssetTagStats
55   * @see       com.liferay.portlet.asset.model.AssetTagStatsModel
56   * @generated
57   */
58  public class AssetTagStatsModelImpl extends BaseModelImpl<AssetTagStats> {
59      public static final String TABLE_NAME = "AssetTagStats";
60      public static final Object[][] TABLE_COLUMNS = {
61              { "tagStatsId", new Integer(Types.BIGINT) },
62              { "tagId", new Integer(Types.BIGINT) },
63              { "classNameId", new Integer(Types.BIGINT) },
64              { "assetCount", new Integer(Types.INTEGER) }
65          };
66      public static final String TABLE_SQL_CREATE = "create table AssetTagStats (tagStatsId LONG not null primary key,tagId LONG,classNameId LONG,assetCount INTEGER)";
67      public static final String TABLE_SQL_DROP = "drop table AssetTagStats";
68      public static final String ORDER_BY_JPQL = " ORDER BY assetTagStats.assetCount DESC";
69      public static final String ORDER_BY_SQL = " ORDER BY AssetTagStats.assetCount DESC";
70      public static final String DATA_SOURCE = "liferayDataSource";
71      public static final String SESSION_FACTORY = "liferaySessionFactory";
72      public static final String TX_MANAGER = "liferayTransactionManager";
73      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
74                  "value.object.entity.cache.enabled.com.liferay.portlet.asset.model.AssetTagStats"),
75              true);
76      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
77                  "value.object.finder.cache.enabled.com.liferay.portlet.asset.model.AssetTagStats"),
78              true);
79  
80      public static AssetTagStats toModel(AssetTagStatsSoap soapModel) {
81          AssetTagStats model = new AssetTagStatsImpl();
82  
83          model.setTagStatsId(soapModel.getTagStatsId());
84          model.setTagId(soapModel.getTagId());
85          model.setClassNameId(soapModel.getClassNameId());
86          model.setAssetCount(soapModel.getAssetCount());
87  
88          return model;
89      }
90  
91      public static List<AssetTagStats> toModels(AssetTagStatsSoap[] soapModels) {
92          List<AssetTagStats> models = new ArrayList<AssetTagStats>(soapModels.length);
93  
94          for (AssetTagStatsSoap soapModel : soapModels) {
95              models.add(toModel(soapModel));
96          }
97  
98          return models;
99      }
100 
101     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
102                 "lock.expiration.time.com.liferay.portlet.asset.model.AssetTagStats"));
103 
104     public AssetTagStatsModelImpl() {
105     }
106 
107     public long getPrimaryKey() {
108         return _tagStatsId;
109     }
110 
111     public void setPrimaryKey(long pk) {
112         setTagStatsId(pk);
113     }
114 
115     public Serializable getPrimaryKeyObj() {
116         return new Long(_tagStatsId);
117     }
118 
119     public long getTagStatsId() {
120         return _tagStatsId;
121     }
122 
123     public void setTagStatsId(long tagStatsId) {
124         _tagStatsId = tagStatsId;
125     }
126 
127     public long getTagId() {
128         return _tagId;
129     }
130 
131     public void setTagId(long tagId) {
132         _tagId = tagId;
133 
134         if (!_setOriginalTagId) {
135             _setOriginalTagId = true;
136 
137             _originalTagId = tagId;
138         }
139     }
140 
141     public long getOriginalTagId() {
142         return _originalTagId;
143     }
144 
145     public String getClassName() {
146         if (getClassNameId() <= 0) {
147             return StringPool.BLANK;
148         }
149 
150         return PortalUtil.getClassName(getClassNameId());
151     }
152 
153     public long getClassNameId() {
154         return _classNameId;
155     }
156 
157     public void setClassNameId(long classNameId) {
158         _classNameId = classNameId;
159 
160         if (!_setOriginalClassNameId) {
161             _setOriginalClassNameId = true;
162 
163             _originalClassNameId = classNameId;
164         }
165     }
166 
167     public long getOriginalClassNameId() {
168         return _originalClassNameId;
169     }
170 
171     public int getAssetCount() {
172         return _assetCount;
173     }
174 
175     public void setAssetCount(int assetCount) {
176         _assetCount = assetCount;
177     }
178 
179     public AssetTagStats toEscapedModel() {
180         if (isEscapedModel()) {
181             return (AssetTagStats)this;
182         }
183         else {
184             return (AssetTagStats)Proxy.newProxyInstance(AssetTagStats.class.getClassLoader(),
185                 new Class[] { AssetTagStats.class },
186                 new AutoEscapeBeanHandler(this));
187         }
188     }
189 
190     public ExpandoBridge getExpandoBridge() {
191         if (_expandoBridge == null) {
192             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
193                     AssetTagStats.class.getName(), getPrimaryKey());
194         }
195 
196         return _expandoBridge;
197     }
198 
199     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
200         getExpandoBridge().setAttributes(serviceContext);
201     }
202 
203     public Object clone() {
204         AssetTagStatsImpl clone = new AssetTagStatsImpl();
205 
206         clone.setTagStatsId(getTagStatsId());
207         clone.setTagId(getTagId());
208         clone.setClassNameId(getClassNameId());
209         clone.setAssetCount(getAssetCount());
210 
211         return clone;
212     }
213 
214     public int compareTo(AssetTagStats assetTagStats) {
215         int value = 0;
216 
217         if (getAssetCount() < assetTagStats.getAssetCount()) {
218             value = -1;
219         }
220         else if (getAssetCount() > assetTagStats.getAssetCount()) {
221             value = 1;
222         }
223         else {
224             value = 0;
225         }
226 
227         value = value * -1;
228 
229         if (value != 0) {
230             return value;
231         }
232 
233         return 0;
234     }
235 
236     public boolean equals(Object obj) {
237         if (obj == null) {
238             return false;
239         }
240 
241         AssetTagStats assetTagStats = null;
242 
243         try {
244             assetTagStats = (AssetTagStats)obj;
245         }
246         catch (ClassCastException cce) {
247             return false;
248         }
249 
250         long pk = assetTagStats.getPrimaryKey();
251 
252         if (getPrimaryKey() == pk) {
253             return true;
254         }
255         else {
256             return false;
257         }
258     }
259 
260     public int hashCode() {
261         return (int)getPrimaryKey();
262     }
263 
264     public String toString() {
265         StringBundler sb = new StringBundler(9);
266 
267         sb.append("{tagStatsId=");
268         sb.append(getTagStatsId());
269         sb.append(", tagId=");
270         sb.append(getTagId());
271         sb.append(", classNameId=");
272         sb.append(getClassNameId());
273         sb.append(", assetCount=");
274         sb.append(getAssetCount());
275         sb.append("}");
276 
277         return sb.toString();
278     }
279 
280     public String toXmlString() {
281         StringBundler sb = new StringBundler(16);
282 
283         sb.append("<model><model-name>");
284         sb.append("com.liferay.portlet.asset.model.AssetTagStats");
285         sb.append("</model-name>");
286 
287         sb.append(
288             "<column><column-name>tagStatsId</column-name><column-value><![CDATA[");
289         sb.append(getTagStatsId());
290         sb.append("]]></column-value></column>");
291         sb.append(
292             "<column><column-name>tagId</column-name><column-value><![CDATA[");
293         sb.append(getTagId());
294         sb.append("]]></column-value></column>");
295         sb.append(
296             "<column><column-name>classNameId</column-name><column-value><![CDATA[");
297         sb.append(getClassNameId());
298         sb.append("]]></column-value></column>");
299         sb.append(
300             "<column><column-name>assetCount</column-name><column-value><![CDATA[");
301         sb.append(getAssetCount());
302         sb.append("]]></column-value></column>");
303 
304         sb.append("</model>");
305 
306         return sb.toString();
307     }
308 
309     private long _tagStatsId;
310     private long _tagId;
311     private long _originalTagId;
312     private boolean _setOriginalTagId;
313     private long _classNameId;
314     private long _originalClassNameId;
315     private boolean _setOriginalClassNameId;
316     private int _assetCount;
317     private transient ExpandoBridge _expandoBridge;
318 }