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