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.polls.model.impl;
16  
17  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
18  import com.liferay.portal.kernel.util.GetterUtil;
19  import com.liferay.portal.kernel.util.HtmlUtil;
20  import com.liferay.portal.kernel.util.StringBundler;
21  import com.liferay.portal.model.impl.BaseModelImpl;
22  
23  import com.liferay.portlet.polls.model.PollsChoice;
24  import com.liferay.portlet.polls.model.PollsChoiceSoap;
25  
26  import java.io.Serializable;
27  
28  import java.lang.reflect.Proxy;
29  
30  import java.sql.Types;
31  
32  import java.util.ArrayList;
33  import java.util.List;
34  
35  /**
36   * <a href="PollsChoiceModelImpl.java.html"><b><i>View Source</i></b></a>
37   *
38   * <p>
39   * ServiceBuilder generated this class. Modifications in this class will be
40   * overwritten the next time is generated.
41   * </p>
42   *
43   * <p>
44   * This interface is a model that represents the PollsChoice table in the
45   * database.
46   * </p>
47   *
48   * @author    Brian Wing Shun Chan
49   * @see       PollsChoiceImpl
50   * @see       com.liferay.portlet.polls.model.PollsChoice
51   * @see       com.liferay.portlet.polls.model.PollsChoiceModel
52   * @generated
53   */
54  public class PollsChoiceModelImpl extends BaseModelImpl<PollsChoice> {
55      public static final String TABLE_NAME = "PollsChoice";
56      public static final Object[][] TABLE_COLUMNS = {
57              { "uuid_", new Integer(Types.VARCHAR) },
58              { "choiceId", new Integer(Types.BIGINT) },
59              { "questionId", new Integer(Types.BIGINT) },
60              { "name", new Integer(Types.VARCHAR) },
61              { "description", new Integer(Types.VARCHAR) }
62          };
63      public static final String TABLE_SQL_CREATE = "create table PollsChoice (uuid_ VARCHAR(75) null,choiceId LONG not null primary key,questionId LONG,name VARCHAR(75) null,description VARCHAR(1000) null)";
64      public static final String TABLE_SQL_DROP = "drop table PollsChoice";
65      public static final String ORDER_BY_JPQL = " ORDER BY pollsChoice.questionId ASC, pollsChoice.name ASC";
66      public static final String ORDER_BY_SQL = " ORDER BY PollsChoice.questionId ASC, PollsChoice.name ASC";
67      public static final String DATA_SOURCE = "liferayDataSource";
68      public static final String SESSION_FACTORY = "liferaySessionFactory";
69      public static final String TX_MANAGER = "liferayTransactionManager";
70      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
71                  "value.object.entity.cache.enabled.com.liferay.portlet.polls.model.PollsChoice"),
72              true);
73      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
74                  "value.object.finder.cache.enabled.com.liferay.portlet.polls.model.PollsChoice"),
75              true);
76  
77      public static PollsChoice toModel(PollsChoiceSoap soapModel) {
78          PollsChoice model = new PollsChoiceImpl();
79  
80          model.setUuid(soapModel.getUuid());
81          model.setChoiceId(soapModel.getChoiceId());
82          model.setQuestionId(soapModel.getQuestionId());
83          model.setName(soapModel.getName());
84          model.setDescription(soapModel.getDescription());
85  
86          return model;
87      }
88  
89      public static List<PollsChoice> toModels(PollsChoiceSoap[] soapModels) {
90          List<PollsChoice> models = new ArrayList<PollsChoice>(soapModels.length);
91  
92          for (PollsChoiceSoap soapModel : soapModels) {
93              models.add(toModel(soapModel));
94          }
95  
96          return models;
97      }
98  
99      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
100                 "lock.expiration.time.com.liferay.portlet.polls.model.PollsChoice"));
101 
102     public PollsChoiceModelImpl() {
103     }
104 
105     public long getPrimaryKey() {
106         return _choiceId;
107     }
108 
109     public void setPrimaryKey(long pk) {
110         setChoiceId(pk);
111     }
112 
113     public Serializable getPrimaryKeyObj() {
114         return new Long(_choiceId);
115     }
116 
117     public String getUuid() {
118         return GetterUtil.getString(_uuid);
119     }
120 
121     public void setUuid(String uuid) {
122         _uuid = uuid;
123     }
124 
125     public long getChoiceId() {
126         return _choiceId;
127     }
128 
129     public void setChoiceId(long choiceId) {
130         _choiceId = choiceId;
131     }
132 
133     public long getQuestionId() {
134         return _questionId;
135     }
136 
137     public void setQuestionId(long questionId) {
138         _questionId = questionId;
139 
140         if (!_setOriginalQuestionId) {
141             _setOriginalQuestionId = true;
142 
143             _originalQuestionId = questionId;
144         }
145     }
146 
147     public long getOriginalQuestionId() {
148         return _originalQuestionId;
149     }
150 
151     public String getName() {
152         return GetterUtil.getString(_name);
153     }
154 
155     public void setName(String name) {
156         _name = name;
157 
158         if (_originalName == null) {
159             _originalName = name;
160         }
161     }
162 
163     public String getOriginalName() {
164         return GetterUtil.getString(_originalName);
165     }
166 
167     public String getDescription() {
168         return GetterUtil.getString(_description);
169     }
170 
171     public void setDescription(String description) {
172         _description = description;
173     }
174 
175     public PollsChoice toEscapedModel() {
176         if (isEscapedModel()) {
177             return (PollsChoice)this;
178         }
179         else {
180             PollsChoice model = new PollsChoiceImpl();
181 
182             model.setNew(isNew());
183             model.setEscapedModel(true);
184 
185             model.setUuid(HtmlUtil.escape(getUuid()));
186             model.setChoiceId(getChoiceId());
187             model.setQuestionId(getQuestionId());
188             model.setName(HtmlUtil.escape(getName()));
189             model.setDescription(HtmlUtil.escape(getDescription()));
190 
191             model = (PollsChoice)Proxy.newProxyInstance(PollsChoice.class.getClassLoader(),
192                     new Class[] { PollsChoice.class },
193                     new ReadOnlyBeanHandler(model));
194 
195             return model;
196         }
197     }
198 
199     public Object clone() {
200         PollsChoiceImpl clone = new PollsChoiceImpl();
201 
202         clone.setUuid(getUuid());
203         clone.setChoiceId(getChoiceId());
204         clone.setQuestionId(getQuestionId());
205         clone.setName(getName());
206         clone.setDescription(getDescription());
207 
208         return clone;
209     }
210 
211     public int compareTo(PollsChoice pollsChoice) {
212         int value = 0;
213 
214         if (getQuestionId() < pollsChoice.getQuestionId()) {
215             value = -1;
216         }
217         else if (getQuestionId() > pollsChoice.getQuestionId()) {
218             value = 1;
219         }
220         else {
221             value = 0;
222         }
223 
224         if (value != 0) {
225             return value;
226         }
227 
228         value = getName().compareTo(pollsChoice.getName());
229 
230         if (value != 0) {
231             return value;
232         }
233 
234         return 0;
235     }
236 
237     public boolean equals(Object obj) {
238         if (obj == null) {
239             return false;
240         }
241 
242         PollsChoice pollsChoice = null;
243 
244         try {
245             pollsChoice = (PollsChoice)obj;
246         }
247         catch (ClassCastException cce) {
248             return false;
249         }
250 
251         long pk = pollsChoice.getPrimaryKey();
252 
253         if (getPrimaryKey() == pk) {
254             return true;
255         }
256         else {
257             return false;
258         }
259     }
260 
261     public int hashCode() {
262         return (int)getPrimaryKey();
263     }
264 
265     public String toString() {
266         StringBundler sb = new StringBundler(11);
267 
268         sb.append("{uuid=");
269         sb.append(getUuid());
270         sb.append(", choiceId=");
271         sb.append(getChoiceId());
272         sb.append(", questionId=");
273         sb.append(getQuestionId());
274         sb.append(", name=");
275         sb.append(getName());
276         sb.append(", description=");
277         sb.append(getDescription());
278         sb.append("}");
279 
280         return sb.toString();
281     }
282 
283     public String toXmlString() {
284         StringBundler sb = new StringBundler(19);
285 
286         sb.append("<model><model-name>");
287         sb.append("com.liferay.portlet.polls.model.PollsChoice");
288         sb.append("</model-name>");
289 
290         sb.append(
291             "<column><column-name>uuid</column-name><column-value><![CDATA[");
292         sb.append(getUuid());
293         sb.append("]]></column-value></column>");
294         sb.append(
295             "<column><column-name>choiceId</column-name><column-value><![CDATA[");
296         sb.append(getChoiceId());
297         sb.append("]]></column-value></column>");
298         sb.append(
299             "<column><column-name>questionId</column-name><column-value><![CDATA[");
300         sb.append(getQuestionId());
301         sb.append("]]></column-value></column>");
302         sb.append(
303             "<column><column-name>name</column-name><column-value><![CDATA[");
304         sb.append(getName());
305         sb.append("]]></column-value></column>");
306         sb.append(
307             "<column><column-name>description</column-name><column-value><![CDATA[");
308         sb.append(getDescription());
309         sb.append("]]></column-value></column>");
310 
311         sb.append("</model>");
312 
313         return sb.toString();
314     }
315 
316     private String _uuid;
317     private long _choiceId;
318     private long _questionId;
319     private long _originalQuestionId;
320     private boolean _setOriginalQuestionId;
321     private String _name;
322     private String _originalName;
323     private String _description;
324 }