001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.expando.model.impl;
016    
017    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.util.GetterUtil;
019    import com.liferay.portal.kernel.util.StringBundler;
020    import com.liferay.portal.kernel.util.StringPool;
021    import com.liferay.portal.model.impl.BaseModelImpl;
022    import com.liferay.portal.util.PortalUtil;
023    
024    import com.liferay.portlet.expando.model.ExpandoTable;
025    import com.liferay.portlet.expando.model.ExpandoTableModel;
026    
027    import java.io.Serializable;
028    
029    import java.lang.reflect.Proxy;
030    
031    import java.sql.Types;
032    
033    /**
034     * <p>
035     * This interface is a model that represents the ExpandoTable table in the
036     * database.
037     * </p>
038     *
039     * @author    Brian Wing Shun Chan
040     * @see       ExpandoTableImpl
041     * @see       com.liferay.portlet.expando.model.ExpandoTable
042     * @see       com.liferay.portlet.expando.model.ExpandoTableModel
043     * @generated
044     */
045    public class ExpandoTableModelImpl extends BaseModelImpl<ExpandoTable>
046            implements ExpandoTableModel {
047            public static final String TABLE_NAME = "ExpandoTable";
048            public static final Object[][] TABLE_COLUMNS = {
049                            { "tableId", new Integer(Types.BIGINT) },
050                            { "companyId", new Integer(Types.BIGINT) },
051                            { "classNameId", new Integer(Types.BIGINT) },
052                            { "name", new Integer(Types.VARCHAR) }
053                    };
054            public static final String TABLE_SQL_CREATE = "create table ExpandoTable (tableId LONG not null primary key,companyId LONG,classNameId LONG,name VARCHAR(75) null)";
055            public static final String TABLE_SQL_DROP = "drop table ExpandoTable";
056            public static final String DATA_SOURCE = "liferayDataSource";
057            public static final String SESSION_FACTORY = "liferaySessionFactory";
058            public static final String TX_MANAGER = "liferayTransactionManager";
059            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
060                                    "value.object.entity.cache.enabled.com.liferay.portlet.expando.model.ExpandoTable"),
061                            true);
062            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
063                                    "value.object.finder.cache.enabled.com.liferay.portlet.expando.model.ExpandoTable"),
064                            true);
065            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
066                                    "lock.expiration.time.com.liferay.portlet.expando.model.ExpandoTable"));
067    
068            public ExpandoTableModelImpl() {
069            }
070    
071            public long getPrimaryKey() {
072                    return _tableId;
073            }
074    
075            public void setPrimaryKey(long pk) {
076                    setTableId(pk);
077            }
078    
079            public Serializable getPrimaryKeyObj() {
080                    return new Long(_tableId);
081            }
082    
083            public long getTableId() {
084                    return _tableId;
085            }
086    
087            public void setTableId(long tableId) {
088                    _tableId = tableId;
089            }
090    
091            public long getCompanyId() {
092                    return _companyId;
093            }
094    
095            public void setCompanyId(long companyId) {
096                    _companyId = companyId;
097    
098                    if (!_setOriginalCompanyId) {
099                            _setOriginalCompanyId = true;
100    
101                            _originalCompanyId = companyId;
102                    }
103            }
104    
105            public long getOriginalCompanyId() {
106                    return _originalCompanyId;
107            }
108    
109            public String getClassName() {
110                    if (getClassNameId() <= 0) {
111                            return StringPool.BLANK;
112                    }
113    
114                    return PortalUtil.getClassName(getClassNameId());
115            }
116    
117            public long getClassNameId() {
118                    return _classNameId;
119            }
120    
121            public void setClassNameId(long classNameId) {
122                    _classNameId = classNameId;
123    
124                    if (!_setOriginalClassNameId) {
125                            _setOriginalClassNameId = true;
126    
127                            _originalClassNameId = classNameId;
128                    }
129            }
130    
131            public long getOriginalClassNameId() {
132                    return _originalClassNameId;
133            }
134    
135            public String getName() {
136                    if (_name == null) {
137                            return StringPool.BLANK;
138                    }
139                    else {
140                            return _name;
141                    }
142            }
143    
144            public void setName(String name) {
145                    _name = name;
146    
147                    if (_originalName == null) {
148                            _originalName = name;
149                    }
150            }
151    
152            public String getOriginalName() {
153                    return GetterUtil.getString(_originalName);
154            }
155    
156            public ExpandoTable toEscapedModel() {
157                    if (isEscapedModel()) {
158                            return (ExpandoTable)this;
159                    }
160                    else {
161                            return (ExpandoTable)Proxy.newProxyInstance(ExpandoTable.class.getClassLoader(),
162                                    new Class[] { ExpandoTable.class },
163                                    new AutoEscapeBeanHandler(this));
164                    }
165            }
166    
167            public Object clone() {
168                    ExpandoTableImpl clone = new ExpandoTableImpl();
169    
170                    clone.setTableId(getTableId());
171                    clone.setCompanyId(getCompanyId());
172                    clone.setClassNameId(getClassNameId());
173                    clone.setName(getName());
174    
175                    return clone;
176            }
177    
178            public int compareTo(ExpandoTable expandoTable) {
179                    long pk = expandoTable.getPrimaryKey();
180    
181                    if (getPrimaryKey() < pk) {
182                            return -1;
183                    }
184                    else if (getPrimaryKey() > pk) {
185                            return 1;
186                    }
187                    else {
188                            return 0;
189                    }
190            }
191    
192            public boolean equals(Object obj) {
193                    if (obj == null) {
194                            return false;
195                    }
196    
197                    ExpandoTable expandoTable = null;
198    
199                    try {
200                            expandoTable = (ExpandoTable)obj;
201                    }
202                    catch (ClassCastException cce) {
203                            return false;
204                    }
205    
206                    long pk = expandoTable.getPrimaryKey();
207    
208                    if (getPrimaryKey() == pk) {
209                            return true;
210                    }
211                    else {
212                            return false;
213                    }
214            }
215    
216            public int hashCode() {
217                    return (int)getPrimaryKey();
218            }
219    
220            public String toString() {
221                    StringBundler sb = new StringBundler(9);
222    
223                    sb.append("{tableId=");
224                    sb.append(getTableId());
225                    sb.append(", companyId=");
226                    sb.append(getCompanyId());
227                    sb.append(", classNameId=");
228                    sb.append(getClassNameId());
229                    sb.append(", name=");
230                    sb.append(getName());
231                    sb.append("}");
232    
233                    return sb.toString();
234            }
235    
236            public String toXmlString() {
237                    StringBundler sb = new StringBundler(16);
238    
239                    sb.append("<model><model-name>");
240                    sb.append("com.liferay.portlet.expando.model.ExpandoTable");
241                    sb.append("</model-name>");
242    
243                    sb.append(
244                            "<column><column-name>tableId</column-name><column-value><![CDATA[");
245                    sb.append(getTableId());
246                    sb.append("]]></column-value></column>");
247                    sb.append(
248                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
249                    sb.append(getCompanyId());
250                    sb.append("]]></column-value></column>");
251                    sb.append(
252                            "<column><column-name>classNameId</column-name><column-value><![CDATA[");
253                    sb.append(getClassNameId());
254                    sb.append("]]></column-value></column>");
255                    sb.append(
256                            "<column><column-name>name</column-name><column-value><![CDATA[");
257                    sb.append(getName());
258                    sb.append("]]></column-value></column>");
259    
260                    sb.append("</model>");
261    
262                    return sb.toString();
263            }
264    
265            private long _tableId;
266            private long _companyId;
267            private long _originalCompanyId;
268            private boolean _setOriginalCompanyId;
269            private long _classNameId;
270            private long _originalClassNameId;
271            private boolean _setOriginalClassNameId;
272            private String _name;
273            private String _originalName;
274    }