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.portal.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.ResourceCode;
29  import com.liferay.portal.model.ResourceCodeSoap;
30  
31  import com.liferay.portlet.expando.model.ExpandoBridge;
32  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
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="ResourceCodeModelImpl.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>ResourceCode</code> table
53   * in the database.
54   * </p>
55   *
56   * @author Brian Wing Shun Chan
57   *
58   * @see com.liferay.portal.model.ResourceCode
59   * @see com.liferay.portal.model.ResourceCodeModel
60   * @see com.liferay.portal.model.impl.ResourceCodeImpl
61   *
62   */
63  public class ResourceCodeModelImpl extends BaseModelImpl<ResourceCode> {
64      public static final String TABLE_NAME = "ResourceCode";
65      public static final Object[][] TABLE_COLUMNS = {
66              { "codeId", new Integer(Types.BIGINT) },
67              
68  
69              { "companyId", new Integer(Types.BIGINT) },
70              
71  
72              { "name", new Integer(Types.VARCHAR) },
73              
74  
75              { "scope", new Integer(Types.INTEGER) }
76          };
77      public static final String TABLE_SQL_CREATE = "create table ResourceCode (codeId LONG not null primary key,companyId LONG,name VARCHAR(255) null,scope INTEGER)";
78      public static final String TABLE_SQL_DROP = "drop table ResourceCode";
79      public static final String DATA_SOURCE = "liferayDataSource";
80      public static final String SESSION_FACTORY = "liferaySessionFactory";
81      public static final String TX_MANAGER = "liferayTransactionManager";
82      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
83                  "value.object.entity.cache.enabled.com.liferay.portal.model.ResourceCode"),
84              true);
85      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
86                  "value.object.finder.cache.enabled.com.liferay.portal.model.ResourceCode"),
87              true);
88  
89      public static ResourceCode toModel(ResourceCodeSoap soapModel) {
90          ResourceCode model = new ResourceCodeImpl();
91  
92          model.setCodeId(soapModel.getCodeId());
93          model.setCompanyId(soapModel.getCompanyId());
94          model.setName(soapModel.getName());
95          model.setScope(soapModel.getScope());
96  
97          return model;
98      }
99  
100     public static List<ResourceCode> toModels(ResourceCodeSoap[] soapModels) {
101         List<ResourceCode> models = new ArrayList<ResourceCode>(soapModels.length);
102 
103         for (ResourceCodeSoap soapModel : soapModels) {
104             models.add(toModel(soapModel));
105         }
106 
107         return models;
108     }
109 
110     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
111                 "lock.expiration.time.com.liferay.portal.model.ResourceCode"));
112 
113     public ResourceCodeModelImpl() {
114     }
115 
116     public long getPrimaryKey() {
117         return _codeId;
118     }
119 
120     public void setPrimaryKey(long pk) {
121         setCodeId(pk);
122     }
123 
124     public Serializable getPrimaryKeyObj() {
125         return new Long(_codeId);
126     }
127 
128     public long getCodeId() {
129         return _codeId;
130     }
131 
132     public void setCodeId(long codeId) {
133         _codeId = codeId;
134     }
135 
136     public long getCompanyId() {
137         return _companyId;
138     }
139 
140     public void setCompanyId(long companyId) {
141         _companyId = companyId;
142 
143         if (!_setOriginalCompanyId) {
144             _setOriginalCompanyId = true;
145 
146             _originalCompanyId = companyId;
147         }
148     }
149 
150     public long getOriginalCompanyId() {
151         return _originalCompanyId;
152     }
153 
154     public String getName() {
155         return GetterUtil.getString(_name);
156     }
157 
158     public void setName(String name) {
159         _name = name;
160 
161         if (_originalName == null) {
162             _originalName = name;
163         }
164     }
165 
166     public String getOriginalName() {
167         return GetterUtil.getString(_originalName);
168     }
169 
170     public int getScope() {
171         return _scope;
172     }
173 
174     public void setScope(int scope) {
175         _scope = scope;
176 
177         if (!_setOriginalScope) {
178             _setOriginalScope = true;
179 
180             _originalScope = scope;
181         }
182     }
183 
184     public int getOriginalScope() {
185         return _originalScope;
186     }
187 
188     public ResourceCode toEscapedModel() {
189         if (isEscapedModel()) {
190             return (ResourceCode)this;
191         }
192         else {
193             ResourceCode model = new ResourceCodeImpl();
194 
195             model.setNew(isNew());
196             model.setEscapedModel(true);
197 
198             model.setCodeId(getCodeId());
199             model.setCompanyId(getCompanyId());
200             model.setName(HtmlUtil.escape(getName()));
201             model.setScope(getScope());
202 
203             model = (ResourceCode)Proxy.newProxyInstance(ResourceCode.class.getClassLoader(),
204                     new Class[] { ResourceCode.class },
205                     new ReadOnlyBeanHandler(model));
206 
207             return model;
208         }
209     }
210 
211     public ExpandoBridge getExpandoBridge() {
212         if (_expandoBridge == null) {
213             _expandoBridge = new ExpandoBridgeImpl(ResourceCode.class.getName(),
214                     getPrimaryKey());
215         }
216 
217         return _expandoBridge;
218     }
219 
220     public Object clone() {
221         ResourceCodeImpl clone = new ResourceCodeImpl();
222 
223         clone.setCodeId(getCodeId());
224         clone.setCompanyId(getCompanyId());
225         clone.setName(getName());
226         clone.setScope(getScope());
227 
228         return clone;
229     }
230 
231     public int compareTo(ResourceCode resourceCode) {
232         long pk = resourceCode.getPrimaryKey();
233 
234         if (getPrimaryKey() < pk) {
235             return -1;
236         }
237         else if (getPrimaryKey() > pk) {
238             return 1;
239         }
240         else {
241             return 0;
242         }
243     }
244 
245     public boolean equals(Object obj) {
246         if (obj == null) {
247             return false;
248         }
249 
250         ResourceCode resourceCode = null;
251 
252         try {
253             resourceCode = (ResourceCode)obj;
254         }
255         catch (ClassCastException cce) {
256             return false;
257         }
258 
259         long pk = resourceCode.getPrimaryKey();
260 
261         if (getPrimaryKey() == pk) {
262             return true;
263         }
264         else {
265             return false;
266         }
267     }
268 
269     public int hashCode() {
270         return (int)getPrimaryKey();
271     }
272 
273     public String toString() {
274         StringBuilder sb = new StringBuilder();
275 
276         sb.append("{codeId=");
277         sb.append(getCodeId());
278         sb.append(", companyId=");
279         sb.append(getCompanyId());
280         sb.append(", name=");
281         sb.append(getName());
282         sb.append(", scope=");
283         sb.append(getScope());
284         sb.append("}");
285 
286         return sb.toString();
287     }
288 
289     public String toXmlString() {
290         StringBuilder sb = new StringBuilder();
291 
292         sb.append("<model><model-name>");
293         sb.append("com.liferay.portal.model.ResourceCode");
294         sb.append("</model-name>");
295 
296         sb.append(
297             "<column><column-name>codeId</column-name><column-value><![CDATA[");
298         sb.append(getCodeId());
299         sb.append("]]></column-value></column>");
300         sb.append(
301             "<column><column-name>companyId</column-name><column-value><![CDATA[");
302         sb.append(getCompanyId());
303         sb.append("]]></column-value></column>");
304         sb.append(
305             "<column><column-name>name</column-name><column-value><![CDATA[");
306         sb.append(getName());
307         sb.append("]]></column-value></column>");
308         sb.append(
309             "<column><column-name>scope</column-name><column-value><![CDATA[");
310         sb.append(getScope());
311         sb.append("]]></column-value></column>");
312 
313         sb.append("</model>");
314 
315         return sb.toString();
316     }
317 
318     private long _codeId;
319     private long _companyId;
320     private long _originalCompanyId;
321     private boolean _setOriginalCompanyId;
322     private String _name;
323     private String _originalName;
324     private int _scope;
325     private int _originalScope;
326     private boolean _setOriginalScope;
327     private transient ExpandoBridge _expandoBridge;
328 }