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.portal.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.ClassName;
022    import com.liferay.portal.model.ClassNameModel;
023    import com.liferay.portal.model.ClassNameSoap;
024    import com.liferay.portal.service.ServiceContext;
025    import com.liferay.portal.util.PortalUtil;
026    
027    import com.liferay.portlet.expando.model.ExpandoBridge;
028    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
029    
030    import java.io.Serializable;
031    
032    import java.lang.reflect.Proxy;
033    
034    import java.sql.Types;
035    
036    import java.util.ArrayList;
037    import java.util.List;
038    
039    /**
040     * The base model implementation for the ClassName service. Represents a row in the "ClassName_" database table, with each column mapped to a property of this class.
041     *
042     * <p>
043     * This implementation and its corresponding interface {@link com.liferay.portal.model.ClassNameModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link ClassNameImpl}.
044     * </p>
045     *
046     * <p>
047     * Never modify or reference this class directly. All methods that expect a class name model instance should use the {@link com.liferay.portal.model.ClassName} interface instead.
048     * </p>
049     *
050     * @author Brian Wing Shun Chan
051     * @see ClassNameImpl
052     * @see com.liferay.portal.model.ClassName
053     * @see com.liferay.portal.model.ClassNameModel
054     * @generated
055     */
056    public class ClassNameModelImpl extends BaseModelImpl<ClassName>
057            implements ClassNameModel {
058            public static final String TABLE_NAME = "ClassName_";
059            public static final Object[][] TABLE_COLUMNS = {
060                            { "classNameId", new Integer(Types.BIGINT) },
061                            { "value", new Integer(Types.VARCHAR) }
062                    };
063            public static final String TABLE_SQL_CREATE = "create table ClassName_ (classNameId LONG not null primary key,value VARCHAR(200) null)";
064            public static final String TABLE_SQL_DROP = "drop table ClassName_";
065            public static final String DATA_SOURCE = "liferayDataSource";
066            public static final String SESSION_FACTORY = "liferaySessionFactory";
067            public static final String TX_MANAGER = "liferayTransactionManager";
068            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
069                                    "value.object.entity.cache.enabled.com.liferay.portal.model.ClassName"),
070                            true);
071            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
072                                    "value.object.finder.cache.enabled.com.liferay.portal.model.ClassName"),
073                            true);
074    
075            /**
076             * Converts the soap model instance into a normal model instance.
077             *
078             * @param soapModel the soap model instance to convert
079             * @return the normal model instance
080             */
081            public static ClassName toModel(ClassNameSoap soapModel) {
082                    ClassName model = new ClassNameImpl();
083    
084                    model.setClassNameId(soapModel.getClassNameId());
085                    model.setValue(soapModel.getValue());
086    
087                    return model;
088            }
089    
090            /**
091             * Converts the soap model instances into normal model instances.
092             *
093             * @param soapModels the soap model instances to convert
094             * @return the normal model instances
095             */
096            public static List<ClassName> toModels(ClassNameSoap[] soapModels) {
097                    List<ClassName> models = new ArrayList<ClassName>(soapModels.length);
098    
099                    for (ClassNameSoap soapModel : soapModels) {
100                            models.add(toModel(soapModel));
101                    }
102    
103                    return models;
104            }
105    
106            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
107                                    "lock.expiration.time.com.liferay.portal.model.ClassName"));
108    
109            public ClassNameModelImpl() {
110            }
111    
112            public long getPrimaryKey() {
113                    return _classNameId;
114            }
115    
116            public void setPrimaryKey(long pk) {
117                    setClassNameId(pk);
118            }
119    
120            public Serializable getPrimaryKeyObj() {
121                    return new Long(_classNameId);
122            }
123    
124            public String getClassName() {
125                    if (getClassNameId() <= 0) {
126                            return StringPool.BLANK;
127                    }
128    
129                    return PortalUtil.getClassName(getClassNameId());
130            }
131    
132            public long getClassNameId() {
133                    return _classNameId;
134            }
135    
136            public void setClassNameId(long classNameId) {
137                    _classNameId = classNameId;
138            }
139    
140            public String getValue() {
141                    if (_value == null) {
142                            return StringPool.BLANK;
143                    }
144                    else {
145                            return _value;
146                    }
147            }
148    
149            public void setValue(String value) {
150                    if (_originalValue == null) {
151                            _originalValue = _value;
152                    }
153    
154                    _value = value;
155            }
156    
157            public String getOriginalValue() {
158                    return GetterUtil.getString(_originalValue);
159            }
160    
161            public ClassName toEscapedModel() {
162                    if (isEscapedModel()) {
163                            return (ClassName)this;
164                    }
165                    else {
166                            return (ClassName)Proxy.newProxyInstance(ClassName.class.getClassLoader(),
167                                    new Class[] { ClassName.class }, new AutoEscapeBeanHandler(this));
168                    }
169            }
170    
171            public ExpandoBridge getExpandoBridge() {
172                    if (_expandoBridge == null) {
173                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
174                                            ClassName.class.getName(), getPrimaryKey());
175                    }
176    
177                    return _expandoBridge;
178            }
179    
180            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
181                    getExpandoBridge().setAttributes(serviceContext);
182            }
183    
184            public Object clone() {
185                    ClassNameImpl classNameImpl = new ClassNameImpl();
186    
187                    classNameImpl.setClassNameId(getClassNameId());
188    
189                    classNameImpl.setValue(getValue());
190    
191                    ClassNameModelImpl classNameModelImpl = classNameImpl;
192    
193                    classNameModelImpl._originalValue = classNameModelImpl._value;
194    
195                    return classNameImpl;
196            }
197    
198            public int compareTo(ClassName className) {
199                    long pk = className.getPrimaryKey();
200    
201                    if (getPrimaryKey() < pk) {
202                            return -1;
203                    }
204                    else if (getPrimaryKey() > pk) {
205                            return 1;
206                    }
207                    else {
208                            return 0;
209                    }
210            }
211    
212            public boolean equals(Object obj) {
213                    if (obj == null) {
214                            return false;
215                    }
216    
217                    ClassName className = null;
218    
219                    try {
220                            className = (ClassName)obj;
221                    }
222                    catch (ClassCastException cce) {
223                            return false;
224                    }
225    
226                    long pk = className.getPrimaryKey();
227    
228                    if (getPrimaryKey() == pk) {
229                            return true;
230                    }
231                    else {
232                            return false;
233                    }
234            }
235    
236            public int hashCode() {
237                    return (int)getPrimaryKey();
238            }
239    
240            public String toString() {
241                    StringBundler sb = new StringBundler(5);
242    
243                    sb.append("{classNameId=");
244                    sb.append(getClassNameId());
245                    sb.append(", value=");
246                    sb.append(getValue());
247                    sb.append("}");
248    
249                    return sb.toString();
250            }
251    
252            public String toXmlString() {
253                    StringBundler sb = new StringBundler(10);
254    
255                    sb.append("<model><model-name>");
256                    sb.append("com.liferay.portal.model.ClassName");
257                    sb.append("</model-name>");
258    
259                    sb.append(
260                            "<column><column-name>classNameId</column-name><column-value><![CDATA[");
261                    sb.append(getClassNameId());
262                    sb.append("]]></column-value></column>");
263                    sb.append(
264                            "<column><column-name>value</column-name><column-value><![CDATA[");
265                    sb.append(getValue());
266                    sb.append("]]></column-value></column>");
267    
268                    sb.append("</model>");
269    
270                    return sb.toString();
271            }
272    
273            private long _classNameId;
274            private String _value;
275            private String _originalValue;
276            private transient ExpandoBridge _expandoBridge;
277    }