1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portlet.ratings.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.expando.model.ExpandoBridge;
26  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
27  import com.liferay.portlet.ratings.model.RatingsStats;
28  import com.liferay.portlet.ratings.model.RatingsStatsSoap;
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="RatingsStatsModelImpl.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 RatingsStats table in the
49   * database.
50   * </p>
51   *
52   * @author    Brian Wing Shun Chan
53   * @see       RatingsStatsImpl
54   * @see       com.liferay.portlet.ratings.model.RatingsStats
55   * @see       com.liferay.portlet.ratings.model.RatingsStatsModel
56   * @generated
57   */
58  public class RatingsStatsModelImpl extends BaseModelImpl<RatingsStats> {
59      public static final String TABLE_NAME = "RatingsStats";
60      public static final Object[][] TABLE_COLUMNS = {
61              { "statsId", new Integer(Types.BIGINT) },
62              { "classNameId", new Integer(Types.BIGINT) },
63              { "classPK", new Integer(Types.BIGINT) },
64              { "totalEntries", new Integer(Types.INTEGER) },
65              { "totalScore", new Integer(Types.DOUBLE) },
66              { "averageScore", new Integer(Types.DOUBLE) }
67          };
68      public static final String TABLE_SQL_CREATE = "create table RatingsStats (statsId LONG not null primary key,classNameId LONG,classPK LONG,totalEntries INTEGER,totalScore DOUBLE,averageScore DOUBLE)";
69      public static final String TABLE_SQL_DROP = "drop table RatingsStats";
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.ratings.model.RatingsStats"),
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.ratings.model.RatingsStats"),
78              true);
79  
80      public static RatingsStats toModel(RatingsStatsSoap soapModel) {
81          RatingsStats model = new RatingsStatsImpl();
82  
83          model.setStatsId(soapModel.getStatsId());
84          model.setClassNameId(soapModel.getClassNameId());
85          model.setClassPK(soapModel.getClassPK());
86          model.setTotalEntries(soapModel.getTotalEntries());
87          model.setTotalScore(soapModel.getTotalScore());
88          model.setAverageScore(soapModel.getAverageScore());
89  
90          return model;
91      }
92  
93      public static List<RatingsStats> toModels(RatingsStatsSoap[] soapModels) {
94          List<RatingsStats> models = new ArrayList<RatingsStats>(soapModels.length);
95  
96          for (RatingsStatsSoap soapModel : soapModels) {
97              models.add(toModel(soapModel));
98          }
99  
100         return models;
101     }
102 
103     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
104                 "lock.expiration.time.com.liferay.portlet.ratings.model.RatingsStats"));
105 
106     public RatingsStatsModelImpl() {
107     }
108 
109     public long getPrimaryKey() {
110         return _statsId;
111     }
112 
113     public void setPrimaryKey(long pk) {
114         setStatsId(pk);
115     }
116 
117     public Serializable getPrimaryKeyObj() {
118         return new Long(_statsId);
119     }
120 
121     public long getStatsId() {
122         return _statsId;
123     }
124 
125     public void setStatsId(long statsId) {
126         _statsId = statsId;
127     }
128 
129     public String getClassName() {
130         if (getClassNameId() <= 0) {
131             return StringPool.BLANK;
132         }
133 
134         return PortalUtil.getClassName(getClassNameId());
135     }
136 
137     public long getClassNameId() {
138         return _classNameId;
139     }
140 
141     public void setClassNameId(long classNameId) {
142         _classNameId = classNameId;
143 
144         if (!_setOriginalClassNameId) {
145             _setOriginalClassNameId = true;
146 
147             _originalClassNameId = classNameId;
148         }
149     }
150 
151     public long getOriginalClassNameId() {
152         return _originalClassNameId;
153     }
154 
155     public long getClassPK() {
156         return _classPK;
157     }
158 
159     public void setClassPK(long classPK) {
160         _classPK = classPK;
161 
162         if (!_setOriginalClassPK) {
163             _setOriginalClassPK = true;
164 
165             _originalClassPK = classPK;
166         }
167     }
168 
169     public long getOriginalClassPK() {
170         return _originalClassPK;
171     }
172 
173     public int getTotalEntries() {
174         return _totalEntries;
175     }
176 
177     public void setTotalEntries(int totalEntries) {
178         _totalEntries = totalEntries;
179     }
180 
181     public double getTotalScore() {
182         return _totalScore;
183     }
184 
185     public void setTotalScore(double totalScore) {
186         _totalScore = totalScore;
187     }
188 
189     public double getAverageScore() {
190         return _averageScore;
191     }
192 
193     public void setAverageScore(double averageScore) {
194         _averageScore = averageScore;
195     }
196 
197     public RatingsStats toEscapedModel() {
198         if (isEscapedModel()) {
199             return (RatingsStats)this;
200         }
201         else {
202             return (RatingsStats)Proxy.newProxyInstance(RatingsStats.class.getClassLoader(),
203                 new Class[] { RatingsStats.class },
204                 new AutoEscapeBeanHandler(this));
205         }
206     }
207 
208     public ExpandoBridge getExpandoBridge() {
209         if (_expandoBridge == null) {
210             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(RatingsStats.class.getName(),
211                     getPrimaryKey());
212         }
213 
214         return _expandoBridge;
215     }
216 
217     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
218         getExpandoBridge().setAttributes(serviceContext);
219     }
220 
221     public Object clone() {
222         RatingsStatsImpl clone = new RatingsStatsImpl();
223 
224         clone.setStatsId(getStatsId());
225         clone.setClassNameId(getClassNameId());
226         clone.setClassPK(getClassPK());
227         clone.setTotalEntries(getTotalEntries());
228         clone.setTotalScore(getTotalScore());
229         clone.setAverageScore(getAverageScore());
230 
231         return clone;
232     }
233 
234     public int compareTo(RatingsStats ratingsStats) {
235         long pk = ratingsStats.getPrimaryKey();
236 
237         if (getPrimaryKey() < pk) {
238             return -1;
239         }
240         else if (getPrimaryKey() > pk) {
241             return 1;
242         }
243         else {
244             return 0;
245         }
246     }
247 
248     public boolean equals(Object obj) {
249         if (obj == null) {
250             return false;
251         }
252 
253         RatingsStats ratingsStats = null;
254 
255         try {
256             ratingsStats = (RatingsStats)obj;
257         }
258         catch (ClassCastException cce) {
259             return false;
260         }
261 
262         long pk = ratingsStats.getPrimaryKey();
263 
264         if (getPrimaryKey() == pk) {
265             return true;
266         }
267         else {
268             return false;
269         }
270     }
271 
272     public int hashCode() {
273         return (int)getPrimaryKey();
274     }
275 
276     public String toString() {
277         StringBundler sb = new StringBundler(13);
278 
279         sb.append("{statsId=");
280         sb.append(getStatsId());
281         sb.append(", classNameId=");
282         sb.append(getClassNameId());
283         sb.append(", classPK=");
284         sb.append(getClassPK());
285         sb.append(", totalEntries=");
286         sb.append(getTotalEntries());
287         sb.append(", totalScore=");
288         sb.append(getTotalScore());
289         sb.append(", averageScore=");
290         sb.append(getAverageScore());
291         sb.append("}");
292 
293         return sb.toString();
294     }
295 
296     public String toXmlString() {
297         StringBundler sb = new StringBundler(22);
298 
299         sb.append("<model><model-name>");
300         sb.append("com.liferay.portlet.ratings.model.RatingsStats");
301         sb.append("</model-name>");
302 
303         sb.append(
304             "<column><column-name>statsId</column-name><column-value><![CDATA[");
305         sb.append(getStatsId());
306         sb.append("]]></column-value></column>");
307         sb.append(
308             "<column><column-name>classNameId</column-name><column-value><![CDATA[");
309         sb.append(getClassNameId());
310         sb.append("]]></column-value></column>");
311         sb.append(
312             "<column><column-name>classPK</column-name><column-value><![CDATA[");
313         sb.append(getClassPK());
314         sb.append("]]></column-value></column>");
315         sb.append(
316             "<column><column-name>totalEntries</column-name><column-value><![CDATA[");
317         sb.append(getTotalEntries());
318         sb.append("]]></column-value></column>");
319         sb.append(
320             "<column><column-name>totalScore</column-name><column-value><![CDATA[");
321         sb.append(getTotalScore());
322         sb.append("]]></column-value></column>");
323         sb.append(
324             "<column><column-name>averageScore</column-name><column-value><![CDATA[");
325         sb.append(getAverageScore());
326         sb.append("]]></column-value></column>");
327 
328         sb.append("</model>");
329 
330         return sb.toString();
331     }
332 
333     private long _statsId;
334     private long _classNameId;
335     private long _originalClassNameId;
336     private boolean _setOriginalClassNameId;
337     private long _classPK;
338     private long _originalClassPK;
339     private boolean _setOriginalClassPK;
340     private int _totalEntries;
341     private double _totalScore;
342     private double _averageScore;
343     private transient ExpandoBridge _expandoBridge;
344 }