1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portlet.ratings.model.impl;
24  
25  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.GetterUtil;
27  import com.liferay.portal.kernel.util.StringPool;
28  import com.liferay.portal.model.impl.BaseModelImpl;
29  import com.liferay.portal.util.PortalUtil;
30  
31  import com.liferay.portlet.ratings.model.RatingsStats;
32  import com.liferay.portlet.ratings.model.RatingsStatsSoap;
33  
34  import java.io.Serializable;
35  
36  import java.lang.reflect.Proxy;
37  
38  import java.sql.Types;
39  
40  import java.util.ArrayList;
41  import java.util.List;
42  
43  /**
44   * <a href="RatingsStatsModelImpl.java.html"><b><i>View Source</i></b></a>
45   *
46   * <p>
47   * ServiceBuilder generated this class. Modifications in this class will be
48   * overwritten the next time is generated.
49   * </p>
50   *
51   * <p>
52   * This interface is a model that represents the RatingsStats table in the
53   * database.
54   * </p>
55   *
56   * @author    Brian Wing Shun Chan
57   * @see       RatingsStatsImpl
58   * @see       com.liferay.portlet.ratings.model.RatingsStats
59   * @see       com.liferay.portlet.ratings.model.RatingsStatsModel
60   * @generated
61   */
62  public class RatingsStatsModelImpl extends BaseModelImpl<RatingsStats> {
63      public static final String TABLE_NAME = "RatingsStats";
64      public static final Object[][] TABLE_COLUMNS = {
65              { "statsId", new Integer(Types.BIGINT) },
66              { "classNameId", new Integer(Types.BIGINT) },
67              { "classPK", new Integer(Types.BIGINT) },
68              { "totalEntries", new Integer(Types.INTEGER) },
69              { "totalScore", new Integer(Types.DOUBLE) },
70              { "averageScore", new Integer(Types.DOUBLE) }
71          };
72      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)";
73      public static final String TABLE_SQL_DROP = "drop table RatingsStats";
74      public static final String DATA_SOURCE = "liferayDataSource";
75      public static final String SESSION_FACTORY = "liferaySessionFactory";
76      public static final String TX_MANAGER = "liferayTransactionManager";
77      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
78                  "value.object.entity.cache.enabled.com.liferay.portlet.ratings.model.RatingsStats"),
79              true);
80      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
81                  "value.object.finder.cache.enabled.com.liferay.portlet.ratings.model.RatingsStats"),
82              true);
83  
84      public static RatingsStats toModel(RatingsStatsSoap soapModel) {
85          RatingsStats model = new RatingsStatsImpl();
86  
87          model.setStatsId(soapModel.getStatsId());
88          model.setClassNameId(soapModel.getClassNameId());
89          model.setClassPK(soapModel.getClassPK());
90          model.setTotalEntries(soapModel.getTotalEntries());
91          model.setTotalScore(soapModel.getTotalScore());
92          model.setAverageScore(soapModel.getAverageScore());
93  
94          return model;
95      }
96  
97      public static List<RatingsStats> toModels(RatingsStatsSoap[] soapModels) {
98          List<RatingsStats> models = new ArrayList<RatingsStats>(soapModels.length);
99  
100         for (RatingsStatsSoap soapModel : soapModels) {
101             models.add(toModel(soapModel));
102         }
103 
104         return models;
105     }
106 
107     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
108                 "lock.expiration.time.com.liferay.portlet.ratings.model.RatingsStats"));
109 
110     public RatingsStatsModelImpl() {
111     }
112 
113     public long getPrimaryKey() {
114         return _statsId;
115     }
116 
117     public void setPrimaryKey(long pk) {
118         setStatsId(pk);
119     }
120 
121     public Serializable getPrimaryKeyObj() {
122         return new Long(_statsId);
123     }
124 
125     public long getStatsId() {
126         return _statsId;
127     }
128 
129     public void setStatsId(long statsId) {
130         _statsId = statsId;
131     }
132 
133     public String getClassName() {
134         if (getClassNameId() <= 0) {
135             return StringPool.BLANK;
136         }
137 
138         return PortalUtil.getClassName(getClassNameId());
139     }
140 
141     public long getClassNameId() {
142         return _classNameId;
143     }
144 
145     public void setClassNameId(long classNameId) {
146         _classNameId = classNameId;
147 
148         if (!_setOriginalClassNameId) {
149             _setOriginalClassNameId = true;
150 
151             _originalClassNameId = classNameId;
152         }
153     }
154 
155     public long getOriginalClassNameId() {
156         return _originalClassNameId;
157     }
158 
159     public long getClassPK() {
160         return _classPK;
161     }
162 
163     public void setClassPK(long classPK) {
164         _classPK = classPK;
165 
166         if (!_setOriginalClassPK) {
167             _setOriginalClassPK = true;
168 
169             _originalClassPK = classPK;
170         }
171     }
172 
173     public long getOriginalClassPK() {
174         return _originalClassPK;
175     }
176 
177     public int getTotalEntries() {
178         return _totalEntries;
179     }
180 
181     public void setTotalEntries(int totalEntries) {
182         _totalEntries = totalEntries;
183     }
184 
185     public double getTotalScore() {
186         return _totalScore;
187     }
188 
189     public void setTotalScore(double totalScore) {
190         _totalScore = totalScore;
191     }
192 
193     public double getAverageScore() {
194         return _averageScore;
195     }
196 
197     public void setAverageScore(double averageScore) {
198         _averageScore = averageScore;
199     }
200 
201     public RatingsStats toEscapedModel() {
202         if (isEscapedModel()) {
203             return (RatingsStats)this;
204         }
205         else {
206             RatingsStats model = new RatingsStatsImpl();
207 
208             model.setNew(isNew());
209             model.setEscapedModel(true);
210 
211             model.setStatsId(getStatsId());
212             model.setClassNameId(getClassNameId());
213             model.setClassPK(getClassPK());
214             model.setTotalEntries(getTotalEntries());
215             model.setTotalScore(getTotalScore());
216             model.setAverageScore(getAverageScore());
217 
218             model = (RatingsStats)Proxy.newProxyInstance(RatingsStats.class.getClassLoader(),
219                     new Class[] { RatingsStats.class },
220                     new ReadOnlyBeanHandler(model));
221 
222             return model;
223         }
224     }
225 
226     public Object clone() {
227         RatingsStatsImpl clone = new RatingsStatsImpl();
228 
229         clone.setStatsId(getStatsId());
230         clone.setClassNameId(getClassNameId());
231         clone.setClassPK(getClassPK());
232         clone.setTotalEntries(getTotalEntries());
233         clone.setTotalScore(getTotalScore());
234         clone.setAverageScore(getAverageScore());
235 
236         return clone;
237     }
238 
239     public int compareTo(RatingsStats ratingsStats) {
240         long pk = ratingsStats.getPrimaryKey();
241 
242         if (getPrimaryKey() < pk) {
243             return -1;
244         }
245         else if (getPrimaryKey() > pk) {
246             return 1;
247         }
248         else {
249             return 0;
250         }
251     }
252 
253     public boolean equals(Object obj) {
254         if (obj == null) {
255             return false;
256         }
257 
258         RatingsStats ratingsStats = null;
259 
260         try {
261             ratingsStats = (RatingsStats)obj;
262         }
263         catch (ClassCastException cce) {
264             return false;
265         }
266 
267         long pk = ratingsStats.getPrimaryKey();
268 
269         if (getPrimaryKey() == pk) {
270             return true;
271         }
272         else {
273             return false;
274         }
275     }
276 
277     public int hashCode() {
278         return (int)getPrimaryKey();
279     }
280 
281     public String toString() {
282         StringBuilder sb = new StringBuilder();
283 
284         sb.append("{statsId=");
285         sb.append(getStatsId());
286         sb.append(", classNameId=");
287         sb.append(getClassNameId());
288         sb.append(", classPK=");
289         sb.append(getClassPK());
290         sb.append(", totalEntries=");
291         sb.append(getTotalEntries());
292         sb.append(", totalScore=");
293         sb.append(getTotalScore());
294         sb.append(", averageScore=");
295         sb.append(getAverageScore());
296         sb.append("}");
297 
298         return sb.toString();
299     }
300 
301     public String toXmlString() {
302         StringBuilder sb = new StringBuilder();
303 
304         sb.append("<model><model-name>");
305         sb.append("com.liferay.portlet.ratings.model.RatingsStats");
306         sb.append("</model-name>");
307 
308         sb.append(
309             "<column><column-name>statsId</column-name><column-value><![CDATA[");
310         sb.append(getStatsId());
311         sb.append("]]></column-value></column>");
312         sb.append(
313             "<column><column-name>classNameId</column-name><column-value><![CDATA[");
314         sb.append(getClassNameId());
315         sb.append("]]></column-value></column>");
316         sb.append(
317             "<column><column-name>classPK</column-name><column-value><![CDATA[");
318         sb.append(getClassPK());
319         sb.append("]]></column-value></column>");
320         sb.append(
321             "<column><column-name>totalEntries</column-name><column-value><![CDATA[");
322         sb.append(getTotalEntries());
323         sb.append("]]></column-value></column>");
324         sb.append(
325             "<column><column-name>totalScore</column-name><column-value><![CDATA[");
326         sb.append(getTotalScore());
327         sb.append("]]></column-value></column>");
328         sb.append(
329             "<column><column-name>averageScore</column-name><column-value><![CDATA[");
330         sb.append(getAverageScore());
331         sb.append("]]></column-value></column>");
332 
333         sb.append("</model>");
334 
335         return sb.toString();
336     }
337 
338     private long _statsId;
339     private long _classNameId;
340     private long _originalClassNameId;
341     private boolean _setOriginalClassNameId;
342     private long _classPK;
343     private long _originalClassPK;
344     private boolean _setOriginalClassPK;
345     private int _totalEntries;
346     private double _totalScore;
347     private double _averageScore;
348 }