1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.journal.model.impl;
16  
17  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
18  import com.liferay.portal.kernel.util.GetterUtil;
19  import com.liferay.portal.kernel.util.HtmlUtil;
20  import com.liferay.portal.kernel.util.StringBundler;
21  import com.liferay.portal.model.impl.BaseModelImpl;
22  import com.liferay.portal.service.ServiceContext;
23  
24  import com.liferay.portlet.expando.model.ExpandoBridge;
25  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
26  import com.liferay.portlet.journal.model.JournalArticleResource;
27  import com.liferay.portlet.journal.model.JournalArticleResourceSoap;
28  
29  import java.io.Serializable;
30  
31  import java.lang.reflect.Proxy;
32  
33  import java.sql.Types;
34  
35  import java.util.ArrayList;
36  import java.util.List;
37  
38  /**
39   * <a href="JournalArticleResourceModelImpl.java.html"><b><i>View Source</i></b></a>
40   *
41   * <p>
42   * ServiceBuilder generated this class. Modifications in this class will be
43   * overwritten the next time is generated.
44   * </p>
45   *
46   * <p>
47   * This interface is a model that represents the JournalArticleResource table in the
48   * database.
49   * </p>
50   *
51   * @author    Brian Wing Shun Chan
52   * @see       JournalArticleResourceImpl
53   * @see       com.liferay.portlet.journal.model.JournalArticleResource
54   * @see       com.liferay.portlet.journal.model.JournalArticleResourceModel
55   * @generated
56   */
57  public class JournalArticleResourceModelImpl extends BaseModelImpl<JournalArticleResource> {
58      public static final String TABLE_NAME = "JournalArticleResource";
59      public static final Object[][] TABLE_COLUMNS = {
60              { "resourcePrimKey", new Integer(Types.BIGINT) },
61              { "groupId", new Integer(Types.BIGINT) },
62              { "articleId", new Integer(Types.VARCHAR) }
63          };
64      public static final String TABLE_SQL_CREATE = "create table JournalArticleResource (resourcePrimKey LONG not null primary key,groupId LONG,articleId VARCHAR(75) null)";
65      public static final String TABLE_SQL_DROP = "drop table JournalArticleResource";
66      public static final String DATA_SOURCE = "liferayDataSource";
67      public static final String SESSION_FACTORY = "liferaySessionFactory";
68      public static final String TX_MANAGER = "liferayTransactionManager";
69      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
70                  "value.object.entity.cache.enabled.com.liferay.portlet.journal.model.JournalArticleResource"),
71              true);
72      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
73                  "value.object.finder.cache.enabled.com.liferay.portlet.journal.model.JournalArticleResource"),
74              true);
75  
76      public static JournalArticleResource toModel(
77          JournalArticleResourceSoap soapModel) {
78          JournalArticleResource model = new JournalArticleResourceImpl();
79  
80          model.setResourcePrimKey(soapModel.getResourcePrimKey());
81          model.setGroupId(soapModel.getGroupId());
82          model.setArticleId(soapModel.getArticleId());
83  
84          return model;
85      }
86  
87      public static List<JournalArticleResource> toModels(
88          JournalArticleResourceSoap[] soapModels) {
89          List<JournalArticleResource> models = new ArrayList<JournalArticleResource>(soapModels.length);
90  
91          for (JournalArticleResourceSoap soapModel : soapModels) {
92              models.add(toModel(soapModel));
93          }
94  
95          return models;
96      }
97  
98      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
99                  "lock.expiration.time.com.liferay.portlet.journal.model.JournalArticleResource"));
100 
101     public JournalArticleResourceModelImpl() {
102     }
103 
104     public long getPrimaryKey() {
105         return _resourcePrimKey;
106     }
107 
108     public void setPrimaryKey(long pk) {
109         setResourcePrimKey(pk);
110     }
111 
112     public Serializable getPrimaryKeyObj() {
113         return new Long(_resourcePrimKey);
114     }
115 
116     public long getResourcePrimKey() {
117         return _resourcePrimKey;
118     }
119 
120     public void setResourcePrimKey(long resourcePrimKey) {
121         _resourcePrimKey = resourcePrimKey;
122     }
123 
124     public long getGroupId() {
125         return _groupId;
126     }
127 
128     public void setGroupId(long groupId) {
129         _groupId = groupId;
130 
131         if (!_setOriginalGroupId) {
132             _setOriginalGroupId = true;
133 
134             _originalGroupId = groupId;
135         }
136     }
137 
138     public long getOriginalGroupId() {
139         return _originalGroupId;
140     }
141 
142     public String getArticleId() {
143         return GetterUtil.getString(_articleId);
144     }
145 
146     public void setArticleId(String articleId) {
147         _articleId = articleId;
148 
149         if (_originalArticleId == null) {
150             _originalArticleId = articleId;
151         }
152     }
153 
154     public String getOriginalArticleId() {
155         return GetterUtil.getString(_originalArticleId);
156     }
157 
158     public JournalArticleResource toEscapedModel() {
159         if (isEscapedModel()) {
160             return (JournalArticleResource)this;
161         }
162         else {
163             JournalArticleResource model = new JournalArticleResourceImpl();
164 
165             model.setNew(isNew());
166             model.setEscapedModel(true);
167 
168             model.setResourcePrimKey(getResourcePrimKey());
169             model.setGroupId(getGroupId());
170             model.setArticleId(HtmlUtil.escape(getArticleId()));
171 
172             model = (JournalArticleResource)Proxy.newProxyInstance(JournalArticleResource.class.getClassLoader(),
173                     new Class[] { JournalArticleResource.class },
174                     new ReadOnlyBeanHandler(model));
175 
176             return model;
177         }
178     }
179 
180     public ExpandoBridge getExpandoBridge() {
181         if (_expandoBridge == null) {
182             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
183                     JournalArticleResource.class.getName(), getResourcePrimKey());
184         }
185 
186         return _expandoBridge;
187     }
188 
189     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
190         getExpandoBridge().setAttributes(serviceContext);
191     }
192 
193     public Object clone() {
194         JournalArticleResourceImpl clone = new JournalArticleResourceImpl();
195 
196         clone.setResourcePrimKey(getResourcePrimKey());
197         clone.setGroupId(getGroupId());
198         clone.setArticleId(getArticleId());
199 
200         return clone;
201     }
202 
203     public int compareTo(JournalArticleResource journalArticleResource) {
204         long pk = journalArticleResource.getPrimaryKey();
205 
206         if (getPrimaryKey() < pk) {
207             return -1;
208         }
209         else if (getPrimaryKey() > pk) {
210             return 1;
211         }
212         else {
213             return 0;
214         }
215     }
216 
217     public boolean equals(Object obj) {
218         if (obj == null) {
219             return false;
220         }
221 
222         JournalArticleResource journalArticleResource = null;
223 
224         try {
225             journalArticleResource = (JournalArticleResource)obj;
226         }
227         catch (ClassCastException cce) {
228             return false;
229         }
230 
231         long pk = journalArticleResource.getPrimaryKey();
232 
233         if (getPrimaryKey() == pk) {
234             return true;
235         }
236         else {
237             return false;
238         }
239     }
240 
241     public int hashCode() {
242         return (int)getPrimaryKey();
243     }
244 
245     public String toString() {
246         StringBundler sb = new StringBundler(7);
247 
248         sb.append("{resourcePrimKey=");
249         sb.append(getResourcePrimKey());
250         sb.append(", groupId=");
251         sb.append(getGroupId());
252         sb.append(", articleId=");
253         sb.append(getArticleId());
254         sb.append("}");
255 
256         return sb.toString();
257     }
258 
259     public String toXmlString() {
260         StringBundler sb = new StringBundler(13);
261 
262         sb.append("<model><model-name>");
263         sb.append("com.liferay.portlet.journal.model.JournalArticleResource");
264         sb.append("</model-name>");
265 
266         sb.append(
267             "<column><column-name>resourcePrimKey</column-name><column-value><![CDATA[");
268         sb.append(getResourcePrimKey());
269         sb.append("]]></column-value></column>");
270         sb.append(
271             "<column><column-name>groupId</column-name><column-value><![CDATA[");
272         sb.append(getGroupId());
273         sb.append("]]></column-value></column>");
274         sb.append(
275             "<column><column-name>articleId</column-name><column-value><![CDATA[");
276         sb.append(getArticleId());
277         sb.append("]]></column-value></column>");
278 
279         sb.append("</model>");
280 
281         return sb.toString();
282     }
283 
284     private long _resourcePrimKey;
285     private long _groupId;
286     private long _originalGroupId;
287     private boolean _setOriginalGroupId;
288     private String _articleId;
289     private String _originalArticleId;
290     private transient ExpandoBridge _expandoBridge;
291 }