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    
023    import com.liferay.portlet.expando.model.ExpandoColumn;
024    import com.liferay.portlet.expando.model.ExpandoColumnModel;
025    import com.liferay.portlet.expando.model.ExpandoColumnSoap;
026    
027    import java.io.Serializable;
028    
029    import java.lang.reflect.Proxy;
030    
031    import java.sql.Types;
032    
033    import java.util.ArrayList;
034    import java.util.List;
035    
036    /**
037     * The base model implementation for the ExpandoColumn service. Represents a row in the "ExpandoColumn" database table, with each column mapped to a property of this class.
038     *
039     * <p>
040     * This implementation and its corresponding interface {@link com.liferay.portlet.expando.model.ExpandoColumnModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link ExpandoColumnImpl}.
041     * </p>
042     *
043     * <p>
044     * Never modify or reference this class directly. All methods that expect a expando column model instance should use the {@link com.liferay.portlet.expando.model.ExpandoColumn} interface instead.
045     * </p>
046     *
047     * @author Brian Wing Shun Chan
048     * @see ExpandoColumnImpl
049     * @see com.liferay.portlet.expando.model.ExpandoColumn
050     * @see com.liferay.portlet.expando.model.ExpandoColumnModel
051     * @generated
052     */
053    public class ExpandoColumnModelImpl extends BaseModelImpl<ExpandoColumn>
054            implements ExpandoColumnModel {
055            public static final String TABLE_NAME = "ExpandoColumn";
056            public static final Object[][] TABLE_COLUMNS = {
057                            { "columnId", new Integer(Types.BIGINT) },
058                            { "companyId", new Integer(Types.BIGINT) },
059                            { "tableId", new Integer(Types.BIGINT) },
060                            { "name", new Integer(Types.VARCHAR) },
061                            { "type_", new Integer(Types.INTEGER) },
062                            { "defaultData", new Integer(Types.VARCHAR) },
063                            { "typeSettings", new Integer(Types.CLOB) }
064                    };
065            public static final String TABLE_SQL_CREATE = "create table ExpandoColumn (columnId LONG not null primary key,companyId LONG,tableId LONG,name VARCHAR(75) null,type_ INTEGER,defaultData STRING null,typeSettings TEXT null)";
066            public static final String TABLE_SQL_DROP = "drop table ExpandoColumn";
067            public static final String ORDER_BY_JPQL = " ORDER BY expandoColumn.name ASC";
068            public static final String ORDER_BY_SQL = " ORDER BY ExpandoColumn.name ASC";
069            public static final String DATA_SOURCE = "liferayDataSource";
070            public static final String SESSION_FACTORY = "liferaySessionFactory";
071            public static final String TX_MANAGER = "liferayTransactionManager";
072            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
073                                    "value.object.entity.cache.enabled.com.liferay.portlet.expando.model.ExpandoColumn"),
074                            true);
075            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
076                                    "value.object.finder.cache.enabled.com.liferay.portlet.expando.model.ExpandoColumn"),
077                            true);
078    
079            /**
080             * Converts the soap model instance into a normal model instance.
081             *
082             * @param soapModel the soap model instance to convert
083             * @return the normal model instance
084             */
085            public static ExpandoColumn toModel(ExpandoColumnSoap soapModel) {
086                    ExpandoColumn model = new ExpandoColumnImpl();
087    
088                    model.setColumnId(soapModel.getColumnId());
089                    model.setCompanyId(soapModel.getCompanyId());
090                    model.setTableId(soapModel.getTableId());
091                    model.setName(soapModel.getName());
092                    model.setType(soapModel.getType());
093                    model.setDefaultData(soapModel.getDefaultData());
094                    model.setTypeSettings(soapModel.getTypeSettings());
095    
096                    return model;
097            }
098    
099            /**
100             * Converts the soap model instances into normal model instances.
101             *
102             * @param soapModels the soap model instances to convert
103             * @return the normal model instances
104             */
105            public static List<ExpandoColumn> toModels(ExpandoColumnSoap[] soapModels) {
106                    List<ExpandoColumn> models = new ArrayList<ExpandoColumn>(soapModels.length);
107    
108                    for (ExpandoColumnSoap soapModel : soapModels) {
109                            models.add(toModel(soapModel));
110                    }
111    
112                    return models;
113            }
114    
115            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
116                                    "lock.expiration.time.com.liferay.portlet.expando.model.ExpandoColumn"));
117    
118            public ExpandoColumnModelImpl() {
119            }
120    
121            public long getPrimaryKey() {
122                    return _columnId;
123            }
124    
125            public void setPrimaryKey(long pk) {
126                    setColumnId(pk);
127            }
128    
129            public Serializable getPrimaryKeyObj() {
130                    return new Long(_columnId);
131            }
132    
133            public long getColumnId() {
134                    return _columnId;
135            }
136    
137            public void setColumnId(long columnId) {
138                    _columnId = columnId;
139            }
140    
141            public long getCompanyId() {
142                    return _companyId;
143            }
144    
145            public void setCompanyId(long companyId) {
146                    _companyId = companyId;
147            }
148    
149            public long getTableId() {
150                    return _tableId;
151            }
152    
153            public void setTableId(long tableId) {
154                    _tableId = tableId;
155    
156                    if (!_setOriginalTableId) {
157                            _setOriginalTableId = true;
158    
159                            _originalTableId = tableId;
160                    }
161            }
162    
163            public long getOriginalTableId() {
164                    return _originalTableId;
165            }
166    
167            public String getName() {
168                    if (_name == null) {
169                            return StringPool.BLANK;
170                    }
171                    else {
172                            return _name;
173                    }
174            }
175    
176            public void setName(String name) {
177                    _name = name;
178    
179                    if (_originalName == null) {
180                            _originalName = name;
181                    }
182            }
183    
184            public String getOriginalName() {
185                    return GetterUtil.getString(_originalName);
186            }
187    
188            public int getType() {
189                    return _type;
190            }
191    
192            public void setType(int type) {
193                    _type = type;
194            }
195    
196            public String getDefaultData() {
197                    if (_defaultData == null) {
198                            return StringPool.BLANK;
199                    }
200                    else {
201                            return _defaultData;
202                    }
203            }
204    
205            public void setDefaultData(String defaultData) {
206                    _defaultData = defaultData;
207            }
208    
209            public String getTypeSettings() {
210                    if (_typeSettings == null) {
211                            return StringPool.BLANK;
212                    }
213                    else {
214                            return _typeSettings;
215                    }
216            }
217    
218            public void setTypeSettings(String typeSettings) {
219                    _typeSettings = typeSettings;
220            }
221    
222            public ExpandoColumn toEscapedModel() {
223                    if (isEscapedModel()) {
224                            return (ExpandoColumn)this;
225                    }
226                    else {
227                            return (ExpandoColumn)Proxy.newProxyInstance(ExpandoColumn.class.getClassLoader(),
228                                    new Class[] { ExpandoColumn.class },
229                                    new AutoEscapeBeanHandler(this));
230                    }
231            }
232    
233            public Object clone() {
234                    ExpandoColumnImpl clone = new ExpandoColumnImpl();
235    
236                    clone.setColumnId(getColumnId());
237                    clone.setCompanyId(getCompanyId());
238                    clone.setTableId(getTableId());
239                    clone.setName(getName());
240                    clone.setType(getType());
241                    clone.setDefaultData(getDefaultData());
242                    clone.setTypeSettings(getTypeSettings());
243    
244                    return clone;
245            }
246    
247            public int compareTo(ExpandoColumn expandoColumn) {
248                    int value = 0;
249    
250                    value = getName().compareTo(expandoColumn.getName());
251    
252                    if (value != 0) {
253                            return value;
254                    }
255    
256                    return 0;
257            }
258    
259            public boolean equals(Object obj) {
260                    if (obj == null) {
261                            return false;
262                    }
263    
264                    ExpandoColumn expandoColumn = null;
265    
266                    try {
267                            expandoColumn = (ExpandoColumn)obj;
268                    }
269                    catch (ClassCastException cce) {
270                            return false;
271                    }
272    
273                    long pk = expandoColumn.getPrimaryKey();
274    
275                    if (getPrimaryKey() == pk) {
276                            return true;
277                    }
278                    else {
279                            return false;
280                    }
281            }
282    
283            public int hashCode() {
284                    return (int)getPrimaryKey();
285            }
286    
287            public String toString() {
288                    StringBundler sb = new StringBundler(15);
289    
290                    sb.append("{columnId=");
291                    sb.append(getColumnId());
292                    sb.append(", companyId=");
293                    sb.append(getCompanyId());
294                    sb.append(", tableId=");
295                    sb.append(getTableId());
296                    sb.append(", name=");
297                    sb.append(getName());
298                    sb.append(", type=");
299                    sb.append(getType());
300                    sb.append(", defaultData=");
301                    sb.append(getDefaultData());
302                    sb.append(", typeSettings=");
303                    sb.append(getTypeSettings());
304                    sb.append("}");
305    
306                    return sb.toString();
307            }
308    
309            public String toXmlString() {
310                    StringBundler sb = new StringBundler(25);
311    
312                    sb.append("<model><model-name>");
313                    sb.append("com.liferay.portlet.expando.model.ExpandoColumn");
314                    sb.append("</model-name>");
315    
316                    sb.append(
317                            "<column><column-name>columnId</column-name><column-value><![CDATA[");
318                    sb.append(getColumnId());
319                    sb.append("]]></column-value></column>");
320                    sb.append(
321                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
322                    sb.append(getCompanyId());
323                    sb.append("]]></column-value></column>");
324                    sb.append(
325                            "<column><column-name>tableId</column-name><column-value><![CDATA[");
326                    sb.append(getTableId());
327                    sb.append("]]></column-value></column>");
328                    sb.append(
329                            "<column><column-name>name</column-name><column-value><![CDATA[");
330                    sb.append(getName());
331                    sb.append("]]></column-value></column>");
332                    sb.append(
333                            "<column><column-name>type</column-name><column-value><![CDATA[");
334                    sb.append(getType());
335                    sb.append("]]></column-value></column>");
336                    sb.append(
337                            "<column><column-name>defaultData</column-name><column-value><![CDATA[");
338                    sb.append(getDefaultData());
339                    sb.append("]]></column-value></column>");
340                    sb.append(
341                            "<column><column-name>typeSettings</column-name><column-value><![CDATA[");
342                    sb.append(getTypeSettings());
343                    sb.append("]]></column-value></column>");
344    
345                    sb.append("</model>");
346    
347                    return sb.toString();
348            }
349    
350            private long _columnId;
351            private long _companyId;
352            private long _tableId;
353            private long _originalTableId;
354            private boolean _setOriginalTableId;
355            private String _name;
356            private String _originalName;
357            private int _type;
358            private String _defaultData;
359            private String _typeSettings;
360    }