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