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.service.ServiceContext;
30  import com.liferay.portal.util.PortalUtil;
31  
32  import com.liferay.portlet.expando.model.ExpandoBridge;
33  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
34  import com.liferay.portlet.ratings.model.RatingsStats;
35  import com.liferay.portlet.ratings.model.RatingsStatsSoap;
36  
37  import java.io.Serializable;
38  
39  import java.lang.reflect.Proxy;
40  
41  import java.sql.Types;
42  
43  import java.util.ArrayList;
44  import java.util.List;
45  
46  /**
47   * <a href="RatingsStatsModelImpl.java.html"><b><i>View Source</i></b></a>
48   *
49   * <p>
50   * ServiceBuilder generated this class. Modifications in this class will be
51   * overwritten the next time is generated.
52   * </p>
53   *
54   * <p>
55   * This interface is a model that represents the RatingsStats table in the
56   * database.
57   * </p>
58   *
59   * @author    Brian Wing Shun Chan
60   * @see       RatingsStatsImpl
61   * @see       com.liferay.portlet.ratings.model.RatingsStats
62   * @see       com.liferay.portlet.ratings.model.RatingsStatsModel
63   * @generated
64   */
65  public class RatingsStatsModelImpl extends BaseModelImpl<RatingsStats> {
66      public static final String TABLE_NAME = "RatingsStats";
67      public static final Object[][] TABLE_COLUMNS = {
68              { "statsId", new Integer(Types.BIGINT) },
69              { "classNameId", new Integer(Types.BIGINT) },
70              { "classPK", new Integer(Types.BIGINT) },
71              { "totalEntries", new Integer(Types.INTEGER) },
72              { "totalScore", new Integer(Types.DOUBLE) },
73              { "averageScore", new Integer(Types.DOUBLE) }
74          };
75      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)";
76      public static final String TABLE_SQL_DROP = "drop table RatingsStats";
77      public static final String DATA_SOURCE = "liferayDataSource";
78      public static final String SESSION_FACTORY = "liferaySessionFactory";
79      public static final String TX_MANAGER = "liferayTransactionManager";
80      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
81                  "value.object.entity.cache.enabled.com.liferay.portlet.ratings.model.RatingsStats"),
82              true);
83      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
84                  "value.object.finder.cache.enabled.com.liferay.portlet.ratings.model.RatingsStats"),
85              true);
86  
87      public static RatingsStats toModel(RatingsStatsSoap soapModel) {
88          RatingsStats model = new RatingsStatsImpl();
89  
90          model.setStatsId(soapModel.getStatsId());
91          model.setClassNameId(soapModel.getClassNameId());
92          model.setClassPK(soapModel.getClassPK());
93          model.setTotalEntries(soapModel.getTotalEntries());
94          model.setTotalScore(soapModel.getTotalScore());
95          model.setAverageScore(soapModel.getAverageScore());
96  
97          return model;
98      }
99  
100     public static List<RatingsStats> toModels(RatingsStatsSoap[] soapModels) {
101         List<RatingsStats> models = new ArrayList<RatingsStats>(soapModels.length);
102 
103         for (RatingsStatsSoap soapModel : soapModels) {
104             models.add(toModel(soapModel));
105         }
106 
107         return models;
108     }
109 
110     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
111                 "lock.expiration.time.com.liferay.portlet.ratings.model.RatingsStats"));
112 
113     public RatingsStatsModelImpl() {
114     }
115 
116     public long getPrimaryKey() {
117         return _statsId;
118     }
119 
120     public void setPrimaryKey(long pk) {
121         setStatsId(pk);
122     }
123 
124     public Serializable getPrimaryKeyObj() {
125         return new Long(_statsId);
126     }
127 
128     public long getStatsId() {
129         return _statsId;
130     }
131 
132     public void setStatsId(long statsId) {
133         _statsId = statsId;
134     }
135 
136     public String getClassName() {
137         if (getClassNameId() <= 0) {
138             return StringPool.BLANK;
139         }
140 
141         return PortalUtil.getClassName(getClassNameId());
142     }
143 
144     public long getClassNameId() {
145         return _classNameId;
146     }
147 
148     public void setClassNameId(long classNameId) {
149         _classNameId = classNameId;
150 
151         if (!_setOriginalClassNameId) {
152             _setOriginalClassNameId = true;
153 
154             _originalClassNameId = classNameId;
155         }
156     }
157 
158     public long getOriginalClassNameId() {
159         return _originalClassNameId;
160     }
161 
162     public long getClassPK() {
163         return _classPK;
164     }
165 
166     public void setClassPK(long classPK) {
167         _classPK = classPK;
168 
169         if (!_setOriginalClassPK) {
170             _setOriginalClassPK = true;
171 
172             _originalClassPK = classPK;
173         }
174     }
175 
176     public long getOriginalClassPK() {
177         return _originalClassPK;
178     }
179 
180     public int getTotalEntries() {
181         return _totalEntries;
182     }
183 
184     public void setTotalEntries(int totalEntries) {
185         _totalEntries = totalEntries;
186     }
187 
188     public double getTotalScore() {
189         return _totalScore;
190     }
191 
192     public void setTotalScore(double totalScore) {
193         _totalScore = totalScore;
194     }
195 
196     public double getAverageScore() {
197         return _averageScore;
198     }
199 
200     public void setAverageScore(double averageScore) {
201         _averageScore = averageScore;
202     }
203 
204     public RatingsStats toEscapedModel() {
205         if (isEscapedModel()) {
206             return (RatingsStats)this;
207         }
208         else {
209             RatingsStats model = new RatingsStatsImpl();
210 
211             model.setNew(isNew());
212             model.setEscapedModel(true);
213 
214             model.setStatsId(getStatsId());
215             model.setClassNameId(getClassNameId());
216             model.setClassPK(getClassPK());
217             model.setTotalEntries(getTotalEntries());
218             model.setTotalScore(getTotalScore());
219             model.setAverageScore(getAverageScore());
220 
221             model = (RatingsStats)Proxy.newProxyInstance(RatingsStats.class.getClassLoader(),
222                     new Class[] { RatingsStats.class },
223                     new ReadOnlyBeanHandler(model));
224 
225             return model;
226         }
227     }
228 
229     public ExpandoBridge getExpandoBridge() {
230         if (_expandoBridge == null) {
231             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(RatingsStats.class.getName(),
232                     getPrimaryKey());
233         }
234 
235         return _expandoBridge;
236     }
237 
238     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
239         getExpandoBridge().setAttributes(serviceContext);
240     }
241 
242     public Object clone() {
243         RatingsStatsImpl clone = new RatingsStatsImpl();
244 
245         clone.setStatsId(getStatsId());
246         clone.setClassNameId(getClassNameId());
247         clone.setClassPK(getClassPK());
248         clone.setTotalEntries(getTotalEntries());
249         clone.setTotalScore(getTotalScore());
250         clone.setAverageScore(getAverageScore());
251 
252         return clone;
253     }
254 
255     public int compareTo(RatingsStats ratingsStats) {
256         long pk = ratingsStats.getPrimaryKey();
257 
258         if (getPrimaryKey() < pk) {
259             return -1;
260         }
261         else if (getPrimaryKey() > pk) {
262             return 1;
263         }
264         else {
265             return 0;
266         }
267     }
268 
269     public boolean equals(Object obj) {
270         if (obj == null) {
271             return false;
272         }
273 
274         RatingsStats ratingsStats = null;
275 
276         try {
277             ratingsStats = (RatingsStats)obj;
278         }
279         catch (ClassCastException cce) {
280             return false;
281         }
282 
283         long pk = ratingsStats.getPrimaryKey();
284 
285         if (getPrimaryKey() == pk) {
286             return true;
287         }
288         else {
289             return false;
290         }
291     }
292 
293     public int hashCode() {
294         return (int)getPrimaryKey();
295     }
296 
297     public String toString() {
298         StringBuilder sb = new StringBuilder();
299 
300         sb.append("{statsId=");
301         sb.append(getStatsId());
302         sb.append(", classNameId=");
303         sb.append(getClassNameId());
304         sb.append(", classPK=");
305         sb.append(getClassPK());
306         sb.append(", totalEntries=");
307         sb.append(getTotalEntries());
308         sb.append(", totalScore=");
309         sb.append(getTotalScore());
310         sb.append(", averageScore=");
311         sb.append(getAverageScore());
312         sb.append("}");
313 
314         return sb.toString();
315     }
316 
317     public String toXmlString() {
318         StringBuilder sb = new StringBuilder();
319 
320         sb.append("<model><model-name>");
321         sb.append("com.liferay.portlet.ratings.model.RatingsStats");
322         sb.append("</model-name>");
323 
324         sb.append(
325             "<column><column-name>statsId</column-name><column-value><![CDATA[");
326         sb.append(getStatsId());
327         sb.append("]]></column-value></column>");
328         sb.append(
329             "<column><column-name>classNameId</column-name><column-value><![CDATA[");
330         sb.append(getClassNameId());
331         sb.append("]]></column-value></column>");
332         sb.append(
333             "<column><column-name>classPK</column-name><column-value><![CDATA[");
334         sb.append(getClassPK());
335         sb.append("]]></column-value></column>");
336         sb.append(
337             "<column><column-name>totalEntries</column-name><column-value><![CDATA[");
338         sb.append(getTotalEntries());
339         sb.append("]]></column-value></column>");
340         sb.append(
341             "<column><column-name>totalScore</column-name><column-value><![CDATA[");
342         sb.append(getTotalScore());
343         sb.append("]]></column-value></column>");
344         sb.append(
345             "<column><column-name>averageScore</column-name><column-value><![CDATA[");
346         sb.append(getAverageScore());
347         sb.append("]]></column-value></column>");
348 
349         sb.append("</model>");
350 
351         return sb.toString();
352     }
353 
354     private long _statsId;
355     private long _classNameId;
356     private long _originalClassNameId;
357     private boolean _setOriginalClassNameId;
358     private long _classPK;
359     private long _originalClassPK;
360     private boolean _setOriginalClassPK;
361     private int _totalEntries;
362     private double _totalScore;
363     private double _averageScore;
364     private transient ExpandoBridge _expandoBridge;
365 }