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.portal.model.impl;
16  
17  import com.liferay.portal.SystemException;
18  import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
19  import com.liferay.portal.kernel.util.GetterUtil;
20  import com.liferay.portal.kernel.util.StringBundler;
21  import com.liferay.portal.kernel.util.StringPool;
22  import com.liferay.portal.model.Subscription;
23  import com.liferay.portal.model.SubscriptionSoap;
24  import com.liferay.portal.service.ServiceContext;
25  import com.liferay.portal.util.PortalUtil;
26  
27  import com.liferay.portlet.expando.model.ExpandoBridge;
28  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
29  
30  import java.io.Serializable;
31  
32  import java.lang.reflect.Proxy;
33  
34  import java.sql.Types;
35  
36  import java.util.ArrayList;
37  import java.util.Date;
38  import java.util.List;
39  
40  /**
41   * <a href="SubscriptionModelImpl.java.html"><b><i>View Source</i></b></a>
42   *
43   * <p>
44   * ServiceBuilder generated this class. Modifications in this class will be
45   * overwritten the next time is generated.
46   * </p>
47   *
48   * <p>
49   * This interface is a model that represents the Subscription table in the
50   * database.
51   * </p>
52   *
53   * @author    Brian Wing Shun Chan
54   * @see       SubscriptionImpl
55   * @see       com.liferay.portal.model.Subscription
56   * @see       com.liferay.portal.model.SubscriptionModel
57   * @generated
58   */
59  public class SubscriptionModelImpl extends BaseModelImpl<Subscription> {
60      public static final String TABLE_NAME = "Subscription";
61      public static final Object[][] TABLE_COLUMNS = {
62              { "subscriptionId", new Integer(Types.BIGINT) },
63              { "companyId", new Integer(Types.BIGINT) },
64              { "userId", new Integer(Types.BIGINT) },
65              { "userName", new Integer(Types.VARCHAR) },
66              { "createDate", new Integer(Types.TIMESTAMP) },
67              { "modifiedDate", new Integer(Types.TIMESTAMP) },
68              { "classNameId", new Integer(Types.BIGINT) },
69              { "classPK", new Integer(Types.BIGINT) },
70              { "frequency", new Integer(Types.VARCHAR) }
71          };
72      public static final String TABLE_SQL_CREATE = "create table Subscription (subscriptionId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,classNameId LONG,classPK LONG,frequency VARCHAR(75) null)";
73      public static final String TABLE_SQL_DROP = "drop table Subscription";
74      public static final String DATA_SOURCE = "liferayDataSource";
75      public static final String SESSION_FACTORY = "liferaySessionFactory";
76      public static final String TX_MANAGER = "liferayTransactionManager";
77      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
78                  "value.object.entity.cache.enabled.com.liferay.portal.model.Subscription"),
79              true);
80      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
81                  "value.object.finder.cache.enabled.com.liferay.portal.model.Subscription"),
82              true);
83  
84      public static Subscription toModel(SubscriptionSoap soapModel) {
85          Subscription model = new SubscriptionImpl();
86  
87          model.setSubscriptionId(soapModel.getSubscriptionId());
88          model.setCompanyId(soapModel.getCompanyId());
89          model.setUserId(soapModel.getUserId());
90          model.setUserName(soapModel.getUserName());
91          model.setCreateDate(soapModel.getCreateDate());
92          model.setModifiedDate(soapModel.getModifiedDate());
93          model.setClassNameId(soapModel.getClassNameId());
94          model.setClassPK(soapModel.getClassPK());
95          model.setFrequency(soapModel.getFrequency());
96  
97          return model;
98      }
99  
100     public static List<Subscription> toModels(SubscriptionSoap[] soapModels) {
101         List<Subscription> models = new ArrayList<Subscription>(soapModels.length);
102 
103         for (SubscriptionSoap 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.portal.model.Subscription"));
112 
113     public SubscriptionModelImpl() {
114     }
115 
116     public long getPrimaryKey() {
117         return _subscriptionId;
118     }
119 
120     public void setPrimaryKey(long pk) {
121         setSubscriptionId(pk);
122     }
123 
124     public Serializable getPrimaryKeyObj() {
125         return new Long(_subscriptionId);
126     }
127 
128     public long getSubscriptionId() {
129         return _subscriptionId;
130     }
131 
132     public void setSubscriptionId(long subscriptionId) {
133         _subscriptionId = subscriptionId;
134     }
135 
136     public long getCompanyId() {
137         return _companyId;
138     }
139 
140     public void setCompanyId(long companyId) {
141         _companyId = companyId;
142 
143         if (!_setOriginalCompanyId) {
144             _setOriginalCompanyId = true;
145 
146             _originalCompanyId = companyId;
147         }
148     }
149 
150     public long getOriginalCompanyId() {
151         return _originalCompanyId;
152     }
153 
154     public long getUserId() {
155         return _userId;
156     }
157 
158     public void setUserId(long userId) {
159         _userId = userId;
160 
161         if (!_setOriginalUserId) {
162             _setOriginalUserId = true;
163 
164             _originalUserId = userId;
165         }
166     }
167 
168     public String getUserUuid() throws SystemException {
169         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
170     }
171 
172     public void setUserUuid(String userUuid) {
173         _userUuid = userUuid;
174     }
175 
176     public long getOriginalUserId() {
177         return _originalUserId;
178     }
179 
180     public String getUserName() {
181         if (_userName == null) {
182             return StringPool.BLANK;
183         }
184         else {
185             return _userName;
186         }
187     }
188 
189     public void setUserName(String userName) {
190         _userName = userName;
191     }
192 
193     public Date getCreateDate() {
194         return _createDate;
195     }
196 
197     public void setCreateDate(Date createDate) {
198         _createDate = createDate;
199     }
200 
201     public Date getModifiedDate() {
202         return _modifiedDate;
203     }
204 
205     public void setModifiedDate(Date modifiedDate) {
206         _modifiedDate = modifiedDate;
207     }
208 
209     public String getClassName() {
210         if (getClassNameId() <= 0) {
211             return StringPool.BLANK;
212         }
213 
214         return PortalUtil.getClassName(getClassNameId());
215     }
216 
217     public long getClassNameId() {
218         return _classNameId;
219     }
220 
221     public void setClassNameId(long classNameId) {
222         _classNameId = classNameId;
223 
224         if (!_setOriginalClassNameId) {
225             _setOriginalClassNameId = true;
226 
227             _originalClassNameId = classNameId;
228         }
229     }
230 
231     public long getOriginalClassNameId() {
232         return _originalClassNameId;
233     }
234 
235     public long getClassPK() {
236         return _classPK;
237     }
238 
239     public void setClassPK(long classPK) {
240         _classPK = classPK;
241 
242         if (!_setOriginalClassPK) {
243             _setOriginalClassPK = true;
244 
245             _originalClassPK = classPK;
246         }
247     }
248 
249     public long getOriginalClassPK() {
250         return _originalClassPK;
251     }
252 
253     public String getFrequency() {
254         if (_frequency == null) {
255             return StringPool.BLANK;
256         }
257         else {
258             return _frequency;
259         }
260     }
261 
262     public void setFrequency(String frequency) {
263         _frequency = frequency;
264     }
265 
266     public Subscription toEscapedModel() {
267         if (isEscapedModel()) {
268             return (Subscription)this;
269         }
270         else {
271             return (Subscription)Proxy.newProxyInstance(Subscription.class.getClassLoader(),
272                 new Class[] { Subscription.class },
273                 new AutoEscapeBeanHandler(this));
274         }
275     }
276 
277     public ExpandoBridge getExpandoBridge() {
278         if (_expandoBridge == null) {
279             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(Subscription.class.getName(),
280                     getPrimaryKey());
281         }
282 
283         return _expandoBridge;
284     }
285 
286     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
287         getExpandoBridge().setAttributes(serviceContext);
288     }
289 
290     public Object clone() {
291         SubscriptionImpl clone = new SubscriptionImpl();
292 
293         clone.setSubscriptionId(getSubscriptionId());
294         clone.setCompanyId(getCompanyId());
295         clone.setUserId(getUserId());
296         clone.setUserName(getUserName());
297         clone.setCreateDate(getCreateDate());
298         clone.setModifiedDate(getModifiedDate());
299         clone.setClassNameId(getClassNameId());
300         clone.setClassPK(getClassPK());
301         clone.setFrequency(getFrequency());
302 
303         return clone;
304     }
305 
306     public int compareTo(Subscription subscription) {
307         long pk = subscription.getPrimaryKey();
308 
309         if (getPrimaryKey() < pk) {
310             return -1;
311         }
312         else if (getPrimaryKey() > pk) {
313             return 1;
314         }
315         else {
316             return 0;
317         }
318     }
319 
320     public boolean equals(Object obj) {
321         if (obj == null) {
322             return false;
323         }
324 
325         Subscription subscription = null;
326 
327         try {
328             subscription = (Subscription)obj;
329         }
330         catch (ClassCastException cce) {
331             return false;
332         }
333 
334         long pk = subscription.getPrimaryKey();
335 
336         if (getPrimaryKey() == pk) {
337             return true;
338         }
339         else {
340             return false;
341         }
342     }
343 
344     public int hashCode() {
345         return (int)getPrimaryKey();
346     }
347 
348     public String toString() {
349         StringBundler sb = new StringBundler(19);
350 
351         sb.append("{subscriptionId=");
352         sb.append(getSubscriptionId());
353         sb.append(", companyId=");
354         sb.append(getCompanyId());
355         sb.append(", userId=");
356         sb.append(getUserId());
357         sb.append(", userName=");
358         sb.append(getUserName());
359         sb.append(", createDate=");
360         sb.append(getCreateDate());
361         sb.append(", modifiedDate=");
362         sb.append(getModifiedDate());
363         sb.append(", classNameId=");
364         sb.append(getClassNameId());
365         sb.append(", classPK=");
366         sb.append(getClassPK());
367         sb.append(", frequency=");
368         sb.append(getFrequency());
369         sb.append("}");
370 
371         return sb.toString();
372     }
373 
374     public String toXmlString() {
375         StringBundler sb = new StringBundler(31);
376 
377         sb.append("<model><model-name>");
378         sb.append("com.liferay.portal.model.Subscription");
379         sb.append("</model-name>");
380 
381         sb.append(
382             "<column><column-name>subscriptionId</column-name><column-value><![CDATA[");
383         sb.append(getSubscriptionId());
384         sb.append("]]></column-value></column>");
385         sb.append(
386             "<column><column-name>companyId</column-name><column-value><![CDATA[");
387         sb.append(getCompanyId());
388         sb.append("]]></column-value></column>");
389         sb.append(
390             "<column><column-name>userId</column-name><column-value><![CDATA[");
391         sb.append(getUserId());
392         sb.append("]]></column-value></column>");
393         sb.append(
394             "<column><column-name>userName</column-name><column-value><![CDATA[");
395         sb.append(getUserName());
396         sb.append("]]></column-value></column>");
397         sb.append(
398             "<column><column-name>createDate</column-name><column-value><![CDATA[");
399         sb.append(getCreateDate());
400         sb.append("]]></column-value></column>");
401         sb.append(
402             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
403         sb.append(getModifiedDate());
404         sb.append("]]></column-value></column>");
405         sb.append(
406             "<column><column-name>classNameId</column-name><column-value><![CDATA[");
407         sb.append(getClassNameId());
408         sb.append("]]></column-value></column>");
409         sb.append(
410             "<column><column-name>classPK</column-name><column-value><![CDATA[");
411         sb.append(getClassPK());
412         sb.append("]]></column-value></column>");
413         sb.append(
414             "<column><column-name>frequency</column-name><column-value><![CDATA[");
415         sb.append(getFrequency());
416         sb.append("]]></column-value></column>");
417 
418         sb.append("</model>");
419 
420         return sb.toString();
421     }
422 
423     private long _subscriptionId;
424     private long _companyId;
425     private long _originalCompanyId;
426     private boolean _setOriginalCompanyId;
427     private long _userId;
428     private String _userUuid;
429     private long _originalUserId;
430     private boolean _setOriginalUserId;
431     private String _userName;
432     private Date _createDate;
433     private Date _modifiedDate;
434     private long _classNameId;
435     private long _originalClassNameId;
436     private boolean _setOriginalClassNameId;
437     private long _classPK;
438     private long _originalClassPK;
439     private boolean _setOriginalClassPK;
440     private String _frequency;
441     private transient ExpandoBridge _expandoBridge;
442 }