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