1   /**
2    * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions 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.kernel.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.GetterUtil;
27  import com.liferay.portal.kernel.util.HtmlUtil;
28  import com.liferay.portal.kernel.util.StringPool;
29  import com.liferay.portal.model.Subscription;
30  import com.liferay.portal.model.SubscriptionSoap;
31  import com.liferay.portal.util.PortalUtil;
32  
33  import java.io.Serializable;
34  
35  import java.lang.reflect.Proxy;
36  
37  import java.sql.Types;
38  
39  import java.util.ArrayList;
40  import java.util.Date;
41  import java.util.List;
42  
43  /**
44   * <a href="SubscriptionModelImpl.java.html"><b><i>View Source</i></b></a>
45   *
46   * <p>
47   * ServiceBuilder generated this class. Modifications in this class will be
48   * overwritten the next time is generated.
49   * </p>
50   *
51   * <p>
52   * This class is a model that represents the <code>Subscription</code> table
53   * in the database.
54   * </p>
55   *
56   * @author Brian Wing Shun Chan
57   *
58   * @see com.liferay.portal.model.Subscription
59   * @see com.liferay.portal.model.SubscriptionModel
60   * @see com.liferay.portal.model.impl.SubscriptionImpl
61   *
62   */
63  public class SubscriptionModelImpl extends BaseModelImpl {
64      public static final String TABLE_NAME = "Subscription";
65      public static final Object[][] TABLE_COLUMNS = {
66              { "subscriptionId", new Integer(Types.BIGINT) },
67              
68  
69              { "companyId", new Integer(Types.BIGINT) },
70              
71  
72              { "userId", new Integer(Types.BIGINT) },
73              
74  
75              { "userName", new Integer(Types.VARCHAR) },
76              
77  
78              { "createDate", new Integer(Types.TIMESTAMP) },
79              
80  
81              { "modifiedDate", new Integer(Types.TIMESTAMP) },
82              
83  
84              { "classNameId", new Integer(Types.BIGINT) },
85              
86  
87              { "classPK", new Integer(Types.BIGINT) },
88              
89  
90              { "frequency", new Integer(Types.VARCHAR) }
91          };
92      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)";
93      public static final String TABLE_SQL_DROP = "drop table Subscription";
94      public static final String DATA_SOURCE = "liferayDataSource";
95      public static final String SESSION_FACTORY = "liferaySessionFactory";
96      public static final String TX_MANAGER = "liferayTransactionManager";
97      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
98                  "value.object.finder.cache.enabled.com.liferay.portal.model.Subscription"),
99              true);
100 
101     public static Subscription toModel(SubscriptionSoap soapModel) {
102         Subscription model = new SubscriptionImpl();
103 
104         model.setSubscriptionId(soapModel.getSubscriptionId());
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.setClassNameId(soapModel.getClassNameId());
111         model.setClassPK(soapModel.getClassPK());
112         model.setFrequency(soapModel.getFrequency());
113 
114         return model;
115     }
116 
117     public static List<Subscription> toModels(SubscriptionSoap[] soapModels) {
118         List<Subscription> models = new ArrayList<Subscription>(soapModels.length);
119 
120         for (SubscriptionSoap soapModel : soapModels) {
121             models.add(toModel(soapModel));
122         }
123 
124         return models;
125     }
126 
127     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
128                 "lock.expiration.time.com.liferay.portal.model.Subscription"));
129 
130     public SubscriptionModelImpl() {
131     }
132 
133     public long getPrimaryKey() {
134         return _subscriptionId;
135     }
136 
137     public void setPrimaryKey(long pk) {
138         setSubscriptionId(pk);
139     }
140 
141     public Serializable getPrimaryKeyObj() {
142         return new Long(_subscriptionId);
143     }
144 
145     public long getSubscriptionId() {
146         return _subscriptionId;
147     }
148 
149     public void setSubscriptionId(long subscriptionId) {
150         if (subscriptionId != _subscriptionId) {
151             _subscriptionId = subscriptionId;
152         }
153     }
154 
155     public long getCompanyId() {
156         return _companyId;
157     }
158 
159     public void setCompanyId(long companyId) {
160         if (companyId != _companyId) {
161             _companyId = companyId;
162         }
163     }
164 
165     public long getUserId() {
166         return _userId;
167     }
168 
169     public void setUserId(long userId) {
170         if (userId != _userId) {
171             _userId = userId;
172         }
173     }
174 
175     public String getUserName() {
176         return GetterUtil.getString(_userName);
177     }
178 
179     public void setUserName(String userName) {
180         if (((userName == null) && (_userName != null)) ||
181                 ((userName != null) && (_userName == null)) ||
182                 ((userName != null) && (_userName != null) &&
183                 !userName.equals(_userName))) {
184             _userName = userName;
185         }
186     }
187 
188     public Date getCreateDate() {
189         return _createDate;
190     }
191 
192     public void setCreateDate(Date createDate) {
193         if (((createDate == null) && (_createDate != null)) ||
194                 ((createDate != null) && (_createDate == null)) ||
195                 ((createDate != null) && (_createDate != null) &&
196                 !createDate.equals(_createDate))) {
197             _createDate = createDate;
198         }
199     }
200 
201     public Date getModifiedDate() {
202         return _modifiedDate;
203     }
204 
205     public void setModifiedDate(Date modifiedDate) {
206         if (((modifiedDate == null) && (_modifiedDate != null)) ||
207                 ((modifiedDate != null) && (_modifiedDate == null)) ||
208                 ((modifiedDate != null) && (_modifiedDate != null) &&
209                 !modifiedDate.equals(_modifiedDate))) {
210             _modifiedDate = modifiedDate;
211         }
212     }
213 
214     public String getClassName() {
215         if (getClassNameId() <= 0) {
216             return StringPool.BLANK;
217         }
218 
219         return PortalUtil.getClassName(getClassNameId());
220     }
221 
222     public long getClassNameId() {
223         return _classNameId;
224     }
225 
226     public void setClassNameId(long classNameId) {
227         if (classNameId != _classNameId) {
228             _classNameId = classNameId;
229         }
230     }
231 
232     public long getClassPK() {
233         return _classPK;
234     }
235 
236     public void setClassPK(long classPK) {
237         if (classPK != _classPK) {
238             _classPK = classPK;
239         }
240     }
241 
242     public String getFrequency() {
243         return GetterUtil.getString(_frequency);
244     }
245 
246     public void setFrequency(String frequency) {
247         if (((frequency == null) && (_frequency != null)) ||
248                 ((frequency != null) && (_frequency == null)) ||
249                 ((frequency != null) && (_frequency != null) &&
250                 !frequency.equals(_frequency))) {
251             _frequency = frequency;
252         }
253     }
254 
255     public Subscription toEscapedModel() {
256         if (isEscapedModel()) {
257             return (Subscription)this;
258         }
259         else {
260             Subscription model = new SubscriptionImpl();
261 
262             model.setNew(isNew());
263             model.setEscapedModel(true);
264 
265             model.setSubscriptionId(getSubscriptionId());
266             model.setCompanyId(getCompanyId());
267             model.setUserId(getUserId());
268             model.setUserName(HtmlUtil.escape(getUserName()));
269             model.setCreateDate(getCreateDate());
270             model.setModifiedDate(getModifiedDate());
271             model.setClassNameId(getClassNameId());
272             model.setClassPK(getClassPK());
273             model.setFrequency(HtmlUtil.escape(getFrequency()));
274 
275             model = (Subscription)Proxy.newProxyInstance(Subscription.class.getClassLoader(),
276                     new Class[] { Subscription.class },
277                     new ReadOnlyBeanHandler(model));
278 
279             return model;
280         }
281     }
282 
283     public Object clone() {
284         SubscriptionImpl clone = new SubscriptionImpl();
285 
286         clone.setSubscriptionId(getSubscriptionId());
287         clone.setCompanyId(getCompanyId());
288         clone.setUserId(getUserId());
289         clone.setUserName(getUserName());
290         clone.setCreateDate(getCreateDate());
291         clone.setModifiedDate(getModifiedDate());
292         clone.setClassNameId(getClassNameId());
293         clone.setClassPK(getClassPK());
294         clone.setFrequency(getFrequency());
295 
296         return clone;
297     }
298 
299     public int compareTo(Object obj) {
300         if (obj == null) {
301             return -1;
302         }
303 
304         SubscriptionImpl subscription = (SubscriptionImpl)obj;
305 
306         long pk = subscription.getPrimaryKey();
307 
308         if (getPrimaryKey() < pk) {
309             return -1;
310         }
311         else if (getPrimaryKey() > pk) {
312             return 1;
313         }
314         else {
315             return 0;
316         }
317     }
318 
319     public boolean equals(Object obj) {
320         if (obj == null) {
321             return false;
322         }
323 
324         SubscriptionImpl subscription = null;
325 
326         try {
327             subscription = (SubscriptionImpl)obj;
328         }
329         catch (ClassCastException cce) {
330             return false;
331         }
332 
333         long pk = subscription.getPrimaryKey();
334 
335         if (getPrimaryKey() == pk) {
336             return true;
337         }
338         else {
339             return false;
340         }
341     }
342 
343     public int hashCode() {
344         return (int)getPrimaryKey();
345     }
346 
347     private long _subscriptionId;
348     private long _companyId;
349     private long _userId;
350     private String _userName;
351     private Date _createDate;
352     private Date _modifiedDate;
353     private long _classNameId;
354     private long _classPK;
355     private String _frequency;
356 }