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