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