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