1   /**
2    * Copyright (c) 2000-2009 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   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portlet.expando.model.impl;
21  
22  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23  import com.liferay.portal.kernel.util.GetterUtil;
24  import com.liferay.portal.model.impl.BaseModelImpl;
25  
26  import com.liferay.portlet.expando.model.ExpandoRow;
27  import com.liferay.portlet.expando.model.ExpandoRowSoap;
28  
29  import java.io.Serializable;
30  
31  import java.lang.reflect.Proxy;
32  
33  import java.sql.Types;
34  
35  import java.util.ArrayList;
36  import java.util.List;
37  
38  /**
39   * <a href="ExpandoRowModelImpl.java.html"><b><i>View Source</i></b></a>
40   *
41   * <p>
42   * ServiceBuilder generated this class. Modifications in this class will be
43   * overwritten the next time is generated.
44   * </p>
45   *
46   * <p>
47   * This class is a model that represents the <code>ExpandoRow</code> table
48   * in the database.
49   * </p>
50   *
51   * @author Brian Wing Shun Chan
52   *
53   * @see com.liferay.portlet.expando.model.ExpandoRow
54   * @see com.liferay.portlet.expando.model.ExpandoRowModel
55   * @see com.liferay.portlet.expando.model.impl.ExpandoRowImpl
56   *
57   */
58  public class ExpandoRowModelImpl extends BaseModelImpl<ExpandoRow> {
59      public static final String TABLE_NAME = "ExpandoRow";
60      public static final Object[][] TABLE_COLUMNS = {
61              { "rowId_", new Integer(Types.BIGINT) },
62              
63  
64              { "companyId", new Integer(Types.BIGINT) },
65              
66  
67              { "tableId", new Integer(Types.BIGINT) },
68              
69  
70              { "classPK", new Integer(Types.BIGINT) }
71          };
72      public static final String TABLE_SQL_CREATE = "create table ExpandoRow (rowId_ LONG not null primary key,companyId LONG,tableId LONG,classPK LONG)";
73      public static final String TABLE_SQL_DROP = "drop table ExpandoRow";
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.ExpandoRow"),
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.ExpandoRow"),
82              true);
83  
84      public static ExpandoRow toModel(ExpandoRowSoap soapModel) {
85          ExpandoRow model = new ExpandoRowImpl();
86  
87          model.setRowId(soapModel.getRowId());
88          model.setCompanyId(soapModel.getCompanyId());
89          model.setTableId(soapModel.getTableId());
90          model.setClassPK(soapModel.getClassPK());
91  
92          return model;
93      }
94  
95      public static List<ExpandoRow> toModels(ExpandoRowSoap[] soapModels) {
96          List<ExpandoRow> models = new ArrayList<ExpandoRow>(soapModels.length);
97  
98          for (ExpandoRowSoap 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.ExpandoRow"));
107 
108     public ExpandoRowModelImpl() {
109     }
110 
111     public long getPrimaryKey() {
112         return _rowId;
113     }
114 
115     public void setPrimaryKey(long pk) {
116         setRowId(pk);
117     }
118 
119     public Serializable getPrimaryKeyObj() {
120         return new Long(_rowId);
121     }
122 
123     public long getRowId() {
124         return _rowId;
125     }
126 
127     public void setRowId(long rowId) {
128         _rowId = rowId;
129     }
130 
131     public long getCompanyId() {
132         return _companyId;
133     }
134 
135     public void setCompanyId(long companyId) {
136         _companyId = companyId;
137     }
138 
139     public long getTableId() {
140         return _tableId;
141     }
142 
143     public void setTableId(long tableId) {
144         _tableId = tableId;
145 
146         if (!_setOriginalTableId) {
147             _setOriginalTableId = true;
148 
149             _originalTableId = tableId;
150         }
151     }
152 
153     public long getOriginalTableId() {
154         return _originalTableId;
155     }
156 
157     public long getClassPK() {
158         return _classPK;
159     }
160 
161     public void setClassPK(long classPK) {
162         _classPK = classPK;
163 
164         if (!_setOriginalClassPK) {
165             _setOriginalClassPK = true;
166 
167             _originalClassPK = classPK;
168         }
169     }
170 
171     public long getOriginalClassPK() {
172         return _originalClassPK;
173     }
174 
175     public ExpandoRow toEscapedModel() {
176         if (isEscapedModel()) {
177             return (ExpandoRow)this;
178         }
179         else {
180             ExpandoRow model = new ExpandoRowImpl();
181 
182             model.setNew(isNew());
183             model.setEscapedModel(true);
184 
185             model.setRowId(getRowId());
186             model.setCompanyId(getCompanyId());
187             model.setTableId(getTableId());
188             model.setClassPK(getClassPK());
189 
190             model = (ExpandoRow)Proxy.newProxyInstance(ExpandoRow.class.getClassLoader(),
191                     new Class[] { ExpandoRow.class },
192                     new ReadOnlyBeanHandler(model));
193 
194             return model;
195         }
196     }
197 
198     public Object clone() {
199         ExpandoRowImpl clone = new ExpandoRowImpl();
200 
201         clone.setRowId(getRowId());
202         clone.setCompanyId(getCompanyId());
203         clone.setTableId(getTableId());
204         clone.setClassPK(getClassPK());
205 
206         return clone;
207     }
208 
209     public int compareTo(ExpandoRow expandoRow) {
210         long pk = expandoRow.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         ExpandoRow expandoRow = null;
229 
230         try {
231             expandoRow = (ExpandoRow)obj;
232         }
233         catch (ClassCastException cce) {
234             return false;
235         }
236 
237         long pk = expandoRow.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         StringBuilder sb = new StringBuilder();
253 
254         sb.append("{rowId=");
255         sb.append(getRowId());
256         sb.append(", companyId=");
257         sb.append(getCompanyId());
258         sb.append(", tableId=");
259         sb.append(getTableId());
260         sb.append(", classPK=");
261         sb.append(getClassPK());
262         sb.append("}");
263 
264         return sb.toString();
265     }
266 
267     public String toXmlString() {
268         StringBuilder sb = new StringBuilder();
269 
270         sb.append("<model><model-name>");
271         sb.append("com.liferay.portlet.expando.model.ExpandoRow");
272         sb.append("</model-name>");
273 
274         sb.append(
275             "<column><column-name>rowId</column-name><column-value><![CDATA[");
276         sb.append(getRowId());
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>tableId</column-name><column-value><![CDATA[");
284         sb.append(getTableId());
285         sb.append("]]></column-value></column>");
286         sb.append(
287             "<column><column-name>classPK</column-name><column-value><![CDATA[");
288         sb.append(getClassPK());
289         sb.append("]]></column-value></column>");
290 
291         sb.append("</model>");
292 
293         return sb.toString();
294     }
295 
296     private long _rowId;
297     private long _companyId;
298     private long _tableId;
299     private long _originalTableId;
300     private boolean _setOriginalTableId;
301     private long _classPK;
302     private long _originalClassPK;
303     private boolean _setOriginalClassPK;
304 }