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.kernel.util.HtmlUtil;
28  import com.liferay.portal.kernel.util.StringPool;
29  import com.liferay.portal.model.impl.BaseModelImpl;
30  import com.liferay.portal.util.PortalUtil;
31  
32  import com.liferay.portlet.expando.model.ExpandoValue;
33  import com.liferay.portlet.expando.model.ExpandoValueSoap;
34  
35  import java.io.Serializable;
36  
37  import java.lang.reflect.Proxy;
38  
39  import java.sql.Types;
40  
41  import java.util.ArrayList;
42  import java.util.List;
43  
44  /**
45   * <a href="ExpandoValueModelImpl.java.html"><b><i>View Source</i></b></a>
46   *
47   * <p>
48   * ServiceBuilder generated this class. Modifications in this class will be
49   * overwritten the next time is generated.
50   * </p>
51   *
52   * <p>
53   * This interface is a model that represents the ExpandoValue table in the
54   * database.
55   * </p>
56   *
57   * @author    Brian Wing Shun Chan
58   * @see       ExpandoValueImpl
59   * @see       com.liferay.portlet.expando.model.ExpandoValue
60   * @see       com.liferay.portlet.expando.model.ExpandoValueModel
61   * @generated
62   */
63  public class ExpandoValueModelImpl extends BaseModelImpl<ExpandoValue> {
64      public static final String TABLE_NAME = "ExpandoValue";
65      public static final Object[][] TABLE_COLUMNS = {
66              { "valueId", new Integer(Types.BIGINT) },
67              { "tableId", new Integer(Types.BIGINT) },
68              { "columnId", new Integer(Types.BIGINT) },
69              { "rowId_", new Integer(Types.BIGINT) },
70              { "classNameId", new Integer(Types.BIGINT) },
71              { "classPK", new Integer(Types.BIGINT) },
72              { "data_", new Integer(Types.VARCHAR) }
73          };
74      public static final String TABLE_SQL_CREATE = "create table ExpandoValue (valueId LONG not null primary key,tableId LONG,columnId LONG,rowId_ LONG,classNameId LONG,classPK LONG,data_ STRING null)";
75      public static final String TABLE_SQL_DROP = "drop table ExpandoValue";
76      public static final String DATA_SOURCE = "liferayDataSource";
77      public static final String SESSION_FACTORY = "liferaySessionFactory";
78      public static final String TX_MANAGER = "liferayTransactionManager";
79      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
80                  "value.object.entity.cache.enabled.com.liferay.portlet.expando.model.ExpandoValue"),
81              true);
82      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
83                  "value.object.finder.cache.enabled.com.liferay.portlet.expando.model.ExpandoValue"),
84              true);
85  
86      public static ExpandoValue toModel(ExpandoValueSoap soapModel) {
87          ExpandoValue model = new ExpandoValueImpl();
88  
89          model.setValueId(soapModel.getValueId());
90          model.setTableId(soapModel.getTableId());
91          model.setColumnId(soapModel.getColumnId());
92          model.setRowId(soapModel.getRowId());
93          model.setClassNameId(soapModel.getClassNameId());
94          model.setClassPK(soapModel.getClassPK());
95          model.setData(soapModel.getData());
96  
97          return model;
98      }
99  
100     public static List<ExpandoValue> toModels(ExpandoValueSoap[] soapModels) {
101         List<ExpandoValue> models = new ArrayList<ExpandoValue>(soapModels.length);
102 
103         for (ExpandoValueSoap soapModel : soapModels) {
104             models.add(toModel(soapModel));
105         }
106 
107         return models;
108     }
109 
110     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
111                 "lock.expiration.time.com.liferay.portlet.expando.model.ExpandoValue"));
112 
113     public ExpandoValueModelImpl() {
114     }
115 
116     public long getPrimaryKey() {
117         return _valueId;
118     }
119 
120     public void setPrimaryKey(long pk) {
121         setValueId(pk);
122     }
123 
124     public Serializable getPrimaryKeyObj() {
125         return new Long(_valueId);
126     }
127 
128     public long getValueId() {
129         return _valueId;
130     }
131 
132     public void setValueId(long valueId) {
133         _valueId = valueId;
134     }
135 
136     public long getTableId() {
137         return _tableId;
138     }
139 
140     public void setTableId(long tableId) {
141         _tableId = tableId;
142 
143         if (!_setOriginalTableId) {
144             _setOriginalTableId = true;
145 
146             _originalTableId = tableId;
147         }
148     }
149 
150     public long getOriginalTableId() {
151         return _originalTableId;
152     }
153 
154     public long getColumnId() {
155         return _columnId;
156     }
157 
158     public void setColumnId(long columnId) {
159         _columnId = columnId;
160 
161         if (!_setOriginalColumnId) {
162             _setOriginalColumnId = true;
163 
164             _originalColumnId = columnId;
165         }
166     }
167 
168     public long getOriginalColumnId() {
169         return _originalColumnId;
170     }
171 
172     public long getRowId() {
173         return _rowId;
174     }
175 
176     public void setRowId(long rowId) {
177         _rowId = rowId;
178 
179         if (!_setOriginalRowId) {
180             _setOriginalRowId = true;
181 
182             _originalRowId = rowId;
183         }
184     }
185 
186     public long getOriginalRowId() {
187         return _originalRowId;
188     }
189 
190     public String getClassName() {
191         if (getClassNameId() <= 0) {
192             return StringPool.BLANK;
193         }
194 
195         return PortalUtil.getClassName(getClassNameId());
196     }
197 
198     public long getClassNameId() {
199         return _classNameId;
200     }
201 
202     public void setClassNameId(long classNameId) {
203         _classNameId = classNameId;
204     }
205 
206     public long getClassPK() {
207         return _classPK;
208     }
209 
210     public void setClassPK(long classPK) {
211         _classPK = classPK;
212 
213         if (!_setOriginalClassPK) {
214             _setOriginalClassPK = true;
215 
216             _originalClassPK = classPK;
217         }
218     }
219 
220     public long getOriginalClassPK() {
221         return _originalClassPK;
222     }
223 
224     public String getData() {
225         return GetterUtil.getString(_data);
226     }
227 
228     public void setData(String data) {
229         _data = data;
230     }
231 
232     public ExpandoValue toEscapedModel() {
233         if (isEscapedModel()) {
234             return (ExpandoValue)this;
235         }
236         else {
237             ExpandoValue model = new ExpandoValueImpl();
238 
239             model.setNew(isNew());
240             model.setEscapedModel(true);
241 
242             model.setValueId(getValueId());
243             model.setTableId(getTableId());
244             model.setColumnId(getColumnId());
245             model.setRowId(getRowId());
246             model.setClassNameId(getClassNameId());
247             model.setClassPK(getClassPK());
248             model.setData(HtmlUtil.escape(getData()));
249 
250             model = (ExpandoValue)Proxy.newProxyInstance(ExpandoValue.class.getClassLoader(),
251                     new Class[] { ExpandoValue.class },
252                     new ReadOnlyBeanHandler(model));
253 
254             return model;
255         }
256     }
257 
258     public Object clone() {
259         ExpandoValueImpl clone = new ExpandoValueImpl();
260 
261         clone.setValueId(getValueId());
262         clone.setTableId(getTableId());
263         clone.setColumnId(getColumnId());
264         clone.setRowId(getRowId());
265         clone.setClassNameId(getClassNameId());
266         clone.setClassPK(getClassPK());
267         clone.setData(getData());
268 
269         return clone;
270     }
271 
272     public int compareTo(ExpandoValue expandoValue) {
273         int value = 0;
274 
275         if (getTableId() < expandoValue.getTableId()) {
276             value = -1;
277         }
278         else if (getTableId() > expandoValue.getTableId()) {
279             value = 1;
280         }
281         else {
282             value = 0;
283         }
284 
285         if (value != 0) {
286             return value;
287         }
288 
289         if (getRowId() < expandoValue.getRowId()) {
290             value = -1;
291         }
292         else if (getRowId() > expandoValue.getRowId()) {
293             value = 1;
294         }
295         else {
296             value = 0;
297         }
298 
299         if (value != 0) {
300             return value;
301         }
302 
303         if (getColumnId() < expandoValue.getColumnId()) {
304             value = -1;
305         }
306         else if (getColumnId() > expandoValue.getColumnId()) {
307             value = 1;
308         }
309         else {
310             value = 0;
311         }
312 
313         if (value != 0) {
314             return value;
315         }
316 
317         return 0;
318     }
319 
320     public boolean equals(Object obj) {
321         if (obj == null) {
322             return false;
323         }
324 
325         ExpandoValue expandoValue = null;
326 
327         try {
328             expandoValue = (ExpandoValue)obj;
329         }
330         catch (ClassCastException cce) {
331             return false;
332         }
333 
334         long pk = expandoValue.getPrimaryKey();
335 
336         if (getPrimaryKey() == pk) {
337             return true;
338         }
339         else {
340             return false;
341         }
342     }
343 
344     public int hashCode() {
345         return (int)getPrimaryKey();
346     }
347 
348     public String toString() {
349         StringBuilder sb = new StringBuilder();
350 
351         sb.append("{valueId=");
352         sb.append(getValueId());
353         sb.append(", tableId=");
354         sb.append(getTableId());
355         sb.append(", columnId=");
356         sb.append(getColumnId());
357         sb.append(", rowId=");
358         sb.append(getRowId());
359         sb.append(", classNameId=");
360         sb.append(getClassNameId());
361         sb.append(", classPK=");
362         sb.append(getClassPK());
363         sb.append(", data=");
364         sb.append(getData());
365         sb.append("}");
366 
367         return sb.toString();
368     }
369 
370     public String toXmlString() {
371         StringBuilder sb = new StringBuilder();
372 
373         sb.append("<model><model-name>");
374         sb.append("com.liferay.portlet.expando.model.ExpandoValue");
375         sb.append("</model-name>");
376 
377         sb.append(
378             "<column><column-name>valueId</column-name><column-value><![CDATA[");
379         sb.append(getValueId());
380         sb.append("]]></column-value></column>");
381         sb.append(
382             "<column><column-name>tableId</column-name><column-value><![CDATA[");
383         sb.append(getTableId());
384         sb.append("]]></column-value></column>");
385         sb.append(
386             "<column><column-name>columnId</column-name><column-value><![CDATA[");
387         sb.append(getColumnId());
388         sb.append("]]></column-value></column>");
389         sb.append(
390             "<column><column-name>rowId</column-name><column-value><![CDATA[");
391         sb.append(getRowId());
392         sb.append("]]></column-value></column>");
393         sb.append(
394             "<column><column-name>classNameId</column-name><column-value><![CDATA[");
395         sb.append(getClassNameId());
396         sb.append("]]></column-value></column>");
397         sb.append(
398             "<column><column-name>classPK</column-name><column-value><![CDATA[");
399         sb.append(getClassPK());
400         sb.append("]]></column-value></column>");
401         sb.append(
402             "<column><column-name>data</column-name><column-value><![CDATA[");
403         sb.append(getData());
404         sb.append("]]></column-value></column>");
405 
406         sb.append("</model>");
407 
408         return sb.toString();
409     }
410 
411     private long _valueId;
412     private long _tableId;
413     private long _originalTableId;
414     private boolean _setOriginalTableId;
415     private long _columnId;
416     private long _originalColumnId;
417     private boolean _setOriginalColumnId;
418     private long _rowId;
419     private long _originalRowId;
420     private boolean _setOriginalRowId;
421     private long _classNameId;
422     private long _classPK;
423     private long _originalClassPK;
424     private boolean _setOriginalClassPK;
425     private String _data;
426 }