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.portlet.expando.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.kernel.util.StringPool;
29  import com.liferay.portal.model.impl.BaseModelImpl;
30  import com.liferay.portal.util.PortalUtil;
31  
32  import com.liferay.portlet.expando.model.ExpandoTable;
33  import com.liferay.portlet.expando.model.ExpandoTableSoap;
34  
35  import java.io.Serializable;
36  
37  import java.lang.reflect.Proxy;
38  
39  import java.sql.Types;
40  
41  import java.util.ArrayList;
42  import java.util.List;
43  
44  /**
45   * <a href="ExpandoTableModelImpl.java.html"><b><i>View Source</i></b></a>
46   *
47   * <p>
48   * ServiceBuilder generated this class. Modifications in this class will be
49   * overwritten the next time is generated.
50   * </p>
51   *
52   * <p>
53   * This class is a model that represents the <code>ExpandoTable</code> table
54   * in the database.
55   * </p>
56   *
57   * @author Brian Wing Shun Chan
58   *
59   * @see com.liferay.portlet.expando.model.ExpandoTable
60   * @see com.liferay.portlet.expando.model.ExpandoTableModel
61   * @see com.liferay.portlet.expando.model.impl.ExpandoTableImpl
62   *
63   */
64  public class ExpandoTableModelImpl extends BaseModelImpl<ExpandoTable> {
65      public static final String TABLE_NAME = "ExpandoTable";
66      public static final Object[][] TABLE_COLUMNS = {
67              { "tableId", new Integer(Types.BIGINT) },
68              
69  
70              { "companyId", new Integer(Types.BIGINT) },
71              
72  
73              { "classNameId", new Integer(Types.BIGINT) },
74              
75  
76              { "name", new Integer(Types.VARCHAR) }
77          };
78      public static final String TABLE_SQL_CREATE = "create table ExpandoTable (tableId LONG not null primary key,companyId LONG,classNameId LONG,name VARCHAR(75) null)";
79      public static final String TABLE_SQL_DROP = "drop table ExpandoTable";
80      public static final String DATA_SOURCE = "liferayDataSource";
81      public static final String SESSION_FACTORY = "liferaySessionFactory";
82      public static final String TX_MANAGER = "liferayTransactionManager";
83      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
84                  "value.object.entity.cache.enabled.com.liferay.portlet.expando.model.ExpandoTable"),
85              true);
86      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
87                  "value.object.finder.cache.enabled.com.liferay.portlet.expando.model.ExpandoTable"),
88              true);
89  
90      public static ExpandoTable toModel(ExpandoTableSoap soapModel) {
91          ExpandoTable model = new ExpandoTableImpl();
92  
93          model.setTableId(soapModel.getTableId());
94          model.setCompanyId(soapModel.getCompanyId());
95          model.setClassNameId(soapModel.getClassNameId());
96          model.setName(soapModel.getName());
97  
98          return model;
99      }
100 
101     public static List<ExpandoTable> toModels(ExpandoTableSoap[] soapModels) {
102         List<ExpandoTable> models = new ArrayList<ExpandoTable>(soapModels.length);
103 
104         for (ExpandoTableSoap soapModel : soapModels) {
105             models.add(toModel(soapModel));
106         }
107 
108         return models;
109     }
110 
111     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
112                 "lock.expiration.time.com.liferay.portlet.expando.model.ExpandoTable"));
113 
114     public ExpandoTableModelImpl() {
115     }
116 
117     public long getPrimaryKey() {
118         return _tableId;
119     }
120 
121     public void setPrimaryKey(long pk) {
122         setTableId(pk);
123     }
124 
125     public Serializable getPrimaryKeyObj() {
126         return new Long(_tableId);
127     }
128 
129     public long getTableId() {
130         return _tableId;
131     }
132 
133     public void setTableId(long tableId) {
134         _tableId = tableId;
135     }
136 
137     public long getCompanyId() {
138         return _companyId;
139     }
140 
141     public void setCompanyId(long companyId) {
142         _companyId = companyId;
143 
144         if (!_setOriginalCompanyId) {
145             _setOriginalCompanyId = true;
146 
147             _originalCompanyId = companyId;
148         }
149     }
150 
151     public long getOriginalCompanyId() {
152         return _originalCompanyId;
153     }
154 
155     public String getClassName() {
156         if (getClassNameId() <= 0) {
157             return StringPool.BLANK;
158         }
159 
160         return PortalUtil.getClassName(getClassNameId());
161     }
162 
163     public long getClassNameId() {
164         return _classNameId;
165     }
166 
167     public void setClassNameId(long classNameId) {
168         _classNameId = classNameId;
169 
170         if (!_setOriginalClassNameId) {
171             _setOriginalClassNameId = true;
172 
173             _originalClassNameId = classNameId;
174         }
175     }
176 
177     public long getOriginalClassNameId() {
178         return _originalClassNameId;
179     }
180 
181     public String getName() {
182         return GetterUtil.getString(_name);
183     }
184 
185     public void setName(String name) {
186         _name = name;
187 
188         if (_originalName == null) {
189             _originalName = name;
190         }
191     }
192 
193     public String getOriginalName() {
194         return GetterUtil.getString(_originalName);
195     }
196 
197     public ExpandoTable toEscapedModel() {
198         if (isEscapedModel()) {
199             return (ExpandoTable)this;
200         }
201         else {
202             ExpandoTable model = new ExpandoTableImpl();
203 
204             model.setNew(isNew());
205             model.setEscapedModel(true);
206 
207             model.setTableId(getTableId());
208             model.setCompanyId(getCompanyId());
209             model.setClassNameId(getClassNameId());
210             model.setName(HtmlUtil.escape(getName()));
211 
212             model = (ExpandoTable)Proxy.newProxyInstance(ExpandoTable.class.getClassLoader(),
213                     new Class[] { ExpandoTable.class },
214                     new ReadOnlyBeanHandler(model));
215 
216             return model;
217         }
218     }
219 
220     public Object clone() {
221         ExpandoTableImpl clone = new ExpandoTableImpl();
222 
223         clone.setTableId(getTableId());
224         clone.setCompanyId(getCompanyId());
225         clone.setClassNameId(getClassNameId());
226         clone.setName(getName());
227 
228         return clone;
229     }
230 
231     public int compareTo(ExpandoTable expandoTable) {
232         long pk = expandoTable.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         ExpandoTable expandoTable = null;
251 
252         try {
253             expandoTable = (ExpandoTable)obj;
254         }
255         catch (ClassCastException cce) {
256             return false;
257         }
258 
259         long pk = expandoTable.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("{tableId=");
277         sb.append(getTableId());
278         sb.append(", companyId=");
279         sb.append(getCompanyId());
280         sb.append(", classNameId=");
281         sb.append(getClassNameId());
282         sb.append(", name=");
283         sb.append(getName());
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.portlet.expando.model.ExpandoTable");
294         sb.append("</model-name>");
295 
296         sb.append(
297             "<column><column-name>tableId</column-name><column-value><![CDATA[");
298         sb.append(getTableId());
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>classNameId</column-name><column-value><![CDATA[");
306         sb.append(getClassNameId());
307         sb.append("]]></column-value></column>");
308         sb.append(
309             "<column><column-name>name</column-name><column-value><![CDATA[");
310         sb.append(getName());
311         sb.append("]]></column-value></column>");
312 
313         sb.append("</model>");
314 
315         return sb.toString();
316     }
317 
318     private long _tableId;
319     private long _companyId;
320     private long _originalCompanyId;
321     private boolean _setOriginalCompanyId;
322     private long _classNameId;
323     private long _originalClassNameId;
324     private boolean _setOriginalClassNameId;
325     private String _name;
326     private String _originalName;
327 }