001    /**
002     * Copyright (c) 2000-2011 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     * 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                    if (!_setOriginalCompanyId) {
102                            _setOriginalCompanyId = true;
103    
104                            _originalCompanyId = _companyId;
105                    }
106    
107                    _companyId = companyId;
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                    if (!_setOriginalClassNameId) {
128                            _setOriginalClassNameId = true;
129    
130                            _originalClassNameId = _classNameId;
131                    }
132    
133                    _classNameId = classNameId;
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                    if (_originalName == null) {
151                            _originalName = _name;
152                    }
153    
154                    _name = name;
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 expandoTableImpl = new ExpandoTableImpl();
174    
175                    expandoTableImpl.setTableId(getTableId());
176    
177                    expandoTableImpl.setCompanyId(getCompanyId());
178    
179                    ExpandoTableModelImpl expandoTableModelImpl = expandoTableImpl;
180    
181                    expandoTableModelImpl._originalCompanyId = expandoTableModelImpl._companyId;
182    
183                    expandoTableModelImpl._setOriginalCompanyId = false;
184                    expandoTableImpl.setClassNameId(getClassNameId());
185    
186                    expandoTableModelImpl._originalClassNameId = expandoTableModelImpl._classNameId;
187    
188                    expandoTableModelImpl._setOriginalClassNameId = false;
189                    expandoTableImpl.setName(getName());
190    
191                    expandoTableModelImpl._originalName = expandoTableModelImpl._name;
192    
193                    return expandoTableImpl;
194            }
195    
196            public int compareTo(ExpandoTable expandoTable) {
197                    long pk = expandoTable.getPrimaryKey();
198    
199                    if (getPrimaryKey() < pk) {
200                            return -1;
201                    }
202                    else if (getPrimaryKey() > pk) {
203                            return 1;
204                    }
205                    else {
206                            return 0;
207                    }
208            }
209    
210            public boolean equals(Object obj) {
211                    if (obj == null) {
212                            return false;
213                    }
214    
215                    ExpandoTable expandoTable = null;
216    
217                    try {
218                            expandoTable = (ExpandoTable)obj;
219                    }
220                    catch (ClassCastException cce) {
221                            return false;
222                    }
223    
224                    long pk = expandoTable.getPrimaryKey();
225    
226                    if (getPrimaryKey() == pk) {
227                            return true;
228                    }
229                    else {
230                            return false;
231                    }
232            }
233    
234            public int hashCode() {
235                    return (int)getPrimaryKey();
236            }
237    
238            public String toString() {
239                    StringBundler sb = new StringBundler(9);
240    
241                    sb.append("{tableId=");
242                    sb.append(getTableId());
243                    sb.append(", companyId=");
244                    sb.append(getCompanyId());
245                    sb.append(", classNameId=");
246                    sb.append(getClassNameId());
247                    sb.append(", name=");
248                    sb.append(getName());
249                    sb.append("}");
250    
251                    return sb.toString();
252            }
253    
254            public String toXmlString() {
255                    StringBundler sb = new StringBundler(16);
256    
257                    sb.append("<model><model-name>");
258                    sb.append("com.liferay.portlet.expando.model.ExpandoTable");
259                    sb.append("</model-name>");
260    
261                    sb.append(
262                            "<column><column-name>tableId</column-name><column-value><![CDATA[");
263                    sb.append(getTableId());
264                    sb.append("]]></column-value></column>");
265                    sb.append(
266                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
267                    sb.append(getCompanyId());
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 _companyId;
285            private long _originalCompanyId;
286            private boolean _setOriginalCompanyId;
287            private long _classNameId;
288            private long _originalClassNameId;
289            private boolean _setOriginalClassNameId;
290            private String _name;
291            private String _originalName;
292    }