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