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