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.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.service.model.ResourceCode
56   * @see com.liferay.portal.service.model.ResourceCodeModel
57   * @see com.liferay.portal.service.model.impl.ResourceCodeImpl
58   *
59   */
60  public class ResourceCodeModelImpl extends BaseModelImpl {
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(300) 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 CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
80                  "value.object.finder.cache.enabled.com.liferay.portal.model.ResourceCode"),
81              true);
82  
83      public static ResourceCode toModel(ResourceCodeSoap soapModel) {
84          ResourceCode model = new ResourceCodeImpl();
85  
86          model.setCodeId(soapModel.getCodeId());
87          model.setCompanyId(soapModel.getCompanyId());
88          model.setName(soapModel.getName());
89          model.setScope(soapModel.getScope());
90  
91          return model;
92      }
93  
94      public static List<ResourceCode> toModels(ResourceCodeSoap[] soapModels) {
95          List<ResourceCode> models = new ArrayList<ResourceCode>(soapModels.length);
96  
97          for (ResourceCodeSoap soapModel : soapModels) {
98              models.add(toModel(soapModel));
99          }
100 
101         return models;
102     }
103 
104     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
105                 "lock.expiration.time.com.liferay.portal.model.ResourceCode"));
106 
107     public ResourceCodeModelImpl() {
108     }
109 
110     public long getPrimaryKey() {
111         return _codeId;
112     }
113 
114     public void setPrimaryKey(long pk) {
115         setCodeId(pk);
116     }
117 
118     public Serializable getPrimaryKeyObj() {
119         return new Long(_codeId);
120     }
121 
122     public long getCodeId() {
123         return _codeId;
124     }
125 
126     public void setCodeId(long codeId) {
127         if (codeId != _codeId) {
128             _codeId = codeId;
129         }
130     }
131 
132     public long getCompanyId() {
133         return _companyId;
134     }
135 
136     public void setCompanyId(long companyId) {
137         if (companyId != _companyId) {
138             _companyId = companyId;
139         }
140     }
141 
142     public String getName() {
143         return GetterUtil.getString(_name);
144     }
145 
146     public void setName(String name) {
147         if (((name == null) && (_name != null)) ||
148                 ((name != null) && (_name == null)) ||
149                 ((name != null) && (_name != null) && !name.equals(_name))) {
150             _name = name;
151         }
152     }
153 
154     public int getScope() {
155         return _scope;
156     }
157 
158     public void setScope(int scope) {
159         if (scope != _scope) {
160             _scope = scope;
161         }
162     }
163 
164     public ResourceCode toEscapedModel() {
165         if (isEscapedModel()) {
166             return (ResourceCode)this;
167         }
168         else {
169             ResourceCode model = new ResourceCodeImpl();
170 
171             model.setEscapedModel(true);
172 
173             model.setCodeId(getCodeId());
174             model.setCompanyId(getCompanyId());
175             model.setName(HtmlUtil.escape(getName()));
176             model.setScope(getScope());
177 
178             model = (ResourceCode)Proxy.newProxyInstance(ResourceCode.class.getClassLoader(),
179                     new Class[] { ResourceCode.class },
180                     new ReadOnlyBeanHandler(model));
181 
182             return model;
183         }
184     }
185 
186     public Object clone() {
187         ResourceCodeImpl clone = new ResourceCodeImpl();
188 
189         clone.setCodeId(getCodeId());
190         clone.setCompanyId(getCompanyId());
191         clone.setName(getName());
192         clone.setScope(getScope());
193 
194         return clone;
195     }
196 
197     public int compareTo(Object obj) {
198         if (obj == null) {
199             return -1;
200         }
201 
202         ResourceCodeImpl resourceCode = (ResourceCodeImpl)obj;
203 
204         long pk = resourceCode.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         ResourceCodeImpl resourceCode = null;
223 
224         try {
225             resourceCode = (ResourceCodeImpl)obj;
226         }
227         catch (ClassCastException cce) {
228             return false;
229         }
230 
231         long pk = resourceCode.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     private long _codeId;
246     private long _companyId;
247     private String _name;
248     private int _scope;
249 }