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