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