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.kernel.util.HtmlUtil;
28  import com.liferay.portal.model.impl.BaseModelImpl;
29  import com.liferay.portal.util.PropsUtil;
30  
31  import com.liferay.portlet.journal.model.JournalArticleResource;
32  import com.liferay.portlet.journal.model.JournalArticleResourceSoap;
33  
34  import java.io.Serializable;
35  
36  import java.lang.reflect.Proxy;
37  
38  import java.sql.Types;
39  
40  import java.util.ArrayList;
41  import java.util.List;
42  
43  /**
44   * <a href="JournalArticleResourceModelImpl.java.html"><b><i>View Source</i></b></a>
45   *
46   * <p>
47   * ServiceBuilder generated this class. Modifications in this class will be
48   * overwritten the next time is generated.
49   * </p>
50   *
51   * <p>
52   * This class is a model that represents the <code>JournalArticleResource</code> table
53   * in the database.
54   * </p>
55   *
56   * @author Brian Wing Shun Chan
57   *
58   * @see com.liferay.portlet.journal.service.model.JournalArticleResource
59   * @see com.liferay.portlet.journal.service.model.JournalArticleResourceModel
60   * @see com.liferay.portlet.journal.service.model.impl.JournalArticleResourceImpl
61   *
62   */
63  public class JournalArticleResourceModelImpl extends BaseModelImpl {
64      public static final String TABLE_NAME = "JournalArticleResource";
65      public static final Object[][] TABLE_COLUMNS = {
66              { "resourcePrimKey", new Integer(Types.BIGINT) },
67              
68  
69              { "groupId", new Integer(Types.BIGINT) },
70              
71  
72              { "articleId", new Integer(Types.VARCHAR) }
73          };
74      public static final String TABLE_SQL_CREATE = "create table JournalArticleResource (resourcePrimKey LONG not null primary key,groupId LONG,articleId VARCHAR(75) null)";
75      public static final String TABLE_SQL_DROP = "drop table JournalArticleResource";
76      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
77                  "value.object.finder.cache.enabled.com.liferay.portlet.journal.model.JournalArticleResource"),
78              true);
79  
80      public static JournalArticleResource toModel(
81          JournalArticleResourceSoap soapModel) {
82          JournalArticleResource model = new JournalArticleResourceImpl();
83  
84          model.setResourcePrimKey(soapModel.getResourcePrimKey());
85          model.setGroupId(soapModel.getGroupId());
86          model.setArticleId(soapModel.getArticleId());
87  
88          return model;
89      }
90  
91      public static List<JournalArticleResource> toModels(
92          JournalArticleResourceSoap[] soapModels) {
93          List<JournalArticleResource> models = new ArrayList<JournalArticleResource>(soapModels.length);
94  
95          for (JournalArticleResourceSoap soapModel : soapModels) {
96              models.add(toModel(soapModel));
97          }
98  
99          return models;
100     }
101 
102     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
103                 "lock.expiration.time.com.liferay.portlet.journal.model.JournalArticleResource"));
104 
105     public JournalArticleResourceModelImpl() {
106     }
107 
108     public long getPrimaryKey() {
109         return _resourcePrimKey;
110     }
111 
112     public void setPrimaryKey(long pk) {
113         setResourcePrimKey(pk);
114     }
115 
116     public Serializable getPrimaryKeyObj() {
117         return new Long(_resourcePrimKey);
118     }
119 
120     public long getResourcePrimKey() {
121         return _resourcePrimKey;
122     }
123 
124     public void setResourcePrimKey(long resourcePrimKey) {
125         if (resourcePrimKey != _resourcePrimKey) {
126             _resourcePrimKey = resourcePrimKey;
127         }
128     }
129 
130     public long getGroupId() {
131         return _groupId;
132     }
133 
134     public void setGroupId(long groupId) {
135         if (groupId != _groupId) {
136             _groupId = groupId;
137         }
138     }
139 
140     public String getArticleId() {
141         return GetterUtil.getString(_articleId);
142     }
143 
144     public void setArticleId(String articleId) {
145         if (((articleId == null) && (_articleId != null)) ||
146                 ((articleId != null) && (_articleId == null)) ||
147                 ((articleId != null) && (_articleId != null) &&
148                 !articleId.equals(_articleId))) {
149             _articleId = articleId;
150         }
151     }
152 
153     public JournalArticleResource toEscapedModel() {
154         if (isEscapedModel()) {
155             return (JournalArticleResource)this;
156         }
157         else {
158             JournalArticleResource model = new JournalArticleResourceImpl();
159 
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 }