001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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     * The base model implementation for the ExpandoTable service. Represents a row in the "ExpandoTable" database table, with each column mapped to a property of this class.
035     *
036     * <p>
037     * This implementation and its corresponding interface {@link com.liferay.portlet.expando.model.ExpandoTableModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link ExpandoTableImpl}.
038     * </p>
039     *
040     * <p>
041     * Never modify or reference this class directly. All methods that expect a expando table model instance should use the {@link com.liferay.portlet.expando.model.ExpandoTable} interface instead.
042     * </p>
043     *
044     * @author Brian Wing Shun Chan
045     * @see ExpandoTableImpl
046     * @see com.liferay.portlet.expando.model.ExpandoTable
047     * @see com.liferay.portlet.expando.model.ExpandoTableModel
048     * @generated
049     */
050    public class ExpandoTableModelImpl extends BaseModelImpl<ExpandoTable>
051            implements ExpandoTableModel {
052            public static final String TABLE_NAME = "ExpandoTable";
053            public static final Object[][] TABLE_COLUMNS = {
054                            { "tableId", new Integer(Types.BIGINT) },
055                            { "companyId", new Integer(Types.BIGINT) },
056                            { "classNameId", new Integer(Types.BIGINT) },
057                            { "name", new Integer(Types.VARCHAR) }
058                    };
059            public static final String TABLE_SQL_CREATE = "create table ExpandoTable (tableId LONG not null primary key,companyId LONG,classNameId LONG,name VARCHAR(75) null)";
060            public static final String TABLE_SQL_DROP = "drop table ExpandoTable";
061            public static final String DATA_SOURCE = "liferayDataSource";
062            public static final String SESSION_FACTORY = "liferaySessionFactory";
063            public static final String TX_MANAGER = "liferayTransactionManager";
064            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
065                                    "value.object.entity.cache.enabled.com.liferay.portlet.expando.model.ExpandoTable"),
066                            true);
067            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
068                                    "value.object.finder.cache.enabled.com.liferay.portlet.expando.model.ExpandoTable"),
069                            true);
070            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
071                                    "lock.expiration.time.com.liferay.portlet.expando.model.ExpandoTable"));
072    
073            public ExpandoTableModelImpl() {
074            }
075    
076            public long getPrimaryKey() {
077                    return _tableId;
078            }
079    
080            public void setPrimaryKey(long pk) {
081                    setTableId(pk);
082            }
083    
084            public Serializable getPrimaryKeyObj() {
085                    return new Long(_tableId);
086            }
087    
088            public long getTableId() {
089                    return _tableId;
090            }
091    
092            public void setTableId(long tableId) {
093                    _tableId = tableId;
094            }
095    
096            public long getCompanyId() {
097                    return _companyId;
098            }
099    
100            public void setCompanyId(long companyId) {
101                    _companyId = companyId;
102    
103                    if (!_setOriginalCompanyId) {
104                            _setOriginalCompanyId = true;
105    
106                            _originalCompanyId = companyId;
107                    }
108            }
109    
110            public long getOriginalCompanyId() {
111                    return _originalCompanyId;
112            }
113    
114            public String getClassName() {
115                    if (getClassNameId() <= 0) {
116                            return StringPool.BLANK;
117                    }
118    
119                    return PortalUtil.getClassName(getClassNameId());
120            }
121    
122            public long getClassNameId() {
123                    return _classNameId;
124            }
125    
126            public void setClassNameId(long classNameId) {
127                    _classNameId = classNameId;
128    
129                    if (!_setOriginalClassNameId) {
130                            _setOriginalClassNameId = true;
131    
132                            _originalClassNameId = classNameId;
133                    }
134            }
135    
136            public long getOriginalClassNameId() {
137                    return _originalClassNameId;
138            }
139    
140            public String getName() {
141                    if (_name == null) {
142                            return StringPool.BLANK;
143                    }
144                    else {
145                            return _name;
146                    }
147            }
148    
149            public void setName(String name) {
150                    _name = name;
151    
152                    if (_originalName == null) {
153                            _originalName = name;
154                    }
155            }
156    
157            public String getOriginalName() {
158                    return GetterUtil.getString(_originalName);
159            }
160    
161            public ExpandoTable toEscapedModel() {
162                    if (isEscapedModel()) {
163                            return (ExpandoTable)this;
164                    }
165                    else {
166                            return (ExpandoTable)Proxy.newProxyInstance(ExpandoTable.class.getClassLoader(),
167                                    new Class[] { ExpandoTable.class },
168                                    new AutoEscapeBeanHandler(this));
169                    }
170            }
171    
172            public Object clone() {
173                    ExpandoTableImpl clone = new ExpandoTableImpl();
174    
175                    clone.setTableId(getTableId());
176                    clone.setCompanyId(getCompanyId());
177                    clone.setClassNameId(getClassNameId());
178                    clone.setName(getName());
179    
180                    return clone;
181            }
182    
183            public int compareTo(ExpandoTable expandoTable) {
184                    long pk = expandoTable.getPrimaryKey();
185    
186                    if (getPrimaryKey() < pk) {
187                            return -1;
188                    }
189                    else if (getPrimaryKey() > pk) {
190                            return 1;
191                    }
192                    else {
193                            return 0;
194                    }
195            }
196    
197            public boolean equals(Object obj) {
198                    if (obj == null) {
199                            return false;
200                    }
201    
202                    ExpandoTable expandoTable = null;
203    
204                    try {
205                            expandoTable = (ExpandoTable)obj;
206                    }
207                    catch (ClassCastException cce) {
208                            return false;
209                    }
210    
211                    long pk = expandoTable.getPrimaryKey();
212    
213                    if (getPrimaryKey() == pk) {
214                            return true;
215                    }
216                    else {
217                            return false;
218                    }
219            }
220    
221            public int hashCode() {
222                    return (int)getPrimaryKey();
223            }
224    
225            public String toString() {
226                    StringBundler sb = new StringBundler(9);
227    
228                    sb.append("{tableId=");
229                    sb.append(getTableId());
230                    sb.append(", companyId=");
231                    sb.append(getCompanyId());
232                    sb.append(", classNameId=");
233                    sb.append(getClassNameId());
234                    sb.append(", name=");
235                    sb.append(getName());
236                    sb.append("}");
237    
238                    return sb.toString();
239            }
240    
241            public String toXmlString() {
242                    StringBundler sb = new StringBundler(16);
243    
244                    sb.append("<model><model-name>");
245                    sb.append("com.liferay.portlet.expando.model.ExpandoTable");
246                    sb.append("</model-name>");
247    
248                    sb.append(
249                            "<column><column-name>tableId</column-name><column-value><![CDATA[");
250                    sb.append(getTableId());
251                    sb.append("]]></column-value></column>");
252                    sb.append(
253                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
254                    sb.append(getCompanyId());
255                    sb.append("]]></column-value></column>");
256                    sb.append(
257                            "<column><column-name>classNameId</column-name><column-value><![CDATA[");
258                    sb.append(getClassNameId());
259                    sb.append("]]></column-value></column>");
260                    sb.append(
261                            "<column><column-name>name</column-name><column-value><![CDATA[");
262                    sb.append(getName());
263                    sb.append("]]></column-value></column>");
264    
265                    sb.append("</model>");
266    
267                    return sb.toString();
268            }
269    
270            private long _tableId;
271            private long _companyId;
272            private long _originalCompanyId;
273            private boolean _setOriginalCompanyId;
274            private long _classNameId;
275            private long _originalClassNameId;
276            private boolean _setOriginalClassNameId;
277            private String _name;
278            private String _originalName;
279    }