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