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.ExpandoTable;
33  import com.liferay.portlet.expando.model.ExpandoTableSoap;
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="ExpandoTableModelImpl.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 ExpandoTable table in the
54   * database.
55   * </p>
56   *
57   * @author    Brian Wing Shun Chan
58   * @see       ExpandoTableImpl
59   * @see       com.liferay.portlet.expando.model.ExpandoTable
60   * @see       com.liferay.portlet.expando.model.ExpandoTableModel
61   * @generated
62   */
63  public class ExpandoTableModelImpl extends BaseModelImpl<ExpandoTable> {
64      public static final String TABLE_NAME = "ExpandoTable";
65      public static final Object[][] TABLE_COLUMNS = {
66              { "tableId", new Integer(Types.BIGINT) },
67              { "classNameId", new Integer(Types.BIGINT) },
68              { "name", new Integer(Types.VARCHAR) }
69          };
70      public static final String TABLE_SQL_CREATE = "create table ExpandoTable (tableId LONG not null primary key,classNameId LONG,name VARCHAR(75) null)";
71      public static final String TABLE_SQL_DROP = "drop table ExpandoTable";
72      public static final String DATA_SOURCE = "liferayDataSource";
73      public static final String SESSION_FACTORY = "liferaySessionFactory";
74      public static final String TX_MANAGER = "liferayTransactionManager";
75      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
76                  "value.object.entity.cache.enabled.com.liferay.portlet.expando.model.ExpandoTable"),
77              true);
78      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
79                  "value.object.finder.cache.enabled.com.liferay.portlet.expando.model.ExpandoTable"),
80              true);
81  
82      public static ExpandoTable toModel(ExpandoTableSoap soapModel) {
83          ExpandoTable model = new ExpandoTableImpl();
84  
85          model.setTableId(soapModel.getTableId());
86          model.setClassNameId(soapModel.getClassNameId());
87          model.setName(soapModel.getName());
88  
89          return model;
90      }
91  
92      public static List<ExpandoTable> toModels(ExpandoTableSoap[] soapModels) {
93          List<ExpandoTable> models = new ArrayList<ExpandoTable>(soapModels.length);
94  
95          for (ExpandoTableSoap soapModel : soapModels) {
96              models.add(toModel(soapModel));
97          }
98  
99          return models;
100     }
101 
102     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
103                 "lock.expiration.time.com.liferay.portlet.expando.model.ExpandoTable"));
104 
105     public ExpandoTableModelImpl() {
106     }
107 
108     public long getPrimaryKey() {
109         return _tableId;
110     }
111 
112     public void setPrimaryKey(long pk) {
113         setTableId(pk);
114     }
115 
116     public Serializable getPrimaryKeyObj() {
117         return new Long(_tableId);
118     }
119 
120     public long getTableId() {
121         return _tableId;
122     }
123 
124     public void setTableId(long tableId) {
125         _tableId = tableId;
126     }
127 
128     public String getClassName() {
129         if (getClassNameId() <= 0) {
130             return StringPool.BLANK;
131         }
132 
133         return PortalUtil.getClassName(getClassNameId());
134     }
135 
136     public long getClassNameId() {
137         return _classNameId;
138     }
139 
140     public void setClassNameId(long classNameId) {
141         _classNameId = classNameId;
142 
143         if (!_setOriginalClassNameId) {
144             _setOriginalClassNameId = true;
145 
146             _originalClassNameId = classNameId;
147         }
148     }
149 
150     public long getOriginalClassNameId() {
151         return _originalClassNameId;
152     }
153 
154     public String getName() {
155         return GetterUtil.getString(_name);
156     }
157 
158     public void setName(String name) {
159         _name = name;
160 
161         if (_originalName == null) {
162             _originalName = name;
163         }
164     }
165 
166     public String getOriginalName() {
167         return GetterUtil.getString(_originalName);
168     }
169 
170     public ExpandoTable toEscapedModel() {
171         if (isEscapedModel()) {
172             return (ExpandoTable)this;
173         }
174         else {
175             ExpandoTable model = new ExpandoTableImpl();
176 
177             model.setNew(isNew());
178             model.setEscapedModel(true);
179 
180             model.setTableId(getTableId());
181             model.setClassNameId(getClassNameId());
182             model.setName(HtmlUtil.escape(getName()));
183 
184             model = (ExpandoTable)Proxy.newProxyInstance(ExpandoTable.class.getClassLoader(),
185                     new Class[] { ExpandoTable.class },
186                     new ReadOnlyBeanHandler(model));
187 
188             return model;
189         }
190     }
191 
192     public Object clone() {
193         ExpandoTableImpl clone = new ExpandoTableImpl();
194 
195         clone.setTableId(getTableId());
196         clone.setClassNameId(getClassNameId());
197         clone.setName(getName());
198 
199         return clone;
200     }
201 
202     public int compareTo(ExpandoTable expandoTable) {
203         long pk = expandoTable.getPrimaryKey();
204 
205         if (getPrimaryKey() < pk) {
206             return -1;
207         }
208         else if (getPrimaryKey() > pk) {
209             return 1;
210         }
211         else {
212             return 0;
213         }
214     }
215 
216     public boolean equals(Object obj) {
217         if (obj == null) {
218             return false;
219         }
220 
221         ExpandoTable expandoTable = null;
222 
223         try {
224             expandoTable = (ExpandoTable)obj;
225         }
226         catch (ClassCastException cce) {
227             return false;
228         }
229 
230         long pk = expandoTable.getPrimaryKey();
231 
232         if (getPrimaryKey() == pk) {
233             return true;
234         }
235         else {
236             return false;
237         }
238     }
239 
240     public int hashCode() {
241         return (int)getPrimaryKey();
242     }
243 
244     public String toString() {
245         StringBuilder sb = new StringBuilder();
246 
247         sb.append("{tableId=");
248         sb.append(getTableId());
249         sb.append(", classNameId=");
250         sb.append(getClassNameId());
251         sb.append(", name=");
252         sb.append(getName());
253         sb.append("}");
254 
255         return sb.toString();
256     }
257 
258     public String toXmlString() {
259         StringBuilder sb = new StringBuilder();
260 
261         sb.append("<model><model-name>");
262         sb.append("com.liferay.portlet.expando.model.ExpandoTable");
263         sb.append("</model-name>");
264 
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>classNameId</column-name><column-value><![CDATA[");
271         sb.append(getClassNameId());
272         sb.append("]]></column-value></column>");
273         sb.append(
274             "<column><column-name>name</column-name><column-value><![CDATA[");
275         sb.append(getName());
276         sb.append("]]></column-value></column>");
277 
278         sb.append("</model>");
279 
280         return sb.toString();
281     }
282 
283     private long _tableId;
284     private long _classNameId;
285     private long _originalClassNameId;
286     private boolean _setOriginalClassNameId;
287     private String _name;
288     private String _originalName;
289 }