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.StringBundler;
20  import com.liferay.portal.model.impl.BaseModelImpl;
21  
22  import com.liferay.portlet.expando.model.ExpandoRow;
23  import com.liferay.portlet.expando.model.ExpandoRowSoap;
24  
25  import java.io.Serializable;
26  
27  import java.lang.reflect.Proxy;
28  
29  import java.sql.Types;
30  
31  import java.util.ArrayList;
32  import java.util.List;
33  
34  /**
35   * <a href="ExpandoRowModelImpl.java.html"><b><i>View Source</i></b></a>
36   *
37   * <p>
38   * ServiceBuilder generated this class. Modifications in this class will be
39   * overwritten the next time is generated.
40   * </p>
41   *
42   * <p>
43   * This interface is a model that represents the ExpandoRow table in the
44   * database.
45   * </p>
46   *
47   * @author    Brian Wing Shun Chan
48   * @see       ExpandoRowImpl
49   * @see       com.liferay.portlet.expando.model.ExpandoRow
50   * @see       com.liferay.portlet.expando.model.ExpandoRowModel
51   * @generated
52   */
53  public class ExpandoRowModelImpl extends BaseModelImpl<ExpandoRow> {
54      public static final String TABLE_NAME = "ExpandoRow";
55      public static final Object[][] TABLE_COLUMNS = {
56              { "rowId_", new Integer(Types.BIGINT) },
57              { "companyId", new Integer(Types.BIGINT) },
58              { "tableId", new Integer(Types.BIGINT) },
59              { "classPK", new Integer(Types.BIGINT) }
60          };
61      public static final String TABLE_SQL_CREATE = "create table ExpandoRow (rowId_ LONG not null primary key,companyId LONG,tableId LONG,classPK LONG)";
62      public static final String TABLE_SQL_DROP = "drop table ExpandoRow";
63      public static final String DATA_SOURCE = "liferayDataSource";
64      public static final String SESSION_FACTORY = "liferaySessionFactory";
65      public static final String TX_MANAGER = "liferayTransactionManager";
66      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
67                  "value.object.entity.cache.enabled.com.liferay.portlet.expando.model.ExpandoRow"),
68              true);
69      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
70                  "value.object.finder.cache.enabled.com.liferay.portlet.expando.model.ExpandoRow"),
71              true);
72  
73      public static ExpandoRow toModel(ExpandoRowSoap soapModel) {
74          ExpandoRow model = new ExpandoRowImpl();
75  
76          model.setRowId(soapModel.getRowId());
77          model.setCompanyId(soapModel.getCompanyId());
78          model.setTableId(soapModel.getTableId());
79          model.setClassPK(soapModel.getClassPK());
80  
81          return model;
82      }
83  
84      public static List<ExpandoRow> toModels(ExpandoRowSoap[] soapModels) {
85          List<ExpandoRow> models = new ArrayList<ExpandoRow>(soapModels.length);
86  
87          for (ExpandoRowSoap soapModel : soapModels) {
88              models.add(toModel(soapModel));
89          }
90  
91          return models;
92      }
93  
94      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
95                  "lock.expiration.time.com.liferay.portlet.expando.model.ExpandoRow"));
96  
97      public ExpandoRowModelImpl() {
98      }
99  
100     public long getPrimaryKey() {
101         return _rowId;
102     }
103 
104     public void setPrimaryKey(long pk) {
105         setRowId(pk);
106     }
107 
108     public Serializable getPrimaryKeyObj() {
109         return new Long(_rowId);
110     }
111 
112     public long getRowId() {
113         return _rowId;
114     }
115 
116     public void setRowId(long rowId) {
117         _rowId = rowId;
118     }
119 
120     public long getCompanyId() {
121         return _companyId;
122     }
123 
124     public void setCompanyId(long companyId) {
125         _companyId = companyId;
126     }
127 
128     public long getTableId() {
129         return _tableId;
130     }
131 
132     public void setTableId(long tableId) {
133         _tableId = tableId;
134 
135         if (!_setOriginalTableId) {
136             _setOriginalTableId = true;
137 
138             _originalTableId = tableId;
139         }
140     }
141 
142     public long getOriginalTableId() {
143         return _originalTableId;
144     }
145 
146     public long getClassPK() {
147         return _classPK;
148     }
149 
150     public void setClassPK(long classPK) {
151         _classPK = classPK;
152 
153         if (!_setOriginalClassPK) {
154             _setOriginalClassPK = true;
155 
156             _originalClassPK = classPK;
157         }
158     }
159 
160     public long getOriginalClassPK() {
161         return _originalClassPK;
162     }
163 
164     public ExpandoRow toEscapedModel() {
165         if (isEscapedModel()) {
166             return (ExpandoRow)this;
167         }
168         else {
169             ExpandoRow model = new ExpandoRowImpl();
170 
171             model.setNew(isNew());
172             model.setEscapedModel(true);
173 
174             model.setRowId(getRowId());
175             model.setCompanyId(getCompanyId());
176             model.setTableId(getTableId());
177             model.setClassPK(getClassPK());
178 
179             model = (ExpandoRow)Proxy.newProxyInstance(ExpandoRow.class.getClassLoader(),
180                     new Class[] { ExpandoRow.class },
181                     new ReadOnlyBeanHandler(model));
182 
183             return model;
184         }
185     }
186 
187     public Object clone() {
188         ExpandoRowImpl clone = new ExpandoRowImpl();
189 
190         clone.setRowId(getRowId());
191         clone.setCompanyId(getCompanyId());
192         clone.setTableId(getTableId());
193         clone.setClassPK(getClassPK());
194 
195         return clone;
196     }
197 
198     public int compareTo(ExpandoRow expandoRow) {
199         long pk = expandoRow.getPrimaryKey();
200 
201         if (getPrimaryKey() < pk) {
202             return -1;
203         }
204         else if (getPrimaryKey() > pk) {
205             return 1;
206         }
207         else {
208             return 0;
209         }
210     }
211 
212     public boolean equals(Object obj) {
213         if (obj == null) {
214             return false;
215         }
216 
217         ExpandoRow expandoRow = null;
218 
219         try {
220             expandoRow = (ExpandoRow)obj;
221         }
222         catch (ClassCastException cce) {
223             return false;
224         }
225 
226         long pk = expandoRow.getPrimaryKey();
227 
228         if (getPrimaryKey() == pk) {
229             return true;
230         }
231         else {
232             return false;
233         }
234     }
235 
236     public int hashCode() {
237         return (int)getPrimaryKey();
238     }
239 
240     public String toString() {
241         StringBundler sb = new StringBundler(9);
242 
243         sb.append("{rowId=");
244         sb.append(getRowId());
245         sb.append(", companyId=");
246         sb.append(getCompanyId());
247         sb.append(", tableId=");
248         sb.append(getTableId());
249         sb.append(", classPK=");
250         sb.append(getClassPK());
251         sb.append("}");
252 
253         return sb.toString();
254     }
255 
256     public String toXmlString() {
257         StringBundler sb = new StringBundler(16);
258 
259         sb.append("<model><model-name>");
260         sb.append("com.liferay.portlet.expando.model.ExpandoRow");
261         sb.append("</model-name>");
262 
263         sb.append(
264             "<column><column-name>rowId</column-name><column-value><![CDATA[");
265         sb.append(getRowId());
266         sb.append("]]></column-value></column>");
267         sb.append(
268             "<column><column-name>companyId</column-name><column-value><![CDATA[");
269         sb.append(getCompanyId());
270         sb.append("]]></column-value></column>");
271         sb.append(
272             "<column><column-name>tableId</column-name><column-value><![CDATA[");
273         sb.append(getTableId());
274         sb.append("]]></column-value></column>");
275         sb.append(
276             "<column><column-name>classPK</column-name><column-value><![CDATA[");
277         sb.append(getClassPK());
278         sb.append("]]></column-value></column>");
279 
280         sb.append("</model>");
281 
282         return sb.toString();
283     }
284 
285     private long _rowId;
286     private long _companyId;
287     private long _tableId;
288     private long _originalTableId;
289     private boolean _setOriginalTableId;
290     private long _classPK;
291     private long _originalClassPK;
292     private boolean _setOriginalClassPK;
293 }