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.portlet.journal.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.model.impl.BaseModelImpl;
26  
27  import com.liferay.portlet.journal.model.JournalArticleResource;
28  import com.liferay.portlet.journal.model.JournalArticleResourceSoap;
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.List;
38  
39  /**
40   * <a href="JournalArticleResourceModelImpl.java.html"><b><i>View Source</i></b></a>
41   *
42   * <p>
43   * ServiceBuilder generated this class. Modifications in this class will be
44   * overwritten the next time is generated.
45   * </p>
46   *
47   * <p>
48   * This class is a model that represents the <code>JournalArticleResource</code> table
49   * in the database.
50   * </p>
51   *
52   * @author Brian Wing Shun Chan
53   *
54   * @see com.liferay.portlet.journal.model.JournalArticleResource
55   * @see com.liferay.portlet.journal.model.JournalArticleResourceModel
56   * @see com.liferay.portlet.journal.model.impl.JournalArticleResourceImpl
57   *
58   */
59  public class JournalArticleResourceModelImpl extends BaseModelImpl {
60      public static final String TABLE_NAME = "JournalArticleResource";
61      public static final Object[][] TABLE_COLUMNS = {
62              { "resourcePrimKey", new Integer(Types.BIGINT) },
63              
64  
65              { "groupId", new Integer(Types.BIGINT) },
66              
67  
68              { "articleId", new Integer(Types.VARCHAR) }
69          };
70      public static final String TABLE_SQL_CREATE = "create table JournalArticleResource (resourcePrimKey LONG not null primary key,groupId LONG,articleId VARCHAR(75) null)";
71      public static final String TABLE_SQL_DROP = "drop table JournalArticleResource";
72      public static final String DATA_SOURCE = "liferayDataSource";
73      public static final String SESSION_FACTORY = "liferaySessionFactory";
74      public static final String TX_MANAGER = "liferayTransactionManager";
75      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
76                  "value.object.finder.cache.enabled.com.liferay.portlet.journal.model.JournalArticleResource"),
77              true);
78  
79      public static JournalArticleResource toModel(
80          JournalArticleResourceSoap soapModel) {
81          JournalArticleResource model = new JournalArticleResourceImpl();
82  
83          model.setResourcePrimKey(soapModel.getResourcePrimKey());
84          model.setGroupId(soapModel.getGroupId());
85          model.setArticleId(soapModel.getArticleId());
86  
87          return model;
88      }
89  
90      public static List<JournalArticleResource> toModels(
91          JournalArticleResourceSoap[] soapModels) {
92          List<JournalArticleResource> models = new ArrayList<JournalArticleResource>(soapModels.length);
93  
94          for (JournalArticleResourceSoap soapModel : soapModels) {
95              models.add(toModel(soapModel));
96          }
97  
98          return models;
99      }
100 
101     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
102                 "lock.expiration.time.com.liferay.portlet.journal.model.JournalArticleResource"));
103 
104     public JournalArticleResourceModelImpl() {
105     }
106 
107     public long getPrimaryKey() {
108         return _resourcePrimKey;
109     }
110 
111     public void setPrimaryKey(long pk) {
112         setResourcePrimKey(pk);
113     }
114 
115     public Serializable getPrimaryKeyObj() {
116         return new Long(_resourcePrimKey);
117     }
118 
119     public long getResourcePrimKey() {
120         return _resourcePrimKey;
121     }
122 
123     public void setResourcePrimKey(long resourcePrimKey) {
124         if (resourcePrimKey != _resourcePrimKey) {
125             _resourcePrimKey = resourcePrimKey;
126         }
127     }
128 
129     public long getGroupId() {
130         return _groupId;
131     }
132 
133     public void setGroupId(long groupId) {
134         if (groupId != _groupId) {
135             _groupId = groupId;
136         }
137     }
138 
139     public String getArticleId() {
140         return GetterUtil.getString(_articleId);
141     }
142 
143     public void setArticleId(String articleId) {
144         if (((articleId == null) && (_articleId != null)) ||
145                 ((articleId != null) && (_articleId == null)) ||
146                 ((articleId != null) && (_articleId != null) &&
147                 !articleId.equals(_articleId))) {
148             _articleId = articleId;
149         }
150     }
151 
152     public JournalArticleResource toEscapedModel() {
153         if (isEscapedModel()) {
154             return (JournalArticleResource)this;
155         }
156         else {
157             JournalArticleResource model = new JournalArticleResourceImpl();
158 
159             model.setNew(isNew());
160             model.setEscapedModel(true);
161 
162             model.setResourcePrimKey(getResourcePrimKey());
163             model.setGroupId(getGroupId());
164             model.setArticleId(HtmlUtil.escape(getArticleId()));
165 
166             model = (JournalArticleResource)Proxy.newProxyInstance(JournalArticleResource.class.getClassLoader(),
167                     new Class[] { JournalArticleResource.class },
168                     new ReadOnlyBeanHandler(model));
169 
170             return model;
171         }
172     }
173 
174     public Object clone() {
175         JournalArticleResourceImpl clone = new JournalArticleResourceImpl();
176 
177         clone.setResourcePrimKey(getResourcePrimKey());
178         clone.setGroupId(getGroupId());
179         clone.setArticleId(getArticleId());
180 
181         return clone;
182     }
183 
184     public int compareTo(Object obj) {
185         if (obj == null) {
186             return -1;
187         }
188 
189         JournalArticleResourceImpl journalArticleResource = (JournalArticleResourceImpl)obj;
190 
191         long pk = journalArticleResource.getPrimaryKey();
192 
193         if (getPrimaryKey() < pk) {
194             return -1;
195         }
196         else if (getPrimaryKey() > pk) {
197             return 1;
198         }
199         else {
200             return 0;
201         }
202     }
203 
204     public boolean equals(Object obj) {
205         if (obj == null) {
206             return false;
207         }
208 
209         JournalArticleResourceImpl journalArticleResource = null;
210 
211         try {
212             journalArticleResource = (JournalArticleResourceImpl)obj;
213         }
214         catch (ClassCastException cce) {
215             return false;
216         }
217 
218         long pk = journalArticleResource.getPrimaryKey();
219 
220         if (getPrimaryKey() == pk) {
221             return true;
222         }
223         else {
224             return false;
225         }
226     }
227 
228     public int hashCode() {
229         return (int)getPrimaryKey();
230     }
231 
232     private long _resourcePrimKey;
233     private long _groupId;
234     private String _articleId;
235 }