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