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.polls.model.impl;
24  
25  import com.liferay.portal.SystemException;
26  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
27  import com.liferay.portal.kernel.util.DateUtil;
28  import com.liferay.portal.kernel.util.GetterUtil;
29  import com.liferay.portal.kernel.util.HtmlUtil;
30  import com.liferay.portal.kernel.util.StringBundler;
31  import com.liferay.portal.model.impl.BaseModelImpl;
32  import com.liferay.portal.service.ServiceContext;
33  import com.liferay.portal.util.PortalUtil;
34  
35  import com.liferay.portlet.expando.model.ExpandoBridge;
36  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
37  import com.liferay.portlet.polls.model.PollsQuestion;
38  import com.liferay.portlet.polls.model.PollsQuestionSoap;
39  
40  import java.io.Serializable;
41  
42  import java.lang.reflect.Proxy;
43  
44  import java.sql.Types;
45  
46  import java.util.ArrayList;
47  import java.util.Date;
48  import java.util.List;
49  
50  /**
51   * <a href="PollsQuestionModelImpl.java.html"><b><i>View Source</i></b></a>
52   *
53   * <p>
54   * ServiceBuilder generated this class. Modifications in this class will be
55   * overwritten the next time is generated.
56   * </p>
57   *
58   * <p>
59   * This interface is a model that represents the PollsQuestion table in the
60   * database.
61   * </p>
62   *
63   * @author    Brian Wing Shun Chan
64   * @see       PollsQuestionImpl
65   * @see       com.liferay.portlet.polls.model.PollsQuestion
66   * @see       com.liferay.portlet.polls.model.PollsQuestionModel
67   * @generated
68   */
69  public class PollsQuestionModelImpl extends BaseModelImpl<PollsQuestion> {
70      public static final String TABLE_NAME = "PollsQuestion";
71      public static final Object[][] TABLE_COLUMNS = {
72              { "uuid_", new Integer(Types.VARCHAR) },
73              { "questionId", new Integer(Types.BIGINT) },
74              { "groupId", new Integer(Types.BIGINT) },
75              { "companyId", new Integer(Types.BIGINT) },
76              { "userId", new Integer(Types.BIGINT) },
77              { "userName", new Integer(Types.VARCHAR) },
78              { "createDate", new Integer(Types.TIMESTAMP) },
79              { "modifiedDate", new Integer(Types.TIMESTAMP) },
80              { "title", new Integer(Types.VARCHAR) },
81              { "description", new Integer(Types.VARCHAR) },
82              { "expirationDate", new Integer(Types.TIMESTAMP) },
83              { "lastVoteDate", new Integer(Types.TIMESTAMP) }
84          };
85      public static final String TABLE_SQL_CREATE = "create table PollsQuestion (uuid_ VARCHAR(75) null,questionId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,title VARCHAR(500) null,description STRING null,expirationDate DATE null,lastVoteDate DATE null)";
86      public static final String TABLE_SQL_DROP = "drop table PollsQuestion";
87      public static final String ORDER_BY_JPQL = " ORDER BY pollsQuestion.createDate DESC";
88      public static final String ORDER_BY_SQL = " ORDER BY PollsQuestion.createDate DESC";
89      public static final String DATA_SOURCE = "liferayDataSource";
90      public static final String SESSION_FACTORY = "liferaySessionFactory";
91      public static final String TX_MANAGER = "liferayTransactionManager";
92      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
93                  "value.object.entity.cache.enabled.com.liferay.portlet.polls.model.PollsQuestion"),
94              true);
95      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
96                  "value.object.finder.cache.enabled.com.liferay.portlet.polls.model.PollsQuestion"),
97              true);
98  
99      public static PollsQuestion toModel(PollsQuestionSoap soapModel) {
100         PollsQuestion model = new PollsQuestionImpl();
101 
102         model.setUuid(soapModel.getUuid());
103         model.setQuestionId(soapModel.getQuestionId());
104         model.setGroupId(soapModel.getGroupId());
105         model.setCompanyId(soapModel.getCompanyId());
106         model.setUserId(soapModel.getUserId());
107         model.setUserName(soapModel.getUserName());
108         model.setCreateDate(soapModel.getCreateDate());
109         model.setModifiedDate(soapModel.getModifiedDate());
110         model.setTitle(soapModel.getTitle());
111         model.setDescription(soapModel.getDescription());
112         model.setExpirationDate(soapModel.getExpirationDate());
113         model.setLastVoteDate(soapModel.getLastVoteDate());
114 
115         return model;
116     }
117 
118     public static List<PollsQuestion> toModels(PollsQuestionSoap[] soapModels) {
119         List<PollsQuestion> models = new ArrayList<PollsQuestion>(soapModels.length);
120 
121         for (PollsQuestionSoap soapModel : soapModels) {
122             models.add(toModel(soapModel));
123         }
124 
125         return models;
126     }
127 
128     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
129                 "lock.expiration.time.com.liferay.portlet.polls.model.PollsQuestion"));
130 
131     public PollsQuestionModelImpl() {
132     }
133 
134     public long getPrimaryKey() {
135         return _questionId;
136     }
137 
138     public void setPrimaryKey(long pk) {
139         setQuestionId(pk);
140     }
141 
142     public Serializable getPrimaryKeyObj() {
143         return new Long(_questionId);
144     }
145 
146     public String getUuid() {
147         return GetterUtil.getString(_uuid);
148     }
149 
150     public void setUuid(String uuid) {
151         _uuid = uuid;
152 
153         if (_originalUuid == null) {
154             _originalUuid = uuid;
155         }
156     }
157 
158     public String getOriginalUuid() {
159         return GetterUtil.getString(_originalUuid);
160     }
161 
162     public long getQuestionId() {
163         return _questionId;
164     }
165 
166     public void setQuestionId(long questionId) {
167         _questionId = questionId;
168     }
169 
170     public long getGroupId() {
171         return _groupId;
172     }
173 
174     public void setGroupId(long groupId) {
175         _groupId = groupId;
176 
177         if (!_setOriginalGroupId) {
178             _setOriginalGroupId = true;
179 
180             _originalGroupId = groupId;
181         }
182     }
183 
184     public long getOriginalGroupId() {
185         return _originalGroupId;
186     }
187 
188     public long getCompanyId() {
189         return _companyId;
190     }
191 
192     public void setCompanyId(long companyId) {
193         _companyId = companyId;
194     }
195 
196     public long getUserId() {
197         return _userId;
198     }
199 
200     public void setUserId(long userId) {
201         _userId = userId;
202     }
203 
204     public String getUserUuid() throws SystemException {
205         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
206     }
207 
208     public void setUserUuid(String userUuid) {
209         _userUuid = userUuid;
210     }
211 
212     public String getUserName() {
213         return GetterUtil.getString(_userName);
214     }
215 
216     public void setUserName(String userName) {
217         _userName = userName;
218     }
219 
220     public Date getCreateDate() {
221         return _createDate;
222     }
223 
224     public void setCreateDate(Date createDate) {
225         _createDate = createDate;
226     }
227 
228     public Date getModifiedDate() {
229         return _modifiedDate;
230     }
231 
232     public void setModifiedDate(Date modifiedDate) {
233         _modifiedDate = modifiedDate;
234     }
235 
236     public String getTitle() {
237         return GetterUtil.getString(_title);
238     }
239 
240     public void setTitle(String title) {
241         _title = title;
242     }
243 
244     public String getDescription() {
245         return GetterUtil.getString(_description);
246     }
247 
248     public void setDescription(String description) {
249         _description = description;
250     }
251 
252     public Date getExpirationDate() {
253         return _expirationDate;
254     }
255 
256     public void setExpirationDate(Date expirationDate) {
257         _expirationDate = expirationDate;
258     }
259 
260     public Date getLastVoteDate() {
261         return _lastVoteDate;
262     }
263 
264     public void setLastVoteDate(Date lastVoteDate) {
265         _lastVoteDate = lastVoteDate;
266     }
267 
268     public PollsQuestion toEscapedModel() {
269         if (isEscapedModel()) {
270             return (PollsQuestion)this;
271         }
272         else {
273             PollsQuestion model = new PollsQuestionImpl();
274 
275             model.setNew(isNew());
276             model.setEscapedModel(true);
277 
278             model.setUuid(HtmlUtil.escape(getUuid()));
279             model.setQuestionId(getQuestionId());
280             model.setGroupId(getGroupId());
281             model.setCompanyId(getCompanyId());
282             model.setUserId(getUserId());
283             model.setUserName(HtmlUtil.escape(getUserName()));
284             model.setCreateDate(getCreateDate());
285             model.setModifiedDate(getModifiedDate());
286             model.setTitle(HtmlUtil.escape(getTitle()));
287             model.setDescription(HtmlUtil.escape(getDescription()));
288             model.setExpirationDate(getExpirationDate());
289             model.setLastVoteDate(getLastVoteDate());
290 
291             model = (PollsQuestion)Proxy.newProxyInstance(PollsQuestion.class.getClassLoader(),
292                     new Class[] { PollsQuestion.class },
293                     new ReadOnlyBeanHandler(model));
294 
295             return model;
296         }
297     }
298 
299     public ExpandoBridge getExpandoBridge() {
300         if (_expandoBridge == null) {
301             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(PollsQuestion.class.getName(),
302                     getPrimaryKey());
303         }
304 
305         return _expandoBridge;
306     }
307 
308     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
309         getExpandoBridge().setAttributes(serviceContext);
310     }
311 
312     public Object clone() {
313         PollsQuestionImpl clone = new PollsQuestionImpl();
314 
315         clone.setUuid(getUuid());
316         clone.setQuestionId(getQuestionId());
317         clone.setGroupId(getGroupId());
318         clone.setCompanyId(getCompanyId());
319         clone.setUserId(getUserId());
320         clone.setUserName(getUserName());
321         clone.setCreateDate(getCreateDate());
322         clone.setModifiedDate(getModifiedDate());
323         clone.setTitle(getTitle());
324         clone.setDescription(getDescription());
325         clone.setExpirationDate(getExpirationDate());
326         clone.setLastVoteDate(getLastVoteDate());
327 
328         return clone;
329     }
330 
331     public int compareTo(PollsQuestion pollsQuestion) {
332         int value = 0;
333 
334         value = DateUtil.compareTo(getCreateDate(),
335                 pollsQuestion.getCreateDate());
336 
337         value = value * -1;
338 
339         if (value != 0) {
340             return value;
341         }
342 
343         return 0;
344     }
345 
346     public boolean equals(Object obj) {
347         if (obj == null) {
348             return false;
349         }
350 
351         PollsQuestion pollsQuestion = null;
352 
353         try {
354             pollsQuestion = (PollsQuestion)obj;
355         }
356         catch (ClassCastException cce) {
357             return false;
358         }
359 
360         long pk = pollsQuestion.getPrimaryKey();
361 
362         if (getPrimaryKey() == pk) {
363             return true;
364         }
365         else {
366             return false;
367         }
368     }
369 
370     public int hashCode() {
371         return (int)getPrimaryKey();
372     }
373 
374     public String toString() {
375         StringBundler sb = new StringBundler(25);
376 
377         sb.append("{uuid=");
378         sb.append(getUuid());
379         sb.append(", questionId=");
380         sb.append(getQuestionId());
381         sb.append(", groupId=");
382         sb.append(getGroupId());
383         sb.append(", companyId=");
384         sb.append(getCompanyId());
385         sb.append(", userId=");
386         sb.append(getUserId());
387         sb.append(", userName=");
388         sb.append(getUserName());
389         sb.append(", createDate=");
390         sb.append(getCreateDate());
391         sb.append(", modifiedDate=");
392         sb.append(getModifiedDate());
393         sb.append(", title=");
394         sb.append(getTitle());
395         sb.append(", description=");
396         sb.append(getDescription());
397         sb.append(", expirationDate=");
398         sb.append(getExpirationDate());
399         sb.append(", lastVoteDate=");
400         sb.append(getLastVoteDate());
401         sb.append("}");
402 
403         return sb.toString();
404     }
405 
406     public String toXmlString() {
407         StringBundler sb = new StringBundler(40);
408 
409         sb.append("<model><model-name>");
410         sb.append("com.liferay.portlet.polls.model.PollsQuestion");
411         sb.append("</model-name>");
412 
413         sb.append(
414             "<column><column-name>uuid</column-name><column-value><![CDATA[");
415         sb.append(getUuid());
416         sb.append("]]></column-value></column>");
417         sb.append(
418             "<column><column-name>questionId</column-name><column-value><![CDATA[");
419         sb.append(getQuestionId());
420         sb.append("]]></column-value></column>");
421         sb.append(
422             "<column><column-name>groupId</column-name><column-value><![CDATA[");
423         sb.append(getGroupId());
424         sb.append("]]></column-value></column>");
425         sb.append(
426             "<column><column-name>companyId</column-name><column-value><![CDATA[");
427         sb.append(getCompanyId());
428         sb.append("]]></column-value></column>");
429         sb.append(
430             "<column><column-name>userId</column-name><column-value><![CDATA[");
431         sb.append(getUserId());
432         sb.append("]]></column-value></column>");
433         sb.append(
434             "<column><column-name>userName</column-name><column-value><![CDATA[");
435         sb.append(getUserName());
436         sb.append("]]></column-value></column>");
437         sb.append(
438             "<column><column-name>createDate</column-name><column-value><![CDATA[");
439         sb.append(getCreateDate());
440         sb.append("]]></column-value></column>");
441         sb.append(
442             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
443         sb.append(getModifiedDate());
444         sb.append("]]></column-value></column>");
445         sb.append(
446             "<column><column-name>title</column-name><column-value><![CDATA[");
447         sb.append(getTitle());
448         sb.append("]]></column-value></column>");
449         sb.append(
450             "<column><column-name>description</column-name><column-value><![CDATA[");
451         sb.append(getDescription());
452         sb.append("]]></column-value></column>");
453         sb.append(
454             "<column><column-name>expirationDate</column-name><column-value><![CDATA[");
455         sb.append(getExpirationDate());
456         sb.append("]]></column-value></column>");
457         sb.append(
458             "<column><column-name>lastVoteDate</column-name><column-value><![CDATA[");
459         sb.append(getLastVoteDate());
460         sb.append("]]></column-value></column>");
461 
462         sb.append("</model>");
463 
464         return sb.toString();
465     }
466 
467     private String _uuid;
468     private String _originalUuid;
469     private long _questionId;
470     private long _groupId;
471     private long _originalGroupId;
472     private boolean _setOriginalGroupId;
473     private long _companyId;
474     private long _userId;
475     private String _userUuid;
476     private String _userName;
477     private Date _createDate;
478     private Date _modifiedDate;
479     private String _title;
480     private String _description;
481     private Date _expirationDate;
482     private Date _lastVoteDate;
483     private transient ExpandoBridge _expandoBridge;
484 }