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