1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.expando.model.impl;
16  
17  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
18  import com.liferay.portal.kernel.util.GetterUtil;
19  import com.liferay.portal.kernel.util.HtmlUtil;
20  import com.liferay.portal.kernel.util.StringBundler;
21  import com.liferay.portal.kernel.util.StringPool;
22  import com.liferay.portal.model.impl.BaseModelImpl;
23  import com.liferay.portal.util.PortalUtil;
24  
25  import com.liferay.portlet.expando.model.ExpandoTable;
26  import com.liferay.portlet.expando.model.ExpandoTableSoap;
27  
28  import java.io.Serializable;
29  
30  import java.lang.reflect.Proxy;
31  
32  import java.sql.Types;
33  
34  import java.util.ArrayList;
35  import java.util.List;
36  
37  /**
38   * <a href="ExpandoTableModelImpl.java.html"><b><i>View Source</i></b></a>
39   *
40   * <p>
41   * ServiceBuilder generated this class. Modifications in this class will be
42   * overwritten the next time is generated.
43   * </p>
44   *
45   * <p>
46   * This interface is a model that represents the ExpandoTable table in the
47   * database.
48   * </p>
49   *
50   * @author    Brian Wing Shun Chan
51   * @see       ExpandoTableImpl
52   * @see       com.liferay.portlet.expando.model.ExpandoTable
53   * @see       com.liferay.portlet.expando.model.ExpandoTableModel
54   * @generated
55   */
56  public class ExpandoTableModelImpl extends BaseModelImpl<ExpandoTable> {
57      public static final String TABLE_NAME = "ExpandoTable";
58      public static final Object[][] TABLE_COLUMNS = {
59              { "tableId", new Integer(Types.BIGINT) },
60              { "companyId", new Integer(Types.BIGINT) },
61              { "classNameId", new Integer(Types.BIGINT) },
62              { "name", new Integer(Types.VARCHAR) }
63          };
64      public static final String TABLE_SQL_CREATE = "create table ExpandoTable (tableId LONG not null primary key,companyId LONG,classNameId LONG,name VARCHAR(75) null)";
65      public static final String TABLE_SQL_DROP = "drop table ExpandoTable";
66      public static final String DATA_SOURCE = "liferayDataSource";
67      public static final String SESSION_FACTORY = "liferaySessionFactory";
68      public static final String TX_MANAGER = "liferayTransactionManager";
69      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
70                  "value.object.entity.cache.enabled.com.liferay.portlet.expando.model.ExpandoTable"),
71              true);
72      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
73                  "value.object.finder.cache.enabled.com.liferay.portlet.expando.model.ExpandoTable"),
74              true);
75  
76      public static ExpandoTable toModel(ExpandoTableSoap soapModel) {
77          ExpandoTable model = new ExpandoTableImpl();
78  
79          model.setTableId(soapModel.getTableId());
80          model.setCompanyId(soapModel.getCompanyId());
81          model.setClassNameId(soapModel.getClassNameId());
82          model.setName(soapModel.getName());
83  
84          return model;
85      }
86  
87      public static List<ExpandoTable> toModels(ExpandoTableSoap[] soapModels) {
88          List<ExpandoTable> models = new ArrayList<ExpandoTable>(soapModels.length);
89  
90          for (ExpandoTableSoap soapModel : soapModels) {
91              models.add(toModel(soapModel));
92          }
93  
94          return models;
95      }
96  
97      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
98                  "lock.expiration.time.com.liferay.portlet.expando.model.ExpandoTable"));
99  
100     public ExpandoTableModelImpl() {
101     }
102 
103     public long getPrimaryKey() {
104         return _tableId;
105     }
106 
107     public void setPrimaryKey(long pk) {
108         setTableId(pk);
109     }
110 
111     public Serializable getPrimaryKeyObj() {
112         return new Long(_tableId);
113     }
114 
115     public long getTableId() {
116         return _tableId;
117     }
118 
119     public void setTableId(long tableId) {
120         _tableId = tableId;
121     }
122 
123     public long getCompanyId() {
124         return _companyId;
125     }
126 
127     public void setCompanyId(long companyId) {
128         _companyId = companyId;
129 
130         if (!_setOriginalCompanyId) {
131             _setOriginalCompanyId = true;
132 
133             _originalCompanyId = companyId;
134         }
135     }
136 
137     public long getOriginalCompanyId() {
138         return _originalCompanyId;
139     }
140 
141     public String getClassName() {
142         if (getClassNameId() <= 0) {
143             return StringPool.BLANK;
144         }
145 
146         return PortalUtil.getClassName(getClassNameId());
147     }
148 
149     public long getClassNameId() {
150         return _classNameId;
151     }
152 
153     public void setClassNameId(long classNameId) {
154         _classNameId = classNameId;
155 
156         if (!_setOriginalClassNameId) {
157             _setOriginalClassNameId = true;
158 
159             _originalClassNameId = classNameId;
160         }
161     }
162 
163     public long getOriginalClassNameId() {
164         return _originalClassNameId;
165     }
166 
167     public String getName() {
168         return GetterUtil.getString(_name);
169     }
170 
171     public void setName(String name) {
172         _name = name;
173 
174         if (_originalName == null) {
175             _originalName = name;
176         }
177     }
178 
179     public String getOriginalName() {
180         return GetterUtil.getString(_originalName);
181     }
182 
183     public ExpandoTable toEscapedModel() {
184         if (isEscapedModel()) {
185             return (ExpandoTable)this;
186         }
187         else {
188             ExpandoTable model = new ExpandoTableImpl();
189 
190             model.setNew(isNew());
191             model.setEscapedModel(true);
192 
193             model.setTableId(getTableId());
194             model.setCompanyId(getCompanyId());
195             model.setClassNameId(getClassNameId());
196             model.setName(HtmlUtil.escape(getName()));
197 
198             model = (ExpandoTable)Proxy.newProxyInstance(ExpandoTable.class.getClassLoader(),
199                     new Class[] { ExpandoTable.class },
200                     new ReadOnlyBeanHandler(model));
201 
202             return model;
203         }
204     }
205 
206     public Object clone() {
207         ExpandoTableImpl clone = new ExpandoTableImpl();
208 
209         clone.setTableId(getTableId());
210         clone.setCompanyId(getCompanyId());
211         clone.setClassNameId(getClassNameId());
212         clone.setName(getName());
213 
214         return clone;
215     }
216 
217     public int compareTo(ExpandoTable expandoTable) {
218         long pk = expandoTable.getPrimaryKey();
219 
220         if (getPrimaryKey() < pk) {
221             return -1;
222         }
223         else if (getPrimaryKey() > pk) {
224             return 1;
225         }
226         else {
227             return 0;
228         }
229     }
230 
231     public boolean equals(Object obj) {
232         if (obj == null) {
233             return false;
234         }
235 
236         ExpandoTable expandoTable = null;
237 
238         try {
239             expandoTable = (ExpandoTable)obj;
240         }
241         catch (ClassCastException cce) {
242             return false;
243         }
244 
245         long pk = expandoTable.getPrimaryKey();
246 
247         if (getPrimaryKey() == pk) {
248             return true;
249         }
250         else {
251             return false;
252         }
253     }
254 
255     public int hashCode() {
256         return (int)getPrimaryKey();
257     }
258 
259     public String toString() {
260         StringBundler sb = new StringBundler(9);
261 
262         sb.append("{tableId=");
263         sb.append(getTableId());
264         sb.append(", companyId=");
265         sb.append(getCompanyId());
266         sb.append(", classNameId=");
267         sb.append(getClassNameId());
268         sb.append(", name=");
269         sb.append(getName());
270         sb.append("}");
271 
272         return sb.toString();
273     }
274 
275     public String toXmlString() {
276         StringBundler sb = new StringBundler(16);
277 
278         sb.append("<model><model-name>");
279         sb.append("com.liferay.portlet.expando.model.ExpandoTable");
280         sb.append("</model-name>");
281 
282         sb.append(
283             "<column><column-name>tableId</column-name><column-value><![CDATA[");
284         sb.append(getTableId());
285         sb.append("]]></column-value></column>");
286         sb.append(
287             "<column><column-name>companyId</column-name><column-value><![CDATA[");
288         sb.append(getCompanyId());
289         sb.append("]]></column-value></column>");
290         sb.append(
291             "<column><column-name>classNameId</column-name><column-value><![CDATA[");
292         sb.append(getClassNameId());
293         sb.append("]]></column-value></column>");
294         sb.append(
295             "<column><column-name>name</column-name><column-value><![CDATA[");
296         sb.append(getName());
297         sb.append("]]></column-value></column>");
298 
299         sb.append("</model>");
300 
301         return sb.toString();
302     }
303 
304     private long _tableId;
305     private long _companyId;
306     private long _originalCompanyId;
307     private boolean _setOriginalCompanyId;
308     private long _classNameId;
309     private long _originalClassNameId;
310     private boolean _setOriginalClassNameId;
311     private String _name;
312     private String _originalName;
313 }