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.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              { "tableId", new Integer(Types.BIGINT) },
58              { "classPK", new Integer(Types.BIGINT) }
59          };
60      public static final String TABLE_SQL_CREATE = "create table ExpandoRow (rowId_ LONG not null primary key,tableId LONG,classPK LONG)";
61      public static final String TABLE_SQL_DROP = "drop table ExpandoRow";
62      public static final String DATA_SOURCE = "liferayDataSource";
63      public static final String SESSION_FACTORY = "liferaySessionFactory";
64      public static final String TX_MANAGER = "liferayTransactionManager";
65      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
66                  "value.object.entity.cache.enabled.com.liferay.portlet.expando.model.ExpandoRow"),
67              true);
68      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
69                  "value.object.finder.cache.enabled.com.liferay.portlet.expando.model.ExpandoRow"),
70              true);
71  
72      public static ExpandoRow toModel(ExpandoRowSoap soapModel) {
73          ExpandoRow model = new ExpandoRowImpl();
74  
75          model.setRowId(soapModel.getRowId());
76          model.setTableId(soapModel.getTableId());
77          model.setClassPK(soapModel.getClassPK());
78  
79          return model;
80      }
81  
82      public static List<ExpandoRow> toModels(ExpandoRowSoap[] soapModels) {
83          List<ExpandoRow> models = new ArrayList<ExpandoRow>(soapModels.length);
84  
85          for (ExpandoRowSoap soapModel : soapModels) {
86              models.add(toModel(soapModel));
87          }
88  
89          return models;
90      }
91  
92      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
93                  "lock.expiration.time.com.liferay.portlet.expando.model.ExpandoRow"));
94  
95      public ExpandoRowModelImpl() {
96      }
97  
98      public long getPrimaryKey() {
99          return _rowId;
100     }
101 
102     public void setPrimaryKey(long pk) {
103         setRowId(pk);
104     }
105 
106     public Serializable getPrimaryKeyObj() {
107         return new Long(_rowId);
108     }
109 
110     public long getRowId() {
111         return _rowId;
112     }
113 
114     public void setRowId(long rowId) {
115         _rowId = rowId;
116     }
117 
118     public long getTableId() {
119         return _tableId;
120     }
121 
122     public void setTableId(long tableId) {
123         _tableId = tableId;
124 
125         if (!_setOriginalTableId) {
126             _setOriginalTableId = true;
127 
128             _originalTableId = tableId;
129         }
130     }
131 
132     public long getOriginalTableId() {
133         return _originalTableId;
134     }
135 
136     public long getClassPK() {
137         return _classPK;
138     }
139 
140     public void setClassPK(long classPK) {
141         _classPK = classPK;
142 
143         if (!_setOriginalClassPK) {
144             _setOriginalClassPK = true;
145 
146             _originalClassPK = classPK;
147         }
148     }
149 
150     public long getOriginalClassPK() {
151         return _originalClassPK;
152     }
153 
154     public ExpandoRow toEscapedModel() {
155         if (isEscapedModel()) {
156             return (ExpandoRow)this;
157         }
158         else {
159             ExpandoRow model = new ExpandoRowImpl();
160 
161             model.setNew(isNew());
162             model.setEscapedModel(true);
163 
164             model.setRowId(getRowId());
165             model.setTableId(getTableId());
166             model.setClassPK(getClassPK());
167 
168             model = (ExpandoRow)Proxy.newProxyInstance(ExpandoRow.class.getClassLoader(),
169                     new Class[] { ExpandoRow.class },
170                     new ReadOnlyBeanHandler(model));
171 
172             return model;
173         }
174     }
175 
176     public Object clone() {
177         ExpandoRowImpl clone = new ExpandoRowImpl();
178 
179         clone.setRowId(getRowId());
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(7);
230 
231         sb.append("{rowId=");
232         sb.append(getRowId());
233         sb.append(", tableId=");
234         sb.append(getTableId());
235         sb.append(", classPK=");
236         sb.append(getClassPK());
237         sb.append("}");
238 
239         return sb.toString();
240     }
241 
242     public String toXmlString() {
243         StringBundler sb = new StringBundler(13);
244 
245         sb.append("<model><model-name>");
246         sb.append("com.liferay.portlet.expando.model.ExpandoRow");
247         sb.append("</model-name>");
248 
249         sb.append(
250             "<column><column-name>rowId</column-name><column-value><![CDATA[");
251         sb.append(getRowId());
252         sb.append("]]></column-value></column>");
253         sb.append(
254             "<column><column-name>tableId</column-name><column-value><![CDATA[");
255         sb.append(getTableId());
256         sb.append("]]></column-value></column>");
257         sb.append(
258             "<column><column-name>classPK</column-name><column-value><![CDATA[");
259         sb.append(getClassPK());
260         sb.append("]]></column-value></column>");
261 
262         sb.append("</model>");
263 
264         return sb.toString();
265     }
266 
267     private long _rowId;
268     private long _tableId;
269     private long _originalTableId;
270     private boolean _setOriginalTableId;
271     private long _classPK;
272     private long _originalClassPK;
273     private boolean _setOriginalClassPK;
274 }