1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portlet.expando.model.impl;
21  
22  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23  import com.liferay.portal.kernel.util.GetterUtil;
24  import com.liferay.portal.kernel.util.HtmlUtil;
25  import com.liferay.portal.kernel.util.StringPool;
26  import com.liferay.portal.model.impl.BaseModelImpl;
27  import com.liferay.portal.util.PortalUtil;
28  
29  import com.liferay.portlet.expando.model.ExpandoValue;
30  import com.liferay.portlet.expando.model.ExpandoValueSoap;
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="ExpandoValueModelImpl.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>ExpandoValue</code> table
51   * in the database.
52   * </p>
53   *
54   * @author Brian Wing Shun Chan
55   *
56   * @see com.liferay.portlet.expando.model.ExpandoValue
57   * @see com.liferay.portlet.expando.model.ExpandoValueModel
58   * @see com.liferay.portlet.expando.model.impl.ExpandoValueImpl
59   *
60   */
61  public class ExpandoValueModelImpl extends BaseModelImpl<ExpandoValue> {
62      public static final String TABLE_NAME = "ExpandoValue";
63      public static final Object[][] TABLE_COLUMNS = {
64              { "valueId", new Integer(Types.BIGINT) },
65              
66  
67              { "companyId", new Integer(Types.BIGINT) },
68              
69  
70              { "tableId", new Integer(Types.BIGINT) },
71              
72  
73              { "columnId", new Integer(Types.BIGINT) },
74              
75  
76              { "rowId_", new Integer(Types.BIGINT) },
77              
78  
79              { "classNameId", new Integer(Types.BIGINT) },
80              
81  
82              { "classPK", new Integer(Types.BIGINT) },
83              
84  
85              { "data_", new Integer(Types.VARCHAR) }
86          };
87      public static final String TABLE_SQL_CREATE = "create table ExpandoValue (valueId LONG not null primary key,companyId LONG,tableId LONG,columnId LONG,rowId_ LONG,classNameId LONG,classPK LONG,data_ STRING null)";
88      public static final String TABLE_SQL_DROP = "drop table ExpandoValue";
89      public static final String DATA_SOURCE = "liferayDataSource";
90      public static final String SESSION_FACTORY = "liferaySessionFactory";
91      public static final String TX_MANAGER = "liferayTransactionManager";
92      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
93                  "value.object.entity.cache.enabled.com.liferay.portlet.expando.model.ExpandoValue"),
94              true);
95      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
96                  "value.object.finder.cache.enabled.com.liferay.portlet.expando.model.ExpandoValue"),
97              true);
98  
99      public static ExpandoValue toModel(ExpandoValueSoap soapModel) {
100         ExpandoValue model = new ExpandoValueImpl();
101 
102         model.setValueId(soapModel.getValueId());
103         model.setCompanyId(soapModel.getCompanyId());
104         model.setTableId(soapModel.getTableId());
105         model.setColumnId(soapModel.getColumnId());
106         model.setRowId(soapModel.getRowId());
107         model.setClassNameId(soapModel.getClassNameId());
108         model.setClassPK(soapModel.getClassPK());
109         model.setData(soapModel.getData());
110 
111         return model;
112     }
113 
114     public static List<ExpandoValue> toModels(ExpandoValueSoap[] soapModels) {
115         List<ExpandoValue> models = new ArrayList<ExpandoValue>(soapModels.length);
116 
117         for (ExpandoValueSoap soapModel : soapModels) {
118             models.add(toModel(soapModel));
119         }
120 
121         return models;
122     }
123 
124     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
125                 "lock.expiration.time.com.liferay.portlet.expando.model.ExpandoValue"));
126 
127     public ExpandoValueModelImpl() {
128     }
129 
130     public long getPrimaryKey() {
131         return _valueId;
132     }
133 
134     public void setPrimaryKey(long pk) {
135         setValueId(pk);
136     }
137 
138     public Serializable getPrimaryKeyObj() {
139         return new Long(_valueId);
140     }
141 
142     public long getValueId() {
143         return _valueId;
144     }
145 
146     public void setValueId(long valueId) {
147         _valueId = valueId;
148     }
149 
150     public long getCompanyId() {
151         return _companyId;
152     }
153 
154     public void setCompanyId(long companyId) {
155         _companyId = companyId;
156     }
157 
158     public long getTableId() {
159         return _tableId;
160     }
161 
162     public void setTableId(long tableId) {
163         _tableId = tableId;
164 
165         if (!_setOriginalTableId) {
166             _setOriginalTableId = true;
167 
168             _originalTableId = tableId;
169         }
170     }
171 
172     public long getOriginalTableId() {
173         return _originalTableId;
174     }
175 
176     public long getColumnId() {
177         return _columnId;
178     }
179 
180     public void setColumnId(long columnId) {
181         _columnId = columnId;
182 
183         if (!_setOriginalColumnId) {
184             _setOriginalColumnId = true;
185 
186             _originalColumnId = columnId;
187         }
188     }
189 
190     public long getOriginalColumnId() {
191         return _originalColumnId;
192     }
193 
194     public long getRowId() {
195         return _rowId;
196     }
197 
198     public void setRowId(long rowId) {
199         _rowId = rowId;
200 
201         if (!_setOriginalRowId) {
202             _setOriginalRowId = true;
203 
204             _originalRowId = rowId;
205         }
206     }
207 
208     public long getOriginalRowId() {
209         return _originalRowId;
210     }
211 
212     public String getClassName() {
213         if (getClassNameId() <= 0) {
214             return StringPool.BLANK;
215         }
216 
217         return PortalUtil.getClassName(getClassNameId());
218     }
219 
220     public long getClassNameId() {
221         return _classNameId;
222     }
223 
224     public void setClassNameId(long classNameId) {
225         _classNameId = classNameId;
226     }
227 
228     public long getClassPK() {
229         return _classPK;
230     }
231 
232     public void setClassPK(long classPK) {
233         _classPK = classPK;
234 
235         if (!_setOriginalClassPK) {
236             _setOriginalClassPK = true;
237 
238             _originalClassPK = classPK;
239         }
240     }
241 
242     public long getOriginalClassPK() {
243         return _originalClassPK;
244     }
245 
246     public String getData() {
247         return GetterUtil.getString(_data);
248     }
249 
250     public void setData(String data) {
251         _data = data;
252     }
253 
254     public ExpandoValue toEscapedModel() {
255         if (isEscapedModel()) {
256             return (ExpandoValue)this;
257         }
258         else {
259             ExpandoValue model = new ExpandoValueImpl();
260 
261             model.setNew(isNew());
262             model.setEscapedModel(true);
263 
264             model.setValueId(getValueId());
265             model.setCompanyId(getCompanyId());
266             model.setTableId(getTableId());
267             model.setColumnId(getColumnId());
268             model.setRowId(getRowId());
269             model.setClassNameId(getClassNameId());
270             model.setClassPK(getClassPK());
271             model.setData(HtmlUtil.escape(getData()));
272 
273             model = (ExpandoValue)Proxy.newProxyInstance(ExpandoValue.class.getClassLoader(),
274                     new Class[] { ExpandoValue.class },
275                     new ReadOnlyBeanHandler(model));
276 
277             return model;
278         }
279     }
280 
281     public Object clone() {
282         ExpandoValueImpl clone = new ExpandoValueImpl();
283 
284         clone.setValueId(getValueId());
285         clone.setCompanyId(getCompanyId());
286         clone.setTableId(getTableId());
287         clone.setColumnId(getColumnId());
288         clone.setRowId(getRowId());
289         clone.setClassNameId(getClassNameId());
290         clone.setClassPK(getClassPK());
291         clone.setData(getData());
292 
293         return clone;
294     }
295 
296     public int compareTo(ExpandoValue expandoValue) {
297         int value = 0;
298 
299         if (getTableId() < expandoValue.getTableId()) {
300             value = -1;
301         }
302         else if (getTableId() > expandoValue.getTableId()) {
303             value = 1;
304         }
305         else {
306             value = 0;
307         }
308 
309         if (value != 0) {
310             return value;
311         }
312 
313         if (getRowId() < expandoValue.getRowId()) {
314             value = -1;
315         }
316         else if (getRowId() > expandoValue.getRowId()) {
317             value = 1;
318         }
319         else {
320             value = 0;
321         }
322 
323         if (value != 0) {
324             return value;
325         }
326 
327         if (getColumnId() < expandoValue.getColumnId()) {
328             value = -1;
329         }
330         else if (getColumnId() > expandoValue.getColumnId()) {
331             value = 1;
332         }
333         else {
334             value = 0;
335         }
336 
337         if (value != 0) {
338             return value;
339         }
340 
341         return 0;
342     }
343 
344     public boolean equals(Object obj) {
345         if (obj == null) {
346             return false;
347         }
348 
349         ExpandoValue expandoValue = null;
350 
351         try {
352             expandoValue = (ExpandoValue)obj;
353         }
354         catch (ClassCastException cce) {
355             return false;
356         }
357 
358         long pk = expandoValue.getPrimaryKey();
359 
360         if (getPrimaryKey() == pk) {
361             return true;
362         }
363         else {
364             return false;
365         }
366     }
367 
368     public int hashCode() {
369         return (int)getPrimaryKey();
370     }
371 
372     public String toString() {
373         StringBuilder sb = new StringBuilder();
374 
375         sb.append("{valueId=");
376         sb.append(getValueId());
377         sb.append(", companyId=");
378         sb.append(getCompanyId());
379         sb.append(", tableId=");
380         sb.append(getTableId());
381         sb.append(", columnId=");
382         sb.append(getColumnId());
383         sb.append(", rowId=");
384         sb.append(getRowId());
385         sb.append(", classNameId=");
386         sb.append(getClassNameId());
387         sb.append(", classPK=");
388         sb.append(getClassPK());
389         sb.append(", data=");
390         sb.append(getData());
391         sb.append("}");
392 
393         return sb.toString();
394     }
395 
396     public String toXmlString() {
397         StringBuilder sb = new StringBuilder();
398 
399         sb.append("<model><model-name>");
400         sb.append("com.liferay.portlet.expando.model.ExpandoValue");
401         sb.append("</model-name>");
402 
403         sb.append(
404             "<column><column-name>valueId</column-name><column-value><![CDATA[");
405         sb.append(getValueId());
406         sb.append("]]></column-value></column>");
407         sb.append(
408             "<column><column-name>companyId</column-name><column-value><![CDATA[");
409         sb.append(getCompanyId());
410         sb.append("]]></column-value></column>");
411         sb.append(
412             "<column><column-name>tableId</column-name><column-value><![CDATA[");
413         sb.append(getTableId());
414         sb.append("]]></column-value></column>");
415         sb.append(
416             "<column><column-name>columnId</column-name><column-value><![CDATA[");
417         sb.append(getColumnId());
418         sb.append("]]></column-value></column>");
419         sb.append(
420             "<column><column-name>rowId</column-name><column-value><![CDATA[");
421         sb.append(getRowId());
422         sb.append("]]></column-value></column>");
423         sb.append(
424             "<column><column-name>classNameId</column-name><column-value><![CDATA[");
425         sb.append(getClassNameId());
426         sb.append("]]></column-value></column>");
427         sb.append(
428             "<column><column-name>classPK</column-name><column-value><![CDATA[");
429         sb.append(getClassPK());
430         sb.append("]]></column-value></column>");
431         sb.append(
432             "<column><column-name>data</column-name><column-value><![CDATA[");
433         sb.append(getData());
434         sb.append("]]></column-value></column>");
435 
436         sb.append("</model>");
437 
438         return sb.toString();
439     }
440 
441     private long _valueId;
442     private long _companyId;
443     private long _tableId;
444     private long _originalTableId;
445     private boolean _setOriginalTableId;
446     private long _columnId;
447     private long _originalColumnId;
448     private boolean _setOriginalColumnId;
449     private long _rowId;
450     private long _originalRowId;
451     private boolean _setOriginalRowId;
452     private long _classNameId;
453     private long _classPK;
454     private long _originalClassPK;
455     private boolean _setOriginalClassPK;
456     private String _data;
457 }