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