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