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