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.portlet.journal.model.impl;
24  
25  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.GetterUtil;
27  import com.liferay.portal.model.impl.BaseModelImpl;
28  import com.liferay.portal.util.PropsUtil;
29  
30  import com.liferay.portlet.journal.model.JournalArticleResource;
31  
32  import com.liferay.util.Html;
33  
34  import java.io.Serializable;
35  
36  import java.lang.reflect.Proxy;
37  
38  import java.sql.Types;
39  
40  /**
41   * <a href="JournalArticleResourceModelImpl.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>JournalArticleResource</code> table
50   * in the database.
51   * </p>
52   *
53   * @author Brian Wing Shun Chan
54   *
55   * @see com.liferay.portlet.journal.service.model.JournalArticleResource
56   * @see com.liferay.portlet.journal.service.model.JournalArticleResourceModel
57   * @see com.liferay.portlet.journal.service.model.impl.JournalArticleResourceImpl
58   *
59   */
60  public class JournalArticleResourceModelImpl extends BaseModelImpl {
61      public static final String TABLE_NAME = "JournalArticleResource";
62      public static final Object[][] TABLE_COLUMNS = {
63              { "resourcePrimKey", new Integer(Types.BIGINT) },
64              
65  
66              { "groupId", new Integer(Types.BIGINT) },
67              
68  
69              { "articleId", new Integer(Types.VARCHAR) }
70          };
71      public static final String TABLE_SQL_CREATE = "create table JournalArticleResource (resourcePrimKey LONG not null primary key,groupId LONG,articleId VARCHAR(75) null)";
72      public static final String TABLE_SQL_DROP = "drop table JournalArticleResource";
73      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
74                  "value.object.finder.cache.enabled.com.liferay.portlet.journal.model.JournalArticleResource"),
75              true);
76      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
77                  "lock.expiration.time.com.liferay.portlet.journal.model.JournalArticleResource"));
78  
79      public JournalArticleResourceModelImpl() {
80      }
81  
82      public long getPrimaryKey() {
83          return _resourcePrimKey;
84      }
85  
86      public void setPrimaryKey(long pk) {
87          setResourcePrimKey(pk);
88      }
89  
90      public Serializable getPrimaryKeyObj() {
91          return new Long(_resourcePrimKey);
92      }
93  
94      public long getResourcePrimKey() {
95          return _resourcePrimKey;
96      }
97  
98      public void setResourcePrimKey(long resourcePrimKey) {
99          if (resourcePrimKey != _resourcePrimKey) {
100             _resourcePrimKey = resourcePrimKey;
101         }
102     }
103 
104     public long getGroupId() {
105         return _groupId;
106     }
107 
108     public void setGroupId(long groupId) {
109         if (groupId != _groupId) {
110             _groupId = groupId;
111         }
112     }
113 
114     public String getArticleId() {
115         return GetterUtil.getString(_articleId);
116     }
117 
118     public void setArticleId(String articleId) {
119         if (((articleId == null) && (_articleId != null)) ||
120                 ((articleId != null) && (_articleId == null)) ||
121                 ((articleId != null) && (_articleId != null) &&
122                 !articleId.equals(_articleId))) {
123             _articleId = articleId;
124         }
125     }
126 
127     public JournalArticleResource toEscapedModel() {
128         if (isEscapedModel()) {
129             return (JournalArticleResource)this;
130         }
131         else {
132             JournalArticleResource model = new JournalArticleResourceImpl();
133 
134             model.setEscapedModel(true);
135 
136             model.setResourcePrimKey(getResourcePrimKey());
137             model.setGroupId(getGroupId());
138             model.setArticleId(Html.escape(getArticleId()));
139 
140             model = (JournalArticleResource)Proxy.newProxyInstance(JournalArticleResource.class.getClassLoader(),
141                     new Class[] { JournalArticleResource.class },
142                     new ReadOnlyBeanHandler(model));
143 
144             return model;
145         }
146     }
147 
148     public Object clone() {
149         JournalArticleResourceImpl clone = new JournalArticleResourceImpl();
150 
151         clone.setResourcePrimKey(getResourcePrimKey());
152         clone.setGroupId(getGroupId());
153         clone.setArticleId(getArticleId());
154 
155         return clone;
156     }
157 
158     public int compareTo(Object obj) {
159         if (obj == null) {
160             return -1;
161         }
162 
163         JournalArticleResourceImpl journalArticleResource = (JournalArticleResourceImpl)obj;
164 
165         long pk = journalArticleResource.getPrimaryKey();
166 
167         if (getPrimaryKey() < pk) {
168             return -1;
169         }
170         else if (getPrimaryKey() > pk) {
171             return 1;
172         }
173         else {
174             return 0;
175         }
176     }
177 
178     public boolean equals(Object obj) {
179         if (obj == null) {
180             return false;
181         }
182 
183         JournalArticleResourceImpl journalArticleResource = null;
184 
185         try {
186             journalArticleResource = (JournalArticleResourceImpl)obj;
187         }
188         catch (ClassCastException cce) {
189             return false;
190         }
191 
192         long pk = journalArticleResource.getPrimaryKey();
193 
194         if (getPrimaryKey() == pk) {
195             return true;
196         }
197         else {
198             return false;
199         }
200     }
201 
202     public int hashCode() {
203         return (int)getPrimaryKey();
204     }
205 
206     private long _resourcePrimKey;
207     private long _groupId;
208     private String _articleId;
209 }