1   /**
2    * Copyright (c) 2000-2010 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   *
12   * 
13   */
14  
15  package com.liferay.portlet.expando.model.impl;
16  
17  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
18  import com.liferay.portal.kernel.util.GetterUtil;
19  import com.liferay.portal.kernel.util.HtmlUtil;
20  import com.liferay.portal.kernel.util.StringBundler;
21  import com.liferay.portal.model.impl.BaseModelImpl;
22  
23  import com.liferay.portlet.expando.model.ExpandoColumn;
24  import com.liferay.portlet.expando.model.ExpandoColumnSoap;
25  
26  import java.io.Serializable;
27  
28  import java.lang.reflect.Proxy;
29  
30  import java.sql.Types;
31  
32  import java.util.ArrayList;
33  import java.util.List;
34  
35  /**
36   * <a href="ExpandoColumnModelImpl.java.html"><b><i>View Source</i></b></a>
37   *
38   * <p>
39   * ServiceBuilder generated this class. Modifications in this class will be
40   * overwritten the next time is generated.
41   * </p>
42   *
43   * <p>
44   * This interface is a model that represents the ExpandoColumn table in the
45   * database.
46   * </p>
47   *
48   * @author    Brian Wing Shun Chan
49   * @see       ExpandoColumnImpl
50   * @see       com.liferay.portlet.expando.model.ExpandoColumn
51   * @see       com.liferay.portlet.expando.model.ExpandoColumnModel
52   * @generated
53   */
54  public class ExpandoColumnModelImpl extends BaseModelImpl<ExpandoColumn> {
55      public static final String TABLE_NAME = "ExpandoColumn";
56      public static final Object[][] TABLE_COLUMNS = {
57              { "columnId", new Integer(Types.BIGINT) },
58              { "tableId", new Integer(Types.BIGINT) },
59              { "name", new Integer(Types.VARCHAR) },
60              { "type_", new Integer(Types.INTEGER) }
61          };
62      public static final String TABLE_SQL_CREATE = "create table ExpandoColumn (columnId LONG not null primary key,tableId LONG,name VARCHAR(75) null,type_ INTEGER)";
63      public static final String TABLE_SQL_DROP = "drop table ExpandoColumn";
64      public static final String DATA_SOURCE = "liferayDataSource";
65      public static final String SESSION_FACTORY = "liferaySessionFactory";
66      public static final String TX_MANAGER = "liferayTransactionManager";
67      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
68                  "value.object.entity.cache.enabled.com.liferay.portlet.expando.model.ExpandoColumn"),
69              true);
70      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
71                  "value.object.finder.cache.enabled.com.liferay.portlet.expando.model.ExpandoColumn"),
72              true);
73  
74      public static ExpandoColumn toModel(ExpandoColumnSoap soapModel) {
75          ExpandoColumn model = new ExpandoColumnImpl();
76  
77          model.setColumnId(soapModel.getColumnId());
78          model.setTableId(soapModel.getTableId());
79          model.setName(soapModel.getName());
80          model.setType(soapModel.getType());
81  
82          return model;
83      }
84  
85      public static List<ExpandoColumn> toModels(ExpandoColumnSoap[] soapModels) {
86          List<ExpandoColumn> models = new ArrayList<ExpandoColumn>(soapModels.length);
87  
88          for (ExpandoColumnSoap soapModel : soapModels) {
89              models.add(toModel(soapModel));
90          }
91  
92          return models;
93      }
94  
95      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
96                  "lock.expiration.time.com.liferay.portlet.expando.model.ExpandoColumn"));
97  
98      public ExpandoColumnModelImpl() {
99      }
100 
101     public long getPrimaryKey() {
102         return _columnId;
103     }
104 
105     public void setPrimaryKey(long pk) {
106         setColumnId(pk);
107     }
108 
109     public Serializable getPrimaryKeyObj() {
110         return new Long(_columnId);
111     }
112 
113     public long getColumnId() {
114         return _columnId;
115     }
116 
117     public void setColumnId(long columnId) {
118         _columnId = columnId;
119     }
120 
121     public long getTableId() {
122         return _tableId;
123     }
124 
125     public void setTableId(long tableId) {
126         _tableId = tableId;
127 
128         if (!_setOriginalTableId) {
129             _setOriginalTableId = true;
130 
131             _originalTableId = tableId;
132         }
133     }
134 
135     public long getOriginalTableId() {
136         return _originalTableId;
137     }
138 
139     public String getName() {
140         return GetterUtil.getString(_name);
141     }
142 
143     public void setName(String name) {
144         _name = name;
145 
146         if (_originalName == null) {
147             _originalName = name;
148         }
149     }
150 
151     public String getOriginalName() {
152         return GetterUtil.getString(_originalName);
153     }
154 
155     public int getType() {
156         return _type;
157     }
158 
159     public void setType(int type) {
160         _type = type;
161     }
162 
163     public ExpandoColumn toEscapedModel() {
164         if (isEscapedModel()) {
165             return (ExpandoColumn)this;
166         }
167         else {
168             ExpandoColumn model = new ExpandoColumnImpl();
169 
170             model.setNew(isNew());
171             model.setEscapedModel(true);
172 
173             model.setColumnId(getColumnId());
174             model.setTableId(getTableId());
175             model.setName(HtmlUtil.escape(getName()));
176             model.setType(getType());
177 
178             model = (ExpandoColumn)Proxy.newProxyInstance(ExpandoColumn.class.getClassLoader(),
179                     new Class[] { ExpandoColumn.class },
180                     new ReadOnlyBeanHandler(model));
181 
182             return model;
183         }
184     }
185 
186     public Object clone() {
187         ExpandoColumnImpl clone = new ExpandoColumnImpl();
188 
189         clone.setColumnId(getColumnId());
190         clone.setTableId(getTableId());
191         clone.setName(getName());
192         clone.setType(getType());
193 
194         return clone;
195     }
196 
197     public int compareTo(ExpandoColumn expandoColumn) {
198         long pk = expandoColumn.getPrimaryKey();
199 
200         if (getPrimaryKey() < pk) {
201             return -1;
202         }
203         else if (getPrimaryKey() > pk) {
204             return 1;
205         }
206         else {
207             return 0;
208         }
209     }
210 
211     public boolean equals(Object obj) {
212         if (obj == null) {
213             return false;
214         }
215 
216         ExpandoColumn expandoColumn = null;
217 
218         try {
219             expandoColumn = (ExpandoColumn)obj;
220         }
221         catch (ClassCastException cce) {
222             return false;
223         }
224 
225         long pk = expandoColumn.getPrimaryKey();
226 
227         if (getPrimaryKey() == pk) {
228             return true;
229         }
230         else {
231             return false;
232         }
233     }
234 
235     public int hashCode() {
236         return (int)getPrimaryKey();
237     }
238 
239     public String toString() {
240         StringBundler sb = new StringBundler(9);
241 
242         sb.append("{columnId=");
243         sb.append(getColumnId());
244         sb.append(", tableId=");
245         sb.append(getTableId());
246         sb.append(", name=");
247         sb.append(getName());
248         sb.append(", type=");
249         sb.append(getType());
250         sb.append("}");
251 
252         return sb.toString();
253     }
254 
255     public String toXmlString() {
256         StringBundler sb = new StringBundler(16);
257 
258         sb.append("<model><model-name>");
259         sb.append("com.liferay.portlet.expando.model.ExpandoColumn");
260         sb.append("</model-name>");
261 
262         sb.append(
263             "<column><column-name>columnId</column-name><column-value><![CDATA[");
264         sb.append(getColumnId());
265         sb.append("]]></column-value></column>");
266         sb.append(
267             "<column><column-name>tableId</column-name><column-value><![CDATA[");
268         sb.append(getTableId());
269         sb.append("]]></column-value></column>");
270         sb.append(
271             "<column><column-name>name</column-name><column-value><![CDATA[");
272         sb.append(getName());
273         sb.append("]]></column-value></column>");
274         sb.append(
275             "<column><column-name>type</column-name><column-value><![CDATA[");
276         sb.append(getType());
277         sb.append("]]></column-value></column>");
278 
279         sb.append("</model>");
280 
281         return sb.toString();
282     }
283 
284     private long _columnId;
285     private long _tableId;
286     private long _originalTableId;
287     private boolean _setOriginalTableId;
288     private String _name;
289     private String _originalName;
290     private int _type;
291 }