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.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             return (ExpandoRow)Proxy.newProxyInstance(ExpandoRow.class.getClassLoader(),
170                 new Class[] { ExpandoRow.class },
171                 new AutoEscapeBeanHandler(this));
172         }
173     }
174 
175     public Object clone() {
176         ExpandoRowImpl clone = new ExpandoRowImpl();
177 
178         clone.setRowId(getRowId());
179         clone.setCompanyId(getCompanyId());
180         clone.setTableId(getTableId());
181         clone.setClassPK(getClassPK());
182 
183         return clone;
184     }
185 
186     public int compareTo(ExpandoRow expandoRow) {
187         long pk = expandoRow.getPrimaryKey();
188 
189         if (getPrimaryKey() < pk) {
190             return -1;
191         }
192         else if (getPrimaryKey() > pk) {
193             return 1;
194         }
195         else {
196             return 0;
197         }
198     }
199 
200     public boolean equals(Object obj) {
201         if (obj == null) {
202             return false;
203         }
204 
205         ExpandoRow expandoRow = null;
206 
207         try {
208             expandoRow = (ExpandoRow)obj;
209         }
210         catch (ClassCastException cce) {
211             return false;
212         }
213 
214         long pk = expandoRow.getPrimaryKey();
215 
216         if (getPrimaryKey() == pk) {
217             return true;
218         }
219         else {
220             return false;
221         }
222     }
223 
224     public int hashCode() {
225         return (int)getPrimaryKey();
226     }
227 
228     public String toString() {
229         StringBundler sb = new StringBundler(9);
230 
231         sb.append("{rowId=");
232         sb.append(getRowId());
233         sb.append(", companyId=");
234         sb.append(getCompanyId());
235         sb.append(", tableId=");
236         sb.append(getTableId());
237         sb.append(", classPK=");
238         sb.append(getClassPK());
239         sb.append("}");
240 
241         return sb.toString();
242     }
243 
244     public String toXmlString() {
245         StringBundler sb = new StringBundler(16);
246 
247         sb.append("<model><model-name>");
248         sb.append("com.liferay.portlet.expando.model.ExpandoRow");
249         sb.append("</model-name>");
250 
251         sb.append(
252             "<column><column-name>rowId</column-name><column-value><![CDATA[");
253         sb.append(getRowId());
254         sb.append("]]></column-value></column>");
255         sb.append(
256             "<column><column-name>companyId</column-name><column-value><![CDATA[");
257         sb.append(getCompanyId());
258         sb.append("]]></column-value></column>");
259         sb.append(
260             "<column><column-name>tableId</column-name><column-value><![CDATA[");
261         sb.append(getTableId());
262         sb.append("]]></column-value></column>");
263         sb.append(
264             "<column><column-name>classPK</column-name><column-value><![CDATA[");
265         sb.append(getClassPK());
266         sb.append("]]></column-value></column>");
267 
268         sb.append("</model>");
269 
270         return sb.toString();
271     }
272 
273     private long _rowId;
274     private long _companyId;
275     private long _tableId;
276     private long _originalTableId;
277     private boolean _setOriginalTableId;
278     private long _classPK;
279     private long _originalClassPK;
280     private boolean _setOriginalClassPK;
281 }