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