1   /**
2    * Copyright (c) 2000-2009 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   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portal.model.impl;
21  
22  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23  import com.liferay.portal.kernel.util.GetterUtil;
24  import com.liferay.portal.kernel.util.HtmlUtil;
25  import com.liferay.portal.kernel.util.StringPool;
26  import com.liferay.portal.model.Subscription;
27  import com.liferay.portal.model.SubscriptionSoap;
28  import com.liferay.portal.util.PortalUtil;
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 class is a model that represents the <code>Subscription</code> table
50   * in the database.
51   * </p>
52   *
53   * @author Brian Wing Shun Chan
54   *
55   * @see com.liferay.portal.model.Subscription
56   * @see com.liferay.portal.model.SubscriptionModel
57   * @see com.liferay.portal.model.impl.SubscriptionImpl
58   *
59   */
60  public class SubscriptionModelImpl extends BaseModelImpl {
61      public static final String TABLE_NAME = "Subscription";
62      public static final Object[][] TABLE_COLUMNS = {
63              { "subscriptionId", new Integer(Types.BIGINT) },
64              
65  
66              { "companyId", new Integer(Types.BIGINT) },
67              
68  
69              { "userId", new Integer(Types.BIGINT) },
70              
71  
72              { "userName", new Integer(Types.VARCHAR) },
73              
74  
75              { "createDate", new Integer(Types.TIMESTAMP) },
76              
77  
78              { "modifiedDate", new Integer(Types.TIMESTAMP) },
79              
80  
81              { "classNameId", new Integer(Types.BIGINT) },
82              
83  
84              { "classPK", new Integer(Types.BIGINT) },
85              
86  
87              { "frequency", new Integer(Types.VARCHAR) }
88          };
89      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)";
90      public static final String TABLE_SQL_DROP = "drop table Subscription";
91      public static final String DATA_SOURCE = "liferayDataSource";
92      public static final String SESSION_FACTORY = "liferaySessionFactory";
93      public static final String TX_MANAGER = "liferayTransactionManager";
94      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
95                  "value.object.finder.cache.enabled.com.liferay.portal.model.Subscription"),
96              true);
97  
98      public static Subscription toModel(SubscriptionSoap soapModel) {
99          Subscription model = new SubscriptionImpl();
100 
101         model.setSubscriptionId(soapModel.getSubscriptionId());
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.setClassNameId(soapModel.getClassNameId());
108         model.setClassPK(soapModel.getClassPK());
109         model.setFrequency(soapModel.getFrequency());
110 
111         return model;
112     }
113 
114     public static List<Subscription> toModels(SubscriptionSoap[] soapModels) {
115         List<Subscription> models = new ArrayList<Subscription>(soapModels.length);
116 
117         for (SubscriptionSoap soapModel : soapModels) {
118             models.add(toModel(soapModel));
119         }
120 
121         return models;
122     }
123 
124     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
125                 "lock.expiration.time.com.liferay.portal.model.Subscription"));
126 
127     public SubscriptionModelImpl() {
128     }
129 
130     public long getPrimaryKey() {
131         return _subscriptionId;
132     }
133 
134     public void setPrimaryKey(long pk) {
135         setSubscriptionId(pk);
136     }
137 
138     public Serializable getPrimaryKeyObj() {
139         return new Long(_subscriptionId);
140     }
141 
142     public long getSubscriptionId() {
143         return _subscriptionId;
144     }
145 
146     public void setSubscriptionId(long subscriptionId) {
147         if (subscriptionId != _subscriptionId) {
148             _subscriptionId = subscriptionId;
149         }
150     }
151 
152     public long getCompanyId() {
153         return _companyId;
154     }
155 
156     public void setCompanyId(long companyId) {
157         if (companyId != _companyId) {
158             _companyId = companyId;
159         }
160     }
161 
162     public long getUserId() {
163         return _userId;
164     }
165 
166     public void setUserId(long userId) {
167         if (userId != _userId) {
168             _userId = userId;
169         }
170     }
171 
172     public String getUserName() {
173         return GetterUtil.getString(_userName);
174     }
175 
176     public void setUserName(String userName) {
177         if (((userName == null) && (_userName != null)) ||
178                 ((userName != null) && (_userName == null)) ||
179                 ((userName != null) && (_userName != null) &&
180                 !userName.equals(_userName))) {
181             _userName = userName;
182         }
183     }
184 
185     public Date getCreateDate() {
186         return _createDate;
187     }
188 
189     public void setCreateDate(Date createDate) {
190         if (((createDate == null) && (_createDate != null)) ||
191                 ((createDate != null) && (_createDate == null)) ||
192                 ((createDate != null) && (_createDate != null) &&
193                 !createDate.equals(_createDate))) {
194             _createDate = createDate;
195         }
196     }
197 
198     public Date getModifiedDate() {
199         return _modifiedDate;
200     }
201 
202     public void setModifiedDate(Date modifiedDate) {
203         if (((modifiedDate == null) && (_modifiedDate != null)) ||
204                 ((modifiedDate != null) && (_modifiedDate == null)) ||
205                 ((modifiedDate != null) && (_modifiedDate != null) &&
206                 !modifiedDate.equals(_modifiedDate))) {
207             _modifiedDate = modifiedDate;
208         }
209     }
210 
211     public String getClassName() {
212         if (getClassNameId() <= 0) {
213             return StringPool.BLANK;
214         }
215 
216         return PortalUtil.getClassName(getClassNameId());
217     }
218 
219     public long getClassNameId() {
220         return _classNameId;
221     }
222 
223     public void setClassNameId(long classNameId) {
224         if (classNameId != _classNameId) {
225             _classNameId = classNameId;
226         }
227     }
228 
229     public long getClassPK() {
230         return _classPK;
231     }
232 
233     public void setClassPK(long classPK) {
234         if (classPK != _classPK) {
235             _classPK = classPK;
236         }
237     }
238 
239     public String getFrequency() {
240         return GetterUtil.getString(_frequency);
241     }
242 
243     public void setFrequency(String frequency) {
244         if (((frequency == null) && (_frequency != null)) ||
245                 ((frequency != null) && (_frequency == null)) ||
246                 ((frequency != null) && (_frequency != null) &&
247                 !frequency.equals(_frequency))) {
248             _frequency = frequency;
249         }
250     }
251 
252     public Subscription toEscapedModel() {
253         if (isEscapedModel()) {
254             return (Subscription)this;
255         }
256         else {
257             Subscription model = new SubscriptionImpl();
258 
259             model.setNew(isNew());
260             model.setEscapedModel(true);
261 
262             model.setSubscriptionId(getSubscriptionId());
263             model.setCompanyId(getCompanyId());
264             model.setUserId(getUserId());
265             model.setUserName(HtmlUtil.escape(getUserName()));
266             model.setCreateDate(getCreateDate());
267             model.setModifiedDate(getModifiedDate());
268             model.setClassNameId(getClassNameId());
269             model.setClassPK(getClassPK());
270             model.setFrequency(HtmlUtil.escape(getFrequency()));
271 
272             model = (Subscription)Proxy.newProxyInstance(Subscription.class.getClassLoader(),
273                     new Class[] { Subscription.class },
274                     new ReadOnlyBeanHandler(model));
275 
276             return model;
277         }
278     }
279 
280     public Object clone() {
281         SubscriptionImpl clone = new SubscriptionImpl();
282 
283         clone.setSubscriptionId(getSubscriptionId());
284         clone.setCompanyId(getCompanyId());
285         clone.setUserId(getUserId());
286         clone.setUserName(getUserName());
287         clone.setCreateDate(getCreateDate());
288         clone.setModifiedDate(getModifiedDate());
289         clone.setClassNameId(getClassNameId());
290         clone.setClassPK(getClassPK());
291         clone.setFrequency(getFrequency());
292 
293         return clone;
294     }
295 
296     public int compareTo(Object obj) {
297         if (obj == null) {
298             return -1;
299         }
300 
301         SubscriptionImpl subscription = (SubscriptionImpl)obj;
302 
303         long pk = subscription.getPrimaryKey();
304 
305         if (getPrimaryKey() < pk) {
306             return -1;
307         }
308         else if (getPrimaryKey() > pk) {
309             return 1;
310         }
311         else {
312             return 0;
313         }
314     }
315 
316     public boolean equals(Object obj) {
317         if (obj == null) {
318             return false;
319         }
320 
321         SubscriptionImpl subscription = null;
322 
323         try {
324             subscription = (SubscriptionImpl)obj;
325         }
326         catch (ClassCastException cce) {
327             return false;
328         }
329 
330         long pk = subscription.getPrimaryKey();
331 
332         if (getPrimaryKey() == pk) {
333             return true;
334         }
335         else {
336             return false;
337         }
338     }
339 
340     public int hashCode() {
341         return (int)getPrimaryKey();
342     }
343 
344     private long _subscriptionId;
345     private long _companyId;
346     private long _userId;
347     private String _userName;
348     private Date _createDate;
349     private Date _modifiedDate;
350     private long _classNameId;
351     private long _classPK;
352     private String _frequency;
353 }