1   /**
2    * Copyright (c) 2000-2007 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions 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.util.GetterUtil;
26  import com.liferay.portal.model.impl.BaseModelImpl;
27  import com.liferay.portal.util.PropsUtil;
28  
29  import java.io.Serializable;
30  
31  import java.sql.Types;
32  
33  /**
34   * <a href="RatingsStatsModelImpl.java.html"><b><i>View Source</i></b></a>
35   *
36   * <p>
37   * ServiceBuilder generated this class. Modifications in this class will be overwritten
38   * the next time is generated.
39   * </p>
40   *
41   * <p>
42   * This class is a model that represents the <code>RatingsStats</code> table in
43   * the database.
44   * </p>
45   *
46   * @author Brian Wing Shun Chan
47   *
48   * @see com.liferay.portlet.ratings.service.model.RatingsStats
49   * @see com.liferay.portlet.ratings.service.model.RatingsStatsModel
50   * @see com.liferay.portlet.ratings.service.model.impl.RatingsStatsImpl
51   *
52   */
53  public class RatingsStatsModelImpl extends BaseModelImpl {
54      public static String TABLE_NAME = "RatingsStats";
55      public static Object[][] TABLE_COLUMNS = {
56              { "statsId", new Integer(Types.BIGINT) },
57              { "classNameId", new Integer(Types.BIGINT) },
58              { "classPK", new Integer(Types.BIGINT) },
59              { "totalEntries", new Integer(Types.INTEGER) },
60              { "totalScore", new Integer(Types.DOUBLE) },
61              { "averageScore", new Integer(Types.DOUBLE) }
62          };
63      public static String TABLE_SQL_CREATE = "create table RatingsStats (statsId LONG not null primary key,classNameId LONG,classPK LONG,totalEntries INTEGER,totalScore DOUBLE,averageScore DOUBLE)";
64      public static String TABLE_SQL_DROP = "drop table RatingsStats";
65      public static boolean XSS_ALLOW_BY_MODEL = GetterUtil.getBoolean(PropsUtil.get(
66                  "xss.allow.com.liferay.portlet.ratings.model.RatingsStats"),
67              XSS_ALLOW);
68      public static long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
69                  "lock.expiration.time.com.liferay.portlet.ratings.model.RatingsStatsModel"));
70  
71      public RatingsStatsModelImpl() {
72      }
73  
74      public long getPrimaryKey() {
75          return _statsId;
76      }
77  
78      public void setPrimaryKey(long pk) {
79          setStatsId(pk);
80      }
81  
82      public Serializable getPrimaryKeyObj() {
83          return new Long(_statsId);
84      }
85  
86      public long getStatsId() {
87          return _statsId;
88      }
89  
90      public void setStatsId(long statsId) {
91          if (statsId != _statsId) {
92              _statsId = statsId;
93          }
94      }
95  
96      public long getClassNameId() {
97          return _classNameId;
98      }
99  
100     public void setClassNameId(long classNameId) {
101         if (classNameId != _classNameId) {
102             _classNameId = classNameId;
103         }
104     }
105 
106     public long getClassPK() {
107         return _classPK;
108     }
109 
110     public void setClassPK(long classPK) {
111         if (classPK != _classPK) {
112             _classPK = classPK;
113         }
114     }
115 
116     public int getTotalEntries() {
117         return _totalEntries;
118     }
119 
120     public void setTotalEntries(int totalEntries) {
121         if (totalEntries != _totalEntries) {
122             _totalEntries = totalEntries;
123         }
124     }
125 
126     public double getTotalScore() {
127         return _totalScore;
128     }
129 
130     public void setTotalScore(double totalScore) {
131         if (totalScore != _totalScore) {
132             _totalScore = totalScore;
133         }
134     }
135 
136     public double getAverageScore() {
137         return _averageScore;
138     }
139 
140     public void setAverageScore(double averageScore) {
141         if (averageScore != _averageScore) {
142             _averageScore = averageScore;
143         }
144     }
145 
146     public Object clone() {
147         RatingsStatsImpl clone = new RatingsStatsImpl();
148         clone.setStatsId(getStatsId());
149         clone.setClassNameId(getClassNameId());
150         clone.setClassPK(getClassPK());
151         clone.setTotalEntries(getTotalEntries());
152         clone.setTotalScore(getTotalScore());
153         clone.setAverageScore(getAverageScore());
154 
155         return clone;
156     }
157 
158     public int compareTo(Object obj) {
159         if (obj == null) {
160             return -1;
161         }
162 
163         RatingsStatsImpl ratingsStats = (RatingsStatsImpl)obj;
164         long pk = ratingsStats.getPrimaryKey();
165 
166         if (getPrimaryKey() < pk) {
167             return -1;
168         }
169         else if (getPrimaryKey() > pk) {
170             return 1;
171         }
172         else {
173             return 0;
174         }
175     }
176 
177     public boolean equals(Object obj) {
178         if (obj == null) {
179             return false;
180         }
181 
182         RatingsStatsImpl ratingsStats = null;
183 
184         try {
185             ratingsStats = (RatingsStatsImpl)obj;
186         }
187         catch (ClassCastException cce) {
188             return false;
189         }
190 
191         long pk = ratingsStats.getPrimaryKey();
192 
193         if (getPrimaryKey() == pk) {
194             return true;
195         }
196         else {
197             return false;
198         }
199     }
200 
201     public int hashCode() {
202         return (int)getPrimaryKey();
203     }
204 
205     private long _statsId;
206     private long _classNameId;
207     private long _classPK;
208     private int _totalEntries;
209     private double _totalScore;
210     private double _averageScore;
211 }