1   /**
2    * Copyright (c) 2000-2008 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  import com.liferay.portal.util.PropsUtil;
29  
30  import com.liferay.portlet.expando.model.ExpandoRow;
31  import com.liferay.portlet.expando.model.ExpandoRowSoap;
32  
33  import java.io.Serializable;
34  
35  import java.lang.reflect.Proxy;
36  
37  import java.sql.Types;
38  
39  import java.util.ArrayList;
40  import java.util.List;
41  
42  /**
43   * <a href="ExpandoRowModelImpl.java.html"><b><i>View Source</i></b></a>
44   *
45   * <p>
46   * ServiceBuilder generated this class. Modifications in this class will be
47   * overwritten the next time is generated.
48   * </p>
49   *
50   * <p>
51   * This class is a model that represents the <code>ExpandoRow</code> table
52   * in the database.
53   * </p>
54   *
55   * @author Brian Wing Shun Chan
56   *
57   * @see com.liferay.portlet.expando.service.model.ExpandoRow
58   * @see com.liferay.portlet.expando.service.model.ExpandoRowModel
59   * @see com.liferay.portlet.expando.service.model.impl.ExpandoRowImpl
60   *
61   */
62  public class ExpandoRowModelImpl extends BaseModelImpl {
63      public static final String TABLE_NAME = "ExpandoRow";
64      public static final Object[][] TABLE_COLUMNS = {
65              { "rowId", new Integer(Types.BIGINT) },
66              
67  
68              { "tableId", new Integer(Types.BIGINT) }
69          };
70      public static final String TABLE_SQL_CREATE = "create table ExpandoRow (rowId LONG not null primary key,tableId LONG)";
71      public static final String TABLE_SQL_DROP = "drop table ExpandoRow";
72      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
73                  "value.object.finder.cache.enabled.com.liferay.portlet.expando.model.ExpandoRow"),
74              true);
75  
76      public static ExpandoRow toModel(ExpandoRowSoap soapModel) {
77          ExpandoRow model = new ExpandoRowImpl();
78  
79          model.setRowId(soapModel.getRowId());
80          model.setTableId(soapModel.getTableId());
81  
82          return model;
83      }
84  
85      public static List<ExpandoRow> toModels(ExpandoRowSoap[] soapModels) {
86          List<ExpandoRow> models = new ArrayList<ExpandoRow>(soapModels.length);
87  
88          for (ExpandoRowSoap soapModel : soapModels) {
89              models.add(toModel(soapModel));
90          }
91  
92          return models;
93      }
94  
95      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
96                  "lock.expiration.time.com.liferay.portlet.expando.model.ExpandoRow"));
97  
98      public ExpandoRowModelImpl() {
99      }
100 
101     public long getPrimaryKey() {
102         return _rowId;
103     }
104 
105     public void setPrimaryKey(long pk) {
106         setRowId(pk);
107     }
108 
109     public Serializable getPrimaryKeyObj() {
110         return new Long(_rowId);
111     }
112 
113     public long getRowId() {
114         return _rowId;
115     }
116 
117     public void setRowId(long rowId) {
118         if (rowId != _rowId) {
119             _rowId = rowId;
120         }
121     }
122 
123     public long getTableId() {
124         return _tableId;
125     }
126 
127     public void setTableId(long tableId) {
128         if (tableId != _tableId) {
129             _tableId = tableId;
130         }
131     }
132 
133     public ExpandoRow toEscapedModel() {
134         if (isEscapedModel()) {
135             return (ExpandoRow)this;
136         }
137         else {
138             ExpandoRow model = new ExpandoRowImpl();
139 
140             model.setEscapedModel(true);
141 
142             model.setRowId(getRowId());
143             model.setTableId(getTableId());
144 
145             model = (ExpandoRow)Proxy.newProxyInstance(ExpandoRow.class.getClassLoader(),
146                     new Class[] { ExpandoRow.class },
147                     new ReadOnlyBeanHandler(model));
148 
149             return model;
150         }
151     }
152 
153     public Object clone() {
154         ExpandoRowImpl clone = new ExpandoRowImpl();
155 
156         clone.setRowId(getRowId());
157         clone.setTableId(getTableId());
158 
159         return clone;
160     }
161 
162     public int compareTo(Object obj) {
163         if (obj == null) {
164             return -1;
165         }
166 
167         ExpandoRowImpl expandoRow = (ExpandoRowImpl)obj;
168 
169         long pk = expandoRow.getPrimaryKey();
170 
171         if (getPrimaryKey() < pk) {
172             return -1;
173         }
174         else if (getPrimaryKey() > pk) {
175             return 1;
176         }
177         else {
178             return 0;
179         }
180     }
181 
182     public boolean equals(Object obj) {
183         if (obj == null) {
184             return false;
185         }
186 
187         ExpandoRowImpl expandoRow = null;
188 
189         try {
190             expandoRow = (ExpandoRowImpl)obj;
191         }
192         catch (ClassCastException cce) {
193             return false;
194         }
195 
196         long pk = expandoRow.getPrimaryKey();
197 
198         if (getPrimaryKey() == pk) {
199             return true;
200         }
201         else {
202             return false;
203         }
204     }
205 
206     public int hashCode() {
207         return (int)getPrimaryKey();
208     }
209 
210     private long _rowId;
211     private long _tableId;
212 }